Wednesday, December 14, 2011

Create expand collapse tree drupal 7

mymodule
|- mymodule.info
|- mymodule.module
|- mymodule.js
|- mymodule.css
|- images
 |- file.gif
 |- minus.gif
 |- plus.gif

mymodule.info:
name = My Module
description = My Description
core = 7.x

mymodule.module:
<?php

function mymodule_menu(){
  $items = array();

  $items['mymodule_page'] = array(
    'title' => 'demo',
    'type' => MENU_CALLBACK,
    'page callback' => 'mymodule_page',
    'access arguments' => array('access content')
  );

  return $items;
}

function mymodule_page() {

  drupal_add_library('system', 'drupal.collapse');
  drupal_add_js(drupal_get_path('module', 'mymodule') . '/mymodule.js', 'file');
  drupal_add_css(drupal_get_path('module', 'mymodule') . '/mymodule.css','file');

  $title = 'My Title';
  $type = 'ul';
  $attributes = array(
    'id' => 'my-custom-listing',
    'class' => 'custom-class another-custom-class', // a string or indexed (string) array with the classes for the list tag
  );

  $items[] = array(
    'data' => '1',
    'class' => array('dummy'=>'category'),
    'children' => array(
         array(
          'data'=> '1.1',
          'class' =>array('dummy'=> 'deepest_item')),
        array(
          'data'=> '1.2',
          'class' =>array('dummy'=> 'deepest_item')),
        array(
          'data'=> '1.3',
          'class' => array('dummy'=> 'category'),
         'children'=> array(
             array('data'=>'1.3.1','class' => array('dummy'=>'deepest_item')),
             array('data'=>'1.3.2','class' => array('dummy'=>'deepest_item'))
          )
        )
    )
  );

  $output =  array(
    'first_para' => array(
      '#type' => 'markup',
      '#markup' => '<p>A paragraph about some stuff...</p>',
    ),
    'second_para' => array(
      '#items' => $items,
      '#title' => $title,
      '#type' => $type,
      '#attributes' => $attributes,
      '#theme' => 'item_list',
    ),
  );
  return $output;

  //return theme_item_list(array('items' => $items, 'title' => $title, 'type' => $type, 'attributes' => $attributes)); }

mymodule.js:
(function ($) {
  $(document).ready(function() {
    $('li.category').addClass('expandable_icon');
    $('li.category').children().addClass('deepest_item');
    $('li.category').children().hide();
    $('li.category').each(
      function(column) {
       $(this).click(function(event){
          if (this == event.target) {
            if($(this).is('.expandable_icon')) {
             $(this).children().show();
             $(this).removeClass('expandable_icon');
             $(this).addClass('collapsible_icon');
            }else{
             $(this).children().hide();
             $(this).removeClass('collapsible_icon');
             $(this).addClass('expandable_icon');
            }
          }
        });
      });
    }
  );
})(jQuery);

mymodule.css:
.expandable_icon{
 list-style-image:url("./images/plus.gif");
 cursor:pointer;
}

.collapsible_icon{
 list-style-image:url("./images/minus.gif");
 cursor:pointer;
}

.deepest_item{
 list-style-image:url("./images/file.gif");
 cursor:pointer;
}

drush en -y mymodule

visit http://YOURSITE/mymodule_page

thanks
http://www.sendesignz.com/index.php/jquery/77-how-to-create-expand-and-collapse-list-item-using-jquery
http://api.drupal.org/api/drupal/includes--theme.inc/function/theme_item_list/7

Thursday, December 8, 2011

show/hide table column in drupal view by jquery

My note on how to toggle show/hide table column in drupal's view.

View 3 on drupal 7 produce html like this

<table class="views-table cols-4">
  <thead> <tr>
    <th class="views-field views-field-title">Example</th>
    <th class="views-field views-field-body">howto</th>
    <th class="views-field views-field-field-1">dynamically</th>
    <th class="views-field views-field-field-2">show/hide</th>
  </tr>
  </thead>
  <tbody>
    <tr class="odd views-row-first views-row-last">
      <td class="views-field views-field-title">table column</td>
      <td class="views-field views-field-body">Drupal</td>
      <td class="views-field views-field-3">Views</td>
      <td class="views-field views-field-4">jquery</td>
    </tr>
  </tbody>
</table>

go to view edit page
Displays -> Page Details -> Page Settings -> Footer
add the following code

Show columns
<form>
<input onclick="toggleVis(this, '.views-field-title')" type="checkbox"> Title
<input onclick="toggleVis(this, '.views-field-body')" type="checkbox"> Body
</form>

<script type="text/javascript">
  function toggleVis(chkbox, col){
    if(chkbox.checked == true) {jQuery(col).show();}
    else {jQuery(col).hide();}
  }
</script>


Some might prefer FAPI like this
function showhide_column_form($form, &$form_state) {

  $form['column_visible'] = array(
    '#type' => 'fieldset',
    '#title' => 'Show/Hide column',
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );

  $form['column_visible']['id'] = array(
    '#type' => 'checkbox',
    '#title' => 'column1',
    '#default_value' => 1,
    '#attributes' => array('onclick' =>"toggleVis(this, '.views-field-title');"),
  );

  return $form;
}
Then replace the previous HTML form by this
<?php
print drupal_render(drupal_get_form('showhide_column_form'));
?>

For me, accessing .module is faster than the view edit page
function my_module_form_views_exposed_form_alter(&$form,&$form_state)
{
  if($form['#id'] == 'views-exposed-form-my-search-page') {

    $inline_script = '
      <style type="text/css">
      .views-field-1 { display: none; }
      .views-field-2 { display: none; }
      </style>

      <script type="text/javascript">
        function toggleVis(chkbox,col){
         if(chkbox.checked == true) { jQuery(col).show(); }
         else {jQuery(col).hide(); }
        }
      </script>';

    $element = array(
      '#type' => 'markup',
      '#markup' => $inline_script,
    );

    drupal_add_html_head($element, 'css');
  }
}


Thanks:
The Drupal community
http://www.fiendish.demon.co.uk/html/javascript/hidetablecols.html

related post about jquery
http://stackoverflow.com/questions/4673267/hide-table-columns-automatically-by-checking-a-checkbox-with-jquery

Wednesday, December 7, 2011

Create Custom Search Criteria Page in Drupal7


function my_module_menu(){
  $items = array();

  $items['my_search_page'] = array(
    'title' => t('my search screen'),
    'description' => 'when the present views filter can not suit your need such as dependent dropdown',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('my_search_page'),
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
    'access arguments' => array('access content')
  );

  return $items;
}


function my_search_page($form, &$form_state) {

  if (!isset($form_state['storage']['my_module']['search_criteria'])) {
    return drupal_get_form('my_search_form');
  }

  $build = array();
  $rows = array();

  $header = array(
    array('data' => 'Title', 'field' => 'title', 'sort' => 'asc'),
    array('data' => 'Node ID', 'field' => 'nid'),
    array('data' => 'Type', 'field' => 'type'),
    array('data' => 'Created', 'field' => 'created'),
    array('data' => 'Published'),
    );

  $title = $form_state['input']['title'];

  $query = db_select('node', 'n')
            ->condition('status', 1)  //Only published nodes, change condition as it suits you
            ->condition('title', $title.'%', 'LIKE')
            ->extend('PagerDefault')  //Pager Extender
            ->limit(10)               //10 results per page
            ->extend('TableSort')     //Sorting Extender
            ->orderByHeader($header)  //Field to sort on is picked from $header
            ->fields ('n', array (
              'nid',
              'title',
              'type',
              'created',
              'status',
            ));

  $results = $query->execute();

  foreach ($results as $node) {
    $rows[] = array(
                l($node->title, 'node/'. $node->nid),
                $node->nid,
                $node->type,
                format_date($node->created),
                $node->status
              );
  }

  //Theme the html table: http://api.drupal.org/api/drupal/includes--theme.inc/function/theme_table/7
  $content = theme('table',
            array(
              'header' => $header,
              'rows' => $rows,
              'sticky' => TRUE,                  //Optional to indicate whether the table headers should be sticky
              'empty' => 'Find not found..',    //Optional empty text for the table if resultset is empty
            )
          );

  $build['content'] = array(
      'dummy1' => my_search_form($form, $form_state),
      'dummy2' => array('#markup' => $content,),
  );

  $build['pager'] = array(
      '#theme' => 'pager',
      '#weight' => 5,
  );

  return $build;
}


function my_search_form($form, &$form_state) {

  $form['criteria'] = array(
    '#type' => 'fieldset',
    '#title' => 'Search Criteria',
    '#attributes' => array('class' => array('container-inline')),
  );

  $form['criteria']['title'] = array(
    '#type' => 'textfield',
    '#title' => t('title'),
    '#value' => (isset($form_state['input']['title'])) ? $form_state['input']['title'] : "",
    '#size' => 10,
    '#maxlength' => 20,
  );

  $form['criteria']['submit'] = array(
    '#type' => 'submit',
    '#value' => 'search',
    '#submit' => array('my_search_form_submit'),
  );

  return $form;
}

function my_search_form_submit($form, &$form_state) {
  $form_state['storage']['my_module']['search_criteria'] = $form_state['values'];
  $form_state['rebuild'] = TRUE;
}



Thanks:
=======
Merge Search Criteria and search result in one page
http://drupal.org/node/1074920#comment-4529954

Create sortable and sticky-headers Table
http://www.rahulsingla.com/blog/2011/05/drupal-7-creating-drupal-style-tables-with-paging-sorting-and-sticky-headers

Multistep form
http://drupal.org/node/717750 + http://drupal.org/project/examples

Horizontal form elements
http://drupal.stackexchange.com/questions/7954/horizontal-form-elements


Wednesday, November 30, 2011

howto initial fields on Drupal 7 node creation screen


hook_form_alter
===============
# to find the element you want to change
install devel

$ cd sites/all/modules
$ mkdir mymodule
$ cd mymodule
$ vi mymodule.info

name = mymodule
description = mymodule description
core = 7.x


$ vi mymodule.module


function mymodule_form_alter(&$form, &$form_state, $form_id)
{
     // find out form_id you're interested
        drupal_set_message($form_id);
}

function mymodule_form_{content-type-machnie-name}_node_form_alter(&$form, &$form_state)
{
    // Prints a variable to the ‘message’ area of the page
        dpm($form);

    // print debuging infomation in order to find the element
        drupal_set_message($form['field_remark']['und']);

    // set default value as need
        $form['field_remark']['und']['0']['value']['#default_value'] = 'hello';
}

$ drush en -y mymodule


http://drupal.org/project/prepopulate
======================================
allows fields in most forms to be pre-populated from the $_REQUEST variable.


Thanks
- http://drupal.stackexchange.com/questions/5605/how-do-you-identify-a-form-element
- http://drupal.org/node/1248914
- http://drupal.org/node/1137562

Friday, November 25, 2011

multi monitor on linux xfce compiz

ถ้าจะใช้งาน เช่น ต่อ notebook ออก Projector หรือทำงาน 2 จอ
แนะนำ sudo apt-get install arandr ครับ

เลือกตำแหน่ง output ได้ครับ ว่าจะให้
แสดงซ้อนกัน
จอ notebook อยู่ซ้าย อีกจออยู่ขวา
หรือ จอ notebook อยู่ขวา อีกจออยู่ซ้าย
เป็นต้น

รวมถึง กรณี เช่น กำหนดให้ panel อยู่ด้านล่างของจอ (ผมชอบ interface แบบ win 3.11)
เลือกให้ 2 จอ แสดงผลซ้อนกัน
ความละเอียดจอภายนอกสูงกว่า (เวลาทำงานที่บ้าน ต่อ notebook ออกจอใหญ่ แล้วทำงานผ่านจอใหญ่เป็นหลัก)
เผลอ hibernate เครื่อง โดยที่ยังไม่ได้ปิด output จอภายนอก
หิ้วเครื่องไปทำงานที่อื่น
เมื่อเปิดเครื่อง ที่ๆไม่มีจอภายนอก
มันดันไม่ refresh ขนาดหน้าจอให้
ทำให้เลื่อนเมาส์ลงไปข้างล่างแล้วมองไม่เห็น

แก้ไขผ่านหน้า xfce-display-settings ก็ไม่ได้ (คงเป็น bug อยู่)
ลอง reload หลายอย่างเช่น
xfce-panel
compiz (ผมใช้ compiz แทน default)
ก็ไม่ได้ผล

จนลงเอยด้วย arandr

เอามาแชร์เผื่อคนอื่นเจอปัญหาเดียวกันครับ

Friday, November 18, 2011

Drupal Debian Linux VirtualBox TroubleShooting Tips

Fix Virtual Network Interface Card to eth0
===========================================
When we move the image to various hosts,
1) the interface name will keep running to eth1, eth2, eth3 and so on
2) the ip address will not automatically obtained.
because inside /etc/network/interfaces
....
iface eth0 inet dhcp
...

