Friday, 30 January 2009

HOWTO: disable horizontal scroll bar using CSS




if you put this in <head> it will disable horizontal scrollbars

Thursday, 29 January 2009

#_, in mysql query, in Joomla

the database prefix can be entered in the form '#_' (hash-underscore),
in which case it will automatically be replaced by the database prefix
used by Joomla.


Wednesday, 28 January 2009

(), round brackets, in Mysql

(T1, ...) RIGHT JOIN (T2,...) ON P(T1,...,T2,...) =
(T2, ...) LEFT JOIN (T1,...) ON P(T1,...,T2,...)


mysql> SELECT cds.artist, cds.title, genres.genre
-> FROM cds, genres
-> WHERE (cds.genreID = genres.genreID);

{}, curly braces, in Php, not mysql

Variable parsing

When a string is specified in double quotes or with heredoc,
variables are parsed within it.

There are two types of syntax: a
simple one and a
complex one.
The simple syntax is the most common and convenient. It provides a way to
embed a variable, an array value, or an object
property in a string with a minimum of effort.

The complex syntax was introduced in PHP 4, and can be recognised by the
curly braces surrounding the expression.

Simple syntax

If a dollar sign ($) is encountered, the parser will
greedily take as many tokens as possible to form a valid variable name.
Enclose the variable name in curly braces to explicitly specify the end of
the name.

"$beer's taste is great"// works; "'" is an invalid character for variable names
echo "He drank some $beers";   // won't work; 's' is a valid character for variable names but the variable is "$beer"
echo "He drank some ${beer}s"// works
echo "He drank some {$beer}s"// works

Similarly, an array index or an object property
can be parsed. With array indices, the closing square bracket
(]) marks the end of the index. The same rules apply to
object properties as to simple variables.

// These examples are specific to using arrays inside of strings.
// When outside of a string, always quote array string keys and do not use
// {braces}.

// Show all errors

$fruits = array('strawberry' => 'red''banana' => 'yellow');

// Works, but note that this works differently outside a string
echo "A banana is $fruits[banana].";

// Works
echo "A banana is {$fruits['banana']}.";

// Works, but PHP looks for a constant named banana first, as described below.
echo "A banana is {$fruits[banana]}.";

// Won't work, use braces.  This results in a parse error.
echo "A banana is $fruits['banana'].";

// Works
echo "A banana is " $fruits['banana'] . ".";

// Works
echo "This square is $square->width meters broad.";

// Won't work. For a solution, see the complex syntax.
echo "This square is $square->width00 centimeters broad.";

For anything more complex, you should use the complex syntax.

->, Objects and references, in Php

A PHP reference is an alias, which allows two different variables to write
to the same value. As of PHP5, an object variable doesn't contain the object
itself as value anymore. It only contains a object identifier which allows
object accessors to find the actual object. When an object is sent by
argument, returned or assigned to another variable, the different variables
are not aliases: they hold a copy of the identifier, which points to the same

Example #1 References and Objects

