Saturday, 26 November 2011

jQuery cheat sheet

  • parent()
  • parents()
  • closest() find the parent element nearest to the selected element
  • children()
  • siblings()
  • prev()
  • next()
  • remove() $("p").remove() remove p elements
  • empty() $("p").empty() delete content in ps
  • detache() $elememts = $("p").detache() remove and hold
  • replacewith()
  • before()
  • after()
  • first()
  • eq()
  • last()
  • slice()
  • filter()
  • not()

Thursday, 24 November 2011

Create a SVN repository

Assume SVN server name is apple

1. ssh to  apple
svnadmin create /var/svn/project_name

2. go back to my machine, cd to  project_name/
svn import svn+ssh://apple/var/svn/project_name

3. check out
svn co svn+ssh://apple/var/svn/project_name

Wednesday, 23 November 2011

Regular Expression

Special Symbol
 \d is digit
\s is white space
. any char
\w equal [A-Za-z0-9_]


boundary
^ is start of string
$ is end of string
\b word boundary

how many times (for previous item)
?  0 or 1
* 0 or more
+ 1 or more
{n} n times
{n,} at least n times
{n,m} n<=match times<=m

group
(pattern) group as one item
(x|y) x or y
[abc] either a,b or c
[^abc] any char except a,b,c
[a-d] match a,b.c or d

PHP related function
preg_match("/mypatter/i", $subject) return 1 if match; otherwise, return 0.  i is a flag for case insensitive search.

Example

all combinations of digits chars and spaces  /^([a-zA-Z\d\s]+)+$/  For this regular expression, empty string will fail







Sample bashrc file

export CVS_RSH=ssh
export CVSROOT=:ext:cvs.somedomain.com:/var/cvs/cvsroot/php
export PATH=/homes/lshen/bin/:/usr/local/lib/jre1.6.0_22/bin/:/usr/bin/:/usr/bin/php/bin/:$PATH
export CLASSPATH=/usr/local/lib/jdk1.6.0_22/bin/:.
export JAVA_HOME=/usr/local/lib/jdk1.6.0_22/bin/
export EDITOR=/usr/bin/vim
export LC_CTYPE=en_US.UTF-8

xset b off

alias ls='ls --color=tty'
alias phpcs='phpcs --standard=Zend';
alias vi='vim'
alias lpr='lpr -P Ricoh'

Some useful command (Mysql Vi etc) Memo

My SQL

Grant a user to a database
mysql>grant all on db_name.* to 'db_username'@'localhost' identified by 'db_userpasswd'
dump a database to a sql file
mysqldump -u root -p --opt leo_db>dump.sql

vi

Auto replace string in vi
:%s/pattern_search_for/new_string_to_be_used/gc

Open and create compressed files

Open files
tar zxvf filename.tar.gz
unzip filename.zip
tar -xvf my.tar
bunzip2 studybuzz.bz2
bzip2 -d studybuzz.bz2
tar jxvf studybuzz.tar.bz2
unrar e test.rar

Create a zip file without parent directory

/test/test.txt
/test/test2.txt
cd test
zip -r -j my.zip *
Create files
zip -r filename.zip filedir
tar -cvf my.tar filedir
Print Env Variables
printenv
curl
curl -H "x-api-key:1234" http://myapi.com/user/1

#The -v option activates verbose mode, revealing detailed communication logs between the client and server
curl -v -H "x-api-key:1234" http://myapi.com/user/1

#curl does not follow HTTP redirects by default. Use the -L, --location option to tell it to do that
curl -L -H "x-api-key:1234" http://myapi.com/user/1