For solution Go To network-interface-in-linux.html


HTTP request status Fails
==========================
http://drupal.org/node/588186

Network interface in Linux

How to reorder or rename logical interface names in Linux
===========================================================
$ sudo apt-get install ifrename
$ cat /etc/iftab
eth0 mac E0:*

Other ways are detailed at http://www.science.uva.nl/research/air/wiki/LogicalInterfaceNames


It's quite useful in case of install Linux on a virtual machine.

When we move the image to various hosts,
1) the interface name will keep running to eth1, eth2, eth3 and so on
2) the ip address will not automatically obtained.
because inside /etc/network/interfaces
....
iface eth0 inet dhcp
...


New method
=========
use the udev-sanctioned method of statically-naming each interface.
Create the following file to bind the MAC address of each of your cards to a certain interface name:
/etc/udev/rules.d/10-network.rules
SUBSYSTEM=="net" KERNEL=="eth*", ATTR{address}=="00:12:34:fe:dc:ba", NAME="eth0"

note:
  • To get the MAC address of each card, use this command: cat /sys/class/net/device-name/address
  • When syntax errors, look at /etc/udev/rules.d/70-persistent-net.rules
  • Make sure to use the lower-case hex values in your udev rules. It doesn't like upper-case.

  • When choosing the static names it should be avoided to use "ethX" and "wlanX", because this may lead to race conditions between the kernel and udev during boot. Instead, it is better to use interface names that are not used by the kernel as default, e.g. "net0, net1, wifi0, wifi1".