class {
$foo 1;

$a = new A;
$b $a;     // $a and $b are copies of the same identifier
             // ($a) = ($b) = <id>
$b->foo 2;

$c = new A;
$d = &$c;    // $c and $d are references
             // ($c,$d) = <id>

$d->foo 2;

$e = new A;

foo($obj) {
// ($obj) = ($e) = <id>
$obj->foo 2;



The above example will output:

2<br />2<br />2<br />

=>, in Php

paring arry keys and values.

Example #1 Ejemplo de array()

= array (
"frutas"  => array("a"=>"naranja""b"=>"plátano""c"=>"manzana"),
"números" => array(123456),
"hoyos"   => array("primero"=> "segundo""tercero")

Example #2 Índice automático con array()

= array(1111,  1=> 1,  => 119=> 13);

El resultado del ejemplo seria:

Array<br />(<br />    [0] => 1<br />    [1] => 1<br />    [2] => 1<br />    [3] => 13<br />    [4] => 1<br />    [8] => 1<br />    [9] => 19<br />)<br />

::, Scope Resolution Operator, in Php

The Scope Resolution Operator (also called Paamayim Nekudotayim) or in
simpler terms, the double colon, is a token that allows access to
constant, and overridden
members or methods of a class.

When referencing these items from outside the class definition, use
the name of the class.

Example #1 :: from outside the class definition

class MyClass {
CONST_VALUE 'A constant value';

$classname 'MyClass';
$classname::CONST_VALUE// As of PHP 5.3.0

echo MyClass::CONST_VALUE;

And, Static properties cannot be accessed through the object using the arrow
operator ->.

%, as Wildcard Usage, in Mysql

For example '2%' would match the following: 20, 25, 2000000, 2avkldj3jklsaf, and 2!

$result = mysql_query("SELECT * FROM example WHERE age LIKE '2%' ")
or die(mysql_error());

&, ampersand, in php

in the following piece of code:

$a=10 ; //(1010b)
$b = 0; // (0000b)

if ($a & $b)

is different from

if ($a && $b)

The first one is true and the second if false.

we use only one & it means bit-by-bit and operation, so $a &
$b=10 (1010b), while when you use && it means and operator of
clauses and in this case $a && $b = 0, cause $b=0.

Beware of the signs. This FAQ is also valid for the or operator ('|').

how Virtuemart present the shop page

1) virtuemart.php:
if( file_exists( PAGEPATH.$modulename.".".$pagename.".php" )) {
include( PAGEPATH.$modulename.".".$pagename.".php" );
// this file is: administrator/components/com_virtuemart/html/shop.index.php

2) shop.index.php:
$tpl = new $GLOBALS['VM_THEMECLASS']();
$tpl->set( 'categories', $category_childs );
echo $tpl->fetch( 'common/shopIndex.tpl.php');
// to theme the output, the template file, components/com_virtuemart/themes/default/templates/common/shopIndex.tpl.php, is needed.

3) shopIndex.tpl.php:

you can remove the shop description/the word of 'categories',
or remove the featured prodcuts in codes, but this also can be done in admin-components-virtuemart-admin-configuration-site-layout-Select the theme for your Shop-default-configuration)

if( $this->get_cfg( 'showFeatured', 1 )) {
/* featuredproducts(random, no_of_products,category_based) no_of_products 0 = all else numeric amount
edit featuredproduct.tpl.php to edit layout */
echo $ps_product->featuredProducts(true,10,false);
// ./featuredproduct.tpl.php will determine the layout for featured products.

Monday, 26 January 2009

Jython and Matlab do jobs for java

Java codes:
import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class MyExample
implements ActionListener {

public void actionPerformed(ActionEvent e) {

public static void main(String[] args) {
JFrame frame = new JFrame("My Frame");
JButton button = new JButton("Push Me!");
ActionListener listener = new MyExample();

import javax.swing as swing

def printMessage(event):
print "Ouch!"

frame=swing.JFrame("my frame")
button=swing.JButton("Push Me!")
frame.setVisible(True) #frame.visible=1

import javax.*;

frame = swing.JFrame('my frame');
button = swing.JButton('Push Me!');



%code for sub function:
function printMessage(handle,event)

Tuesday, 20 January 2009

mysql user management

准备:更改root的密码 (mysql安装后,root是没有密码的)
@>mysqladmin -uroot password YOURNEWPASSWORD


@>mysql -u root -p
mysql> insert into mysql.user(Host,User,Password) values("localhost","cross",password("1234"));
mysql>flush privileges;
这样就创建了一个名为:cross 密码为:1234 的用户。


@>mysql -u cross -p


@>mysql -u root -p
mysql>create database joomla1;
>grant all privileges on joomla1.* to 'cross'@localhost identified by '1234';
mysql>flush privileges;

mysql>grant select,update on phplampDB.* to 'phplamp'@localhost identified by '1234';
mysql>flush privileges;

@>mysql -u root -p
mysql>DELETE FROM user WHERE User="phplamp" and Host="localhost";
mysql>flush privileges;
mysql>drop database phplampDB;

@>mysql -u root -p
mysql>update mysql.user set password=password('新密码') where User="phplamp" and Host="localhost";
mysql>flush privileges;

Tuesday, 13 January 2009

javascript: enter to execute



<script type="text/javascript">

    function getrefno(reno, helperMsg){

        if(reno.value.length == 0){



            return false;


            window.location = ""+reno.value;

            return true;



function entertoget(e){

var code;

if (!e) var e = window.event;

if (e.keyCode) code = e.keyCode;

else if (e.which) code = e.which;

var character = String.fromCharCode(code);


var refn=document.getElementById('ref');

var address = refn.value;








Reference: <input type='text' id='ref' onkeypress="javascript:entertoget(event);" value='gigigallery' />

<input type='button' onclick="javascript:getrefno(document.getElementById('ref'), 'Please Enter Your Ref No.');" value='Get My Photos' />




Saturday, 10 January 2009

HOWTO: make “the java plugin” work on Firefox in Fedora 10 / Linux Distro?

1) locate the file named on your box by issuing the following command at the prompt:

[dkd903@dkd903-laptop ~]$ locate

you`ll find that the file is available in the /usr/java/jre1.6.0_07/plugin/i386/ directory.

2) Then what you need to do is just link the .so file symbolically to the mozilla plugins folder, and you are done:

[dkd903@dkd903-laptop ~]$ sudo   ln  -s  

Sunday, 4 January 2009



做法:1   大土豆一个(2人份)土豆这东西很出数的,所以不用切很多

           2   土豆切丝,大家如果刀法和我一样不是很到位的话,就慢点切吧,即使切大点也没关系,反正自己家人吃嘛,呵呵

            3   将刚切好的土豆丝放在凉水中,这样土豆丝就不会变黑了

            4   将土豆丝放如开水中抄一下,不要用很长时间,这要根据你切土豆丝的粗细决定

            5   将抄好的土豆丝放入凉水中过3变,去掉淀粉,让土豆丝更脆,把土豆丝放入盘中

            6   将2勺油放入马勺中烧开,在土豆丝上放上葱花。糖少许,蒜要多些,鸡精,盐,芝麻,赶过的麻椒面,辣椒面,将烧开的油倒上去,拌好放香菜即可。


My photo
London, United Kingdom

Facebook & Twitter