Ref:
http://www.debianhelp.co.uk/udev.htm
https://wiki.archlinux.org/index.php/Udev#Network_device

equivalent Microsoft Project Linux

I'm looking for a free of the equivalent of Microsoft Project on linux.

ganttproject meet my need.



ganttproject
============
http://ganttproject.biz/
java-based


OpenProj
========
http://openproj.org
Licence terms: CPAL

openproj_1.4-2.deb 2008-10-02
http://sourceforge.net/projects/openproj/files/OpenProj%20Binaries/1.4/


Pleno
=====
- URL: http://sourceforge.net/projects/pleno/
- Licence terms: GPL


Projectivity
============
- URL: http://www.projectivity.biz
- Licence terms: GPL


Todoyu
======
- URL: http://todoyu.sourceforge.net
- Licence terms: BSD
Require Apache, PHP, MySQL


Project HQ
==========
- URL: http://projecthq.org/
- Licence terms: GPL



Taskjuggler
===========
Modern and powerful open source project management tool.
www.taskjuggler.org
Free
written in Ruby
sudo apt-get install rubygems
gem install taskjuggler


Planner
=======
The GNOME project management tool
sudo apt-get install planner



Koffice KPlato
===============



Web-based
=========
Feng Office Web Office focused on productivity, collaboration, communication and management
eGroupWare Enterprise ready web-based groupware suite with project management
dotProject Web-based, multi-user, multi-language project management application
Redmine Flexible application written using the Ruby on Rails framework

Monday, November 14, 2011

postgres createdb invalid locale name debian

$ sudo -u postgres createdb -l th_TH.UTF-8 -E UTF-8 -T template0 mydb;
createdb: database creation failed: ERROR:  invalid locale name th_TH.UTF-8

$ locale -a
C
en_US.utf8
POSIX

$ sudo apt-get install locales

$ sudo dpkg-reconfigure locales
# in debian this command will display a screen while ubuntu not!!

$ sudo init 6

$ locale -a
C
en_US.utf8
POSIX
th_TH.utf8



Useful cmd
=======
$ sudo locale-gen th_TH.UTF-8
$ sudo locale-gen --purge en_US.UTF-8 th_TH.utf8


$ sudo apt-get install locales-all

Saturday, October 29, 2011

CSS แปลง anchor text ให้เป็นปุ่ม

  < style >
    a.button-like{
      background: #0000ff;
      border: 1px solid #FFFFFF;
      border-radius: 4px 4px 4px 4px;
      color: #FFFFFF;
      cursor: pointer;
      font-family: Tahoma,Verdana,Arial,Helvetica,sans-serif;
      font-size: 100%;
      font-weight: bold;
      margin: 0 4px;
      outline: 1px solid #9BABB0;
      text-transform: uppercase;
      text-decoration: none; /* to remove the underline */
      padding: 2px 4px;
    }
  < /style >

< a class="button-like" href="..." > text </a>

get absolute path in drupal modules

The following codes is in /var/www/drupal-6.22/sites/all/modules/mymodule/mymodule.module

  echo dirname(__FILE__)
  = /var/www/drupal-6.22/sites/all/modules/mymodule

  echo realpath(".");
  = /var/www/drupal-6.22

  echo realpath(drupal_get_path('module', 'mymodule'));
  = /var/www/drupal-6.22/sites/all/modules/mymodule

  echo $_SERVER['DOCUMENT_ROOT'] . base_path();
  = /var/www//drupal-6.22/

  global $base_url;
  echo $base_url;
  = http://bmms:8080/drupal-6.22

  echo base_path(); // drupal function
  = /drupal-6.22/

  $path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'filename.ext';
  $data = file( $path );
  foreach($data as $value) {
    $output .= "$value";
  }


http://php.net/manual/en/language.constants.predefined.php
http://php.net/manual/en/function.dirname.php
http://php.net/manual/en/function.realpath.php

Friday, October 28, 2011

attach files to drupal contemplate pages


[tag] embed height="310" width="720" type="image/svg+xml" src=< ? php print file_create_url( images/image1.svg ); ? > [tag]

Database Tools and Utilities

MySQL Workbench is a unified visual tool for database architects, developers, and DBAs.
MySQL Workbench provides data modeling, SQL development, and comprehensive administration tools for
server configuration, user administration, and much more.
MySQL Workbench is available on Windows, Linux and Mac OS.
http://www.mysql.com/products/workbench/

Database Reverse Engineering
http://schemaspy.sourceforge.net/

Monday, October 24, 2011

XML HTML Editor IDE for Linux

Name Version Free WYSIWYG Code Support inline script (PHP) Auto Complete Highlight Match Bracket Folding Tag Toggle Comment Note
KompoZer 0.8b3
20081229
Y +Prop. Dialog Box
+ HTML Form
BP: Y
RC: fill later
Y N N N N my note is here
Seamonkey
Composer
2.4.1 Y + Prop. Dialog Box
(No HTML Form)
BP: Y

N N N

less features than Komposer
BlueGriffon 1.2.1 Y + Prop. Dialog Box
+ HTML5
+ SVG
BP: Y N HTML N N
Because Gecko lives inside, the
document will look exactly the same in Firefox.
Amaya 11.3.1
May 11 2011
Y + HTML5
+ SVG
BP:Y




my note is here
Aptana 3.0.5
20111006
Y N BP: Y
RC: Y
Y Excellent
PHP+HTML
Y Y
+ outline
Excellent Eclipse Base
Eclipse
PHP
Helios
20100617-1415
Y N


Y Y
+ outline


Eclipse
HTML Editor










Netbean 7.0.1 Y N Poor
more info
Y Y
+ help
Y Y
+ outline


Intellij IDEA
Community Edition
10.5 Y N Customizable Y HTML Y Y

serna free
Y Y






Serna enterprise XML
N Y






Emacs 23

nXhtml nXhtml




Bluefish 2.0.3 Y N external
tools
Y HTML
PHP (pop up)
Y Y Y
Geany 0.2
Jun 23 2011
Y N external tools Y HTML
PHP (fix)
no build-in Y Y more
info
gedit 2.30.4 Y N external
tools
simple text editor no build-in no build-in no build-in no build-in
sublime 2 No but no enforced time limit for the evaluation





SciTE 2.25
Apr 14 2011



Partial no build-in no build-in HTML
Lightweight GTK-based
Programming Editor
kate 3.6.5

?




KDE app
OpenBEXI
Y Y






Arachnophilia 5.5 Y N RC: Y but not quite good




Java App.
Quanta Plus
Y






KDE App.
Quanta Gold
N







Komodo Edit 6 Y
No Build-in





Komodo IDE
N
Y





phpstorm
N






30-day trial
jedit 4.4 Y N Y (UTF8?)
more info





java app
medit 1.0.3 Y N No Build-in





gphpedit






bug

UniversalIndentGUI









EditiX
N






Evaluation : 30 days
oXygen
N






Evaluation : 30 days
Screem








Dead Project


Code
BP = Beauty Print : the code output when use ide to create html element
RC = Reformat Code : existing code including Javascript/PHP/JSP snippet.

Some External tools for tidy/beautify/reformat html code are
http://tidy.sourceforge.net (my note
on tidy here)
http://phptidy.berlios.de/

More info at
http://en.wikipedia.org/wiki/Comparison_of_HTML_editors
http://www.linuxdocs.org/HOWTOs/PHP-HOWTO-9.html
http://drupal.org/node/147789

Or Edit online at
http://lifehacker.biz/articles/web-developers-package-code-beautifier-and-formatter/


Conclusion
=======
I choice KompoZer as my primary WYSIWYG for HTML
,1) Bluefish 2) Aptana as PHP text editor (b/c of its help when autocomplete)
,Geany for small change in code and other xml files
,Inkscape when draft SVG
serna ??


Eclipse PHP Development Tools

Intellij IDEA

NetBeans

NetBeans Result

Amaya Tips

Amaya reads HTML documents by default as ISO-Latin-1 files.
If an author does not provide information about the character set (charset) in the HTTP header
or in a meta element, Amaya considers an HTML document to be encoded in ISO-Latin-1.

KompoZer Tips

KompoZer is a GTK application, it has nothing to do with KDE.

sudo apt-get install kompozer

with BOM : it show Thai properly, but after save Thai parts in the file become "+!2"@% ".
Fix by "Save and Change Charactor Encoding"

tidy reformat beautify html xml emacs

sudo apt-get install emacs

nxhtml-mode
==========
nxhtml-mode is derived from nxml-mode (NxmlMode).
It adds a lot of things useful for XHTML.
Among other things it adds some way of handling multiple modes, folding, an improved interface to Tidy etc.
http://www.emacswiki.org/emacs/NxmlModeForXHTML
http://ourcomments.org/Emacs/nXhtml/doc/nxhtml-changes.html


Installation instruction
=================
http://www.emacswiki.org/emacs/download/tidy.el


tidy html
=======
Go to nXhtml -> tools -> Tidy XHTML -> Tidy Buffer


Tips
====
To Compile nxhtml.el goto
Menu nXhtml -> nXhtml help and Setup -> Byte compile nXhtml


Note
====
work well with inline php b/c no bug of 'always shift/indent php code'
(3rd of execution lead 6 spaces indent,4th lead 8 ,5th lead 10 ....)

More info
=======
HTML Editing With Emacs

http://stackoverflow.com/questions/137043/can-emacs-re-indent-a-big-blob-of-html-for-me


tidy reformat beautify html xml gedit


Using tidy.sourceforge.net
==========================
sudo apt-get install tidy
sudo apt-get install gedit-plugins

Under Plugins Tab:
Enable External tools

(My note on tidy is here)



Using PHP_Beautifier
======================
http://pear.php.net/package/PHP_Beautifier
This tool will not be able to beautify inline html and php together.

sudo apt-get install php-pear
# Still in Beta state

sudo pear install PHP_Beautifier
sudo pear install PHP_Beautifier-0.1.15.tgz

php_beautifier -s4 -l "ArrayNested() IndentStyles(style=bsd) NewLines(before=if:switch:while:for:foreach:function:T_CLASS:return:break,after=T_COMMENT)"


Full instruction at http://www.masnun.me/2010/04/10/using-gedit-as-a-php-ide.html


Plug-in
=====
http://yuix.org/web-development/ubuntu-11-10-oneiric-ocelot-gedit-indent-lines-plugin/184



More info
==========
gedit-3 : http://live.gnome.org/Gedit/Plugins#third_party
gedit-2 : http://live.gnome.org/Gedit/PluginsOld

http://www.micahcarrick.com/gedit-html-editor.html

Tidy/reformat/beautify html in Bluefish

Setting
========
Menu Edit -> Preference(s) -> External filters -> Tiny HTML
Change Command from 'tiny' to 'tiny -i'
(My note on tiny is here)


Reformat Code
=============
Tools -> Filters -> Tiny HTML

tidy/reformat/beautify html/xml in Geany

tidy.sourceforge.net
====================
Menu Edit -> Format -> Send Selection to ->
tidy -config /path/to/tidy.conf
(My tidy.conf is here)

phptidy.berlios.de
===================


Autocomplete
============
http://www.krutant.com/2011/05/geany-perfect-web-development-ide.html


Geany = ?
==========
Geany is a small and lightweight integrated development environment.
It was developed to provide a small and fast IDE, which has only a few dependencies from other packages.
It is using only the GTK2 toolkit and therefore you need only the GTK2 runtime libraries to run Geany.

The basic features of Geany are:
 - syntax highlighting
 - code completion
 - auto completion of constructs like if, for and while, XML and HTML
 - call tips
 - folding
 - many supported filetypes like C, Java, PHP, HTML, Python, Perl, Pascal
 - symbol lists
 - embedded terminal emulation

https://github.com/codebrainz/geany-zencoding


tidy/reformat/beautify/pretty-print html by tidy.sourceforge.net

HTML syntax checker and reformatter

Corrects markup in a way compliant with the latest standards, and optimal for the popular browsers.
It has a comprehensive knowledge of the attributes defined in the HTML 4.0 recommendation from W3C, and understands the US ASCII, ISO Latin-1, UTF-8 and the ISO 2022 family of 7-bit encodings.

In the output:
 * HTML entity names for characters are used when appropriate.
 * Missing attribute quotes are added, and mismatched quotes found.
 * Tags lacking a terminating '>' are spotted.
 * Proprietary elements are recognized and reported as such.
 * The page is reformatted, from a choice of indentation styles.


Installation
=======
sudo apt-get install tidy


tidy.conf
======
// tidy version 25 March 2009


//markup: yes
//break-before-br: no
indent: yes
//indent-attributes: no
// add indent-spaces to avoid bug
indent-spaces: 2
vertical-space: yes
wrap: 0
wrap-php: yes
//char-encoding: utf8
input-encoding: utf8
output-encoding: utf8
tidy-mark: no
// output-xhtml to avoid error of save same buffer many times
output-xhtml: yes
// w/o quiet: yes option, error might show
quiet: yes
doctype: strict



Useful options
================
-indent, -i
= indent element content

-utf8
= use UTF-8 for both input and output

-asxml, -asxhtml
= convert HTML to well formed XHTML (output-xhtml: yes)

-wrap , -w
= wrap text at the specified .
Set wrap to zero if you want to disable line wrapping.
0 is assumed if is missing.

--tidy-mark no
= if Tidy should add a meta element to the document head to indicate that the document has been tidied.
(Default: yes)



More info
==========
http://tidy.sourceforge.net
http://tidy.sourceforge.net/docs/quickref.html
man tidy
http://www.w3.org/People/Raggett/tidy/

Subproject:
http://us3.php.net/manual/en/intro.tidy.php

Wednesday, October 19, 2011

Firefox cannot load websites but other programs can

แก้ปัญหา firefox เข้าบางเว็บไม่ได้
========================
- ไปที่ location bar (ตรงที่พิมพ์ url เช่น facebook.com)
แล้วพิมพ์คำว่า "about:config" แล้ว Enter
- กด "I'll be careful, I promise!"
- ในช่อง Filter, พิมพ์ ipv6
- double-click ที่ network.dns.disableIPv6 ให้ค่าเป็น true
- restart firefox

ที่มา
http://guru.google.co.th/guru/thread?tid=22da0b65060ea250
support.mozilla.com/en-US/kb/Firefox cannot load websites but other programs can

Tuesday, October 18, 2011

Chrome Extensions

Read Later Fast

Save as PDF



http://www.it24hrs.com/2011/10-tips-use-chrome-for-student/


chrome://extensions/

Saturday, October 15, 2011

Zoneminder Troubleshooting Guide

Is the card working properly?
======================
Try out these commands:
$ dmesg | grep bttv
....

$ sudo tail -f /var/log/syslog
.....

$ ls -ls /dev/video*
0 crw-rw-rw-+ 1 root video 81, 0 Oct 15 22:46 /dev/video0
0 crw-rw-rw-+ 1 root video 81, 2 Oct 15 22:46 /dev/video1
0 crw-rw-rw-+ 1 root video 81, 4 Oct 15 22:46 /dev/video2
0 crw-rw-rw-+ 1 root video 81, 6 Oct 15 22:46 /dev/video3

$ v4l-info /dev/video0
.....

$ ffmpeg -f video4linux2 -s 320x240 -r 30000/1001 -i /dev/video0 -y webcam.avi


Other useful commands
=================
$ sudo /etc/init.d/apache2 force-reload
$ sudo service zoneminder restart



Got unexpected memory map file size
===========================
$ sudo tail -f /var/log/syslog
....
Oct 14 17:17:52 penguin zmc_dvideo0[9153]: ERR [Got unexpected memory map file size 10801524, expected 12166644]
....

Solution
======
Open the file “/etc/sysctl.conf”, and paste these lines at the bottom of the file, then reboot.
kernel.shmall = 167772160
kernel.shmmax = 167772160

Ref: http://www.zoneminder.com/wiki/index.php/Debian_Squeeze#Inadequate_Memory_Allocation




Failed to set video format: Invalid argument
================================
$ sudo tail -f /var/log/syslog
.....
Oct 14 17:18:11 penguin zmc_dvideo1[9158]: FAT [Failed to set video format: Invalid argument]
.....

Solution
======
Change Configuration in Monitor -> Source
Device Format, Capture Palette, Capture Width, and Capture Hight
to be compatible with your camera


DVR Geovision GV-800 Zoneminder Linux

GV-800
Hardware version 3.5
16 ch video and 4 ch audio,120/100fps


Specification
==========
$ lspci -n
...
04:00.0 0400: 109e:036e (rev 11)
04:00.1 0480: 109e:0878 (rev 11)
04:04.0 0400: 109e:036e (rev 11)
04:04.1 0480: 109e:0878 (rev 11)
04:08.0 0400: 109e:036e (rev 11)
04:08.1 0480: 109e:0878 (rev 11)
04:0c.0 0400: 109e:036e (rev 11)
04:0c.1 0480: 109e:0878 (rev 11)
...

$ lspci -k
04:00.0 Multimedia video controller: Brooktree Corporation Bt878 Video Capture (rev 11)
    Subsystem: Device 800a:763d
    Kernel driver in use: bttv
04:00.1 Multimedia controller: Brooktree Corporation Bt878 Audio Capture (rev 11)
    Subsystem: Device 800a:763d
04:04.0 Multimedia video controller: Brooktree Corporation Bt878 Video Capture (rev 11)
    Subsystem: Device 800b:763d
    Kernel driver in use: bttv
04:04.1 Multimedia controller: Brooktree Corporation Bt878 Audio Capture (rev 11)
    Subsystem: Device 800b:763d
04:08.0 Multimedia video controller: Brooktree Corporation Bt878 Video Capture (rev 11)
    Subsystem: Device 800c:763d
    Kernel driver in use: bttv
04:08.1 Multimedia controller: Brooktree Corporation Bt878 Audio Capture (rev 11)
    Subsystem: Device 800c:763d
04:0c.0 Multimedia video controller: Brooktree Corporation Bt878 Video Capture (rev 11)
    Subsystem: Device 800d:763d
    Kernel driver in use: bttv
04:0c.1 Multimedia controller: Brooktree Corporation Bt878 Audio Capture (rev 11)
    Subsystem: Device 800d:763d

$ ls -ls /dev/video*
0 crw-rw----+ 1 root video 81, 0 Oct 14 06:41 /dev/video0
0 crw-rw----+ 1 root video 81, 2 Oct 14 06:41 /dev/video1
0 crw-rw----+ 1 root video 81, 4 Oct 14 06:41 /dev/video2
0 crw-rw----+ 1 root video 81, 6 Oct 14 06:41 /dev/video3

$ uname -r
3.0.0-1-amd64


Installation
============
only http://www.zoneminder.com/wiki/index.php/Debian_Squeeze
then http://www.zoneminder.com/wiki/index.php/Ubuntu_9.04_%28Jaunty%29_desktop_with_graphical_interface
For adding cameras
*NOT require /etc/modprob.d/bttv.conf configuration

Camera 1 -> /dev/video0 channel 0
Camera 2 -> /dev/video1 channel 0
Camera 3 -> /dev/video2 channel 0
Camera 4 -> /dev/video3 channel 0

Camera 5 -> /dev/video0 channel 1
Camera 6 -> /dev/video1 channel 1
Camera 7 -> /dev/video2 channel 1
Camera 8 -> /dev/video3 channel 1

Camera 9 -> /dev/video0 channel 2
Camera 10 -> /dev/video1 channel 2
Camera 11 -> /dev/video2 channel 2
Camera 12 -> /dev/video3 channel 2

Camera 13 -> /dev/video0 channel 3
Camera 14 -> /dev/video1 channel 3
Camera 15 -> /dev/video2 channel 3
Camera 16 -> /dev/video3 channel 3


Useful Commands
===============
$ v4l-info /dev/video0
$ sudo /etc/init.d/apache2 force-reload
$ sudo service zoneminder restart
$ dmesg | grep bttv
$ sudo tail -f /var/log/syslog
$ ffmpeg -f video4linux2 -s 320x240 -r 30000/1001 -i /dev/video0 -y webcam.avi



Output in dmesg
============
$ dmesg | grep bttv
[    5.805510] bttv: driver version 0.9.18 loaded
[    5.805512] bttv: using 8 buffers with 2080k (520 pages) each for capture
[    5.805720] bttv: Bt8xx card found (0).
[    5.805740] bttv 0000:04:00.0: PCI INT A -> GSI 21 (level, low) -> IRQ 21
[    5.805750] bttv0: Bt878 (rev 17) at 0000:04:00.0, irq: 21, latency: 64, mmio: 0xfdeff000
[    5.805770] bttv0: detected: GeoVision GV-800(S) (master) [card=157], PCI subsystem ID is 800a:763d
[    5.805772] bttv0: using: Geovision GV-800(S) (master) [card=157,autodetected]
[    5.805807] bttv0: gpio: en=00000000, out=00000000 in=00ff28ff [init]
[    5.806572] bttv0: tuner absent
[    5.806604] bttv0: registered device video0
[    5.806624] bttv0: registered device vbi0
[    5.806650] bttv0: PLL: 28636363 => 35468950 .. ok
[    5.839533] bttv: Bt8xx card found (1).
[    5.839544] bttv 0000:04:04.0: PCI INT A -> GSI 21 (level, low) -> IRQ 21
[    5.839552] bttv1: Bt878 (rev 17) at 0000:04:04.0, irq: 21, latency: 64, mmio: 0xfdefd000
[    5.839573] bttv1: detected: GeoVision GV-800(S) (slave) [card=158], PCI subsystem ID is 800b:763d
[    5.839575] bttv1: using: Geovision GV-800(S) (slave) [card=158,autodetected]
[    5.839602] bttv1: gpio: en=00000000, out=00000000 in=00ff7cff [init]
[    5.839639] bttv1: tuner absent
[    5.839667] bttv1: registered device video1
[    5.839690] bttv1: registered device vbi1
[    5.839717] bttv1: PLL: 28636363 => 35468950 .. ok
[    5.871530] bttv: Bt8xx card found (2).
[    5.871540] bttv 0000:04:08.0: PCI INT A -> GSI 21 (level, low) -> IRQ 21
[    5.871548] bttv2: Bt878 (rev 17) at 0000:04:08.0, irq: 21, latency: 64, mmio: 0xfdefb000
[    5.871568] bttv2: detected: GeoVision GV-800(S) (slave) [card=158], PCI subsystem ID is 800c:763d
[    5.871570] bttv2: using: Geovision GV-800(S) (slave) [card=158,autodetected]
[    5.871596] bttv2: gpio: en=00000000, out=00000000 in=00ffbeff [init]
[    5.871632] bttv2: tuner absent
[    5.871659] bttv2: registered device video2
[    5.871682] bttv2: registered device vbi2
[    5.871708] bttv2: PLL: 28636363 => 35468950 .. ok
[    5.903525] bttv: Bt8xx card found (3).
[    5.903534] bttv 0000:04:0c.0: PCI INT A -> GSI 21 (level, low) -> IRQ 21
[    5.903542] bttv3: Bt878 (rev 17) at 0000:04:0c.0, irq: 21, latency: 64, mmio: 0xfdef9000
[    5.903557] bttv3: detected: GeoVision GV-800(S) (slave) [card=158], PCI subsystem ID is 800d:763d
[    5.903559] bttv3: using: Geovision GV-800(S) (slave) [card=158,autodetected]
[    5.903584] bttv3: gpio: en=00000000, out=00000000 in=00fffcff [init]
[    5.903621] bttv3: tuner absent
[    5.903650] bttv3: registered device video3
[    5.903671] bttv3: registered device vbi3
[    5.903697] bttv3: PLL: 28636363 => 35468950 .. ok

DVR Techwell 6805a




$ uname -r
3.0.0-1-amd64


$ lspci -n
....
02:00.0 0c03: 1033:0194 (rev 03)
03:06.0 0400: 1797:6804 (rev 10)
03:06.1 0480: 1797:6805 (rev 10)
04:00.0 0101: 197b:2368
.....


$ lspci -k
.....
02:00.0 USB Controller: NEC Corporation uPD720200 USB 3.0 Host Controller (rev 03)
    Subsystem: Micro-Star International Co., Ltd. Device 7599
    Kernel driver in use: xhci_hcd
03:06.0 Multimedia video controller: Techwell Inc. Device 6804 (rev 10)
03:06.1 Multimedia controller: Techwell Inc. Device 6805 (rev 10)
04:00.0 IDE interface: JMicron Technology Corp. JMB368 IDE controller
    Subsystem: Micro-Star International Co., Ltd. Device 7599
    Kernel driver in use: pata_jmicron
....


$ ls -ls /dev/video*
ls: cannot access /dev/video*: No such file or directory


DVR Card 104C-E zoneminder

work with Zoneminder + linux
follow instruction on
http://www.zoneminder.com/wiki/index.php/Debian_Squeeze
(include instruction on other issues)

no need to create or edit /etc/modprobe.d/bttv.conf
Camera 1 -> /dev/video0 channel 0
Camera 2 -> /dev/video0 channel 1
Camera 3 -> /dev/video0 channel 2
Camera 4 -> /dev/video0 channel 3


$ uname -r
3.0.0-1-amd64

Card Specification
============
http://www.tungson.cn/en/product_info.asp?InfoID=163



$ lspci -k
03:06.0 Multimedia video controller: Conexant Systems, Inc. CX23880/1/2/3 PCI Video and Audio Decoder (rev 05)
    Subsystem: Device c180:c980
    Kernel driver in use: cx8800
03:06.1 Multimedia controller: Conexant Systems, Inc. CX23880/1/2/3 PCI Video and Audio Decoder [Audio Port] (rev 05)
    Subsystem: Device c180:c980
    Kernel driver in use: cx88_audio


$ ls -ls /dev/video*
0 crw-rw-rw-+ 1 root video 81, 0 Oct 15 11:23 /dev/video0


$ v4l-info /dev/video0

### v4l2 device info [/dev/video0] ###
general info
    VIDIOC_QUERYCAP
    driver                  : "cx8800"
    card                    : "Shenzhen Tungsten Ages Tech TE-"
    bus_info                : "PCI:0000:03:06.0"
    version                 : 0.0.8
    capabilities            : 0x5010011 [VIDEO_CAPTURE,VBI_CAPTURE,TUNER,READWRITE,STREAMING]

standards
    VIDIOC_ENUMSTD(0)
    index                   : 0
    id                      : 0x1000 [NTSC_M]
    name                    : "NTSC-M"
    frameperiod.numerator   : 1001
    frameperiod.denominator : 30000
    framelines              : 525
    VIDIOC_ENUMSTD(1)
    index                   : 1
    id                      : 0x2000 [NTSC_M_JP]
    name                    : "NTSC-M-JP"
    frameperiod.numerator   : 1001
    frameperiod.denominator : 30000
    framelines              : 525
    VIDIOC_ENUMSTD(2)
    index                   : 2
    id                      : 0x4000 [?]
    name                    : "NTSC-443"
    frameperiod.numerator   : 1001
    frameperiod.denominator : 30000
    framelines              : 525
    VIDIOC_ENUMSTD(3)
    index                   : 3
    id                      : 0x7 [PAL_B,PAL_B1,PAL_G]
    name                    : "PAL-BG"
    frameperiod.numerator   : 1
    frameperiod.denominator : 25
    framelines              : 625
    VIDIOC_ENUMSTD(4)
    index                   : 4
    id                      : 0x10 [PAL_I]
    name                    : "PAL-I"
    frameperiod.numerator   : 1
    frameperiod.denominator : 25
    framelines              : 625
    VIDIOC_ENUMSTD(5)
    index                   : 5
    id                      : 0xe0 [PAL_D,PAL_D1,PAL_K]
    name                    : "PAL-DK"
    frameperiod.numerator   : 1
    frameperiod.denominator : 25
    framelines              : 625
    VIDIOC_ENUMSTD(6)
    index                   : 6
    id                      : 0x100 [PAL_M]
    name                    : "PAL-M"
    frameperiod.numerator   : 1001
    frameperiod.denominator : 30000
    framelines              : 525
    VIDIOC_ENUMSTD(7)
    index                   : 7
    id                      : 0x200 [PAL_N]
    name                    : "PAL-N"
    frameperiod.numerator   : 1
    frameperiod.denominator : 25
    framelines              : 625
    VIDIOC_ENUMSTD(8)
    index                   : 8
    id                      : 0x400 [PAL_Nc]
    name                    : "PAL-Nc"
    frameperiod.numerator   : 1
    frameperiod.denominator : 25
    framelines              : 625
    VIDIOC_ENUMSTD(9)
    index                   : 9
    id                      : 0x800 [PAL_60]
    name                    : "PAL-60"
    frameperiod.numerator   : 1001
    frameperiod.denominator : 30000
    framelines              : 525
    VIDIOC_ENUMSTD(10)
    index                   : 10
    id                      : 0x10000 [SECAM_B]
    name                    : "SECAM-B"
    frameperiod.numerator   : 1
    frameperiod.denominator : 25
    framelines              : 625
    VIDIOC_ENUMSTD(11)
    index                   : 11
    id                      : 0x40000 [SECAM_G]
    name                    : "SECAM-G"
    frameperiod.numerator   : 1
    frameperiod.denominator : 25
    framelines              : 625
    VIDIOC_ENUMSTD(12)
    index                   : 12
    id                      : 0x80000 [SECAM_H]
    name                    : "SECAM-H"
    frameperiod.numerator   : 1
    frameperiod.denominator : 25
    framelines              : 625
    VIDIOC_ENUMSTD(13)
    index                   : 13
    id                      : 0x320000 [SECAM_D,SECAM_K,SECAM_K1]
    name                    : "SECAM-DK"
    frameperiod.numerator   : 1
    frameperiod.denominator : 25
    framelines              : 625
    VIDIOC_ENUMSTD(14)
    index                   : 14
    id                      : 0x400000 [SECAM_L]
    name                    : "SECAM-L"
    frameperiod.numerator   : 1
    frameperiod.denominator : 25
    framelines              : 625

inputs
    VIDIOC_ENUMINPUT(0)
    index                   : 0
    name                    : "Television"
    type                    : TUNER
    audioset                : 0
    tuner                   : 0
    std                     : 0x7f7ff7 [PAL_B,PAL_B1,PAL_G,PAL_I,PAL_D,PAL_D1,PAL_K,PAL_M,PAL_N,PAL_Nc,PAL_60,NTSC_M,NTSC_M_JP,?,SECAM_B,SECAM_D,SECAM_G,SECAM_H,SECAM_K,SECAM_K1,SECAM_L]
    status                  : 0x0 []
    VIDIOC_ENUMINPUT(1)
    index                   : 1
    name                    : "Composite1"
    type                    : CAMERA
    audioset                : 0
    tuner                   : 0
    std                     : 0x0 []
    status                  : 0x0 []
    VIDIOC_ENUMINPUT(2)
    index                   : 2
    name                    : "S-Video"
    type                    : CAMERA
    audioset                : 0
    tuner                   : 0
    std                     : 0x0 []
    status                  : 0x0 []

tuners
    VIDIOC_G_TUNER(0)
    index                   : 0
    name                    : "Television"
    type                    : ANALOG_TV
    capability              : 0x70 [STEREO,LANG2,LANG1]
    rangelow                : 0
    rangehigh               : 4294967295
    rxsubchans              : 0x1 [MONO]
    audmode                 : MONO
    signal                  : 65535
    afc                     : 0

video capture
    VIDIOC_ENUM_FMT(0,VIDEO_CAPTURE)
    index                   : 0
    type                    : VIDEO_CAPTURE
    flags                   : 0
    description             : "8 bpp, gray"
    pixelformat             : 0x59455247 [GREY]
    VIDIOC_ENUM_FMT(1,VIDEO_CAPTURE)
    index                   : 1
    type                    : VIDEO_CAPTURE
    flags                   : 0
    description             : "15 bpp RGB, le"
    pixelformat             : 0x4f424752 [RGBO]
    VIDIOC_ENUM_FMT(2,VIDEO_CAPTURE)
    index                   : 2
    type                    : VIDEO_CAPTURE
    flags                   : 0
    description             : "15 bpp RGB, be"
    pixelformat             : 0x51424752 [RGBQ]
    VIDIOC_ENUM_FMT(3,VIDEO_CAPTURE)
    index                   : 3
    type                    : VIDEO_CAPTURE
    flags                   : 0
    description             : "16 bpp RGB, le"
    pixelformat             : 0x50424752 [RGBP]
    VIDIOC_ENUM_FMT(4,VIDEO_CAPTURE)
    index                   : 4
    type                    : VIDEO_CAPTURE
    flags                   : 0
    description             : "16 bpp RGB, be"
    pixelformat             : 0x52424752 [RGBR]
    VIDIOC_ENUM_FMT(5,VIDEO_CAPTURE)
    index                   : 5
    type                    : VIDEO_CAPTURE
    flags                   : 0
    description             : "24 bpp RGB, le"
    pixelformat             : 0x33524742 [BGR3]
    VIDIOC_ENUM_FMT(6,VIDEO_CAPTURE)
    index                   : 6
    type                    : VIDEO_CAPTURE
    flags                   : 0
    description             : "32 bpp RGB, le"
    pixelformat             : 0x34524742 [BGR4]
    VIDIOC_ENUM_FMT(7,VIDEO_CAPTURE)
    index                   : 7
    type                    : VIDEO_CAPTURE
    flags                   : 0
    description             : "32 bpp RGB, be"
    pixelformat             : 0x34424752 [RGB4]
    VIDIOC_ENUM_FMT(8,VIDEO_CAPTURE)
    index                   : 8
    type                    : VIDEO_CAPTURE
    flags                   : 0
    description             : "4:2:2, packed, YUYV"
    pixelformat             : 0x56595559 [YUYV]
    VIDIOC_ENUM_FMT(9,VIDEO_CAPTURE)
    index                   : 9
    type                    : VIDEO_CAPTURE
    flags                   : 0
    description             : "4:2:2, packed, UYVY"
    pixelformat             : 0x59565955 [UYVY]
    VIDIOC_G_FMT(VIDEO_CAPTURE)
    type                    : VIDEO_CAPTURE
    fmt.pix.width           : 320
    fmt.pix.height          : 240
    fmt.pix.pixelformat     : 0x33524742 [BGR3]
    fmt.pix.field           : INTERLACED
    fmt.pix.bytesperline    : 960
    fmt.pix.sizeimage       : 230400
    fmt.pix.colorspace      : unknown
    fmt.pix.priv            : 0

vbi capture
    VIDIOC_G_FMT(VBI_CAPTURE)
    type                    : VBI_CAPTURE
    fmt.vbi.sampling_rate   : 35468950
    fmt.vbi.offset          : 244
    fmt.vbi.samples_per_line: 2048
    fmt.vbi.sample_format   : 0x59455247 [GREY]
    fmt.vbi.start[0]        : 6
    fmt.vbi.start[1]        : 318
    fmt.vbi.count[0]        : 17
    fmt.vbi.count[1]        : 17
    fmt.vbi.flags           : 0

controls
    VIDIOC_QUERYCTRL(BASE+0)
    id                      : 9963776
    type                    : INTEGER
    name                    : "Brightness"
    minimum                 : 0
    maximum                 : 255
    step                    : 1
    default_value           : 127
    flags                   : 0
    VIDIOC_QUERYCTRL(BASE+1)
    id                      : 9963777
    type                    : INTEGER
    name                    : "Contrast"
    minimum                 : 0
    maximum                 : 255
    step                    : 1
    default_value           : 63
    flags                   : 0
    VIDIOC_QUERYCTRL(BASE+2)
    id                      : 9963778
    type                    : INTEGER
    name                    : "Saturation"
    minimum                 : 0
    maximum                 : 255
    step                    : 1
    default_value           : 127
    flags                   : 0
    VIDIOC_QUERYCTRL(BASE+3)
    id                      : 9963779
    type                    : INTEGER
    name                    : "Hue"
    minimum                 : 0
    maximum                 : 255
    step                    : 1
    default_value           : 127
    flags                   : 0



Useful Commands
============
sudo service zoneminder restart
sudo /etc/init.d/apache2 force-reload
sudo /etc/init.d/udev restart
dmesg
sudo tail -f /var/log/syslog
ffmpeg -f video4linux2 -s 352x288 -r 30000/1001 -i /dev/video0 -y webcam.avi

sudo apt-get install xawtv
xawtv -nodga -device /dev/video3
xawtv -c /dev/video0

Adding Cameras:
go to http://www.zoneminder.com/wiki/index.php/Ubuntu_9.04_%28Jaunty%29_desktop_with_graphical_interface