strpos(haystack, needle)
$leadingZero = sprintf("%02d", $string);
$currency = sprintf("%01.2f", $n);
error_reporting(E_ALL | E_STRICT); ini_set('display_errors', 1);
$(function() { ... }); // on pageload (jQuery)
if ($("#myid").length > 0) { /*element exists*/ }
window.location = "http://redirect.com"
history.go(-1);
create tar: tar czf <blah.tar> *
pdftk 1.pdf 2.pdf 3.pdf cat output 123.pdf
find . type f -name '*.php' -print0 | xargs -0 grep {pattern}
egrep -r -include=\*.php -h '@copyright' . | uniq -c | sort -nr
egrep -r -include=\*.php -L '@copyright' .
sdiff -stW file.ext.merge-left.rxx file.ext.merge-right.rxx
scp <filename> <user>@<domain>:<filepath> # Copies a file from local machine to server
scp <user>@<domain>:<filepath> <filename> # Copies a file from server to local machine
patch -p0 -i <patch-filename>
xmllint --format <filename> > <newfile>
Instead of using git pull --rebase, use a git fetch origin and git rebase -p origin/master
svn propset svn:keywords "Id" filename.php
svn copy http://svn.example.com/trunk http://svn.example.com/branches/new-branch -m "Creating a private branch of trunk."
svn merge --ignore-ancestry
svn switch --force
php_flag xdebug.profiler_enable on
php_flag xdebug.profiler_enable_trigger on
(URL should have ?XDEBUG_PROFILE=1)
php_value xdebug.profiler_output_dir /home/xxx/public_html/log
lvh.me virtualhost setup (in /etc/apache2/sites-enabled/*):
RewriteCond %{HTTP_HOST} ^([^.]+)\.web\.lvh.me$
RewriteRule ^(.*)$ /var/www/%1/web/$1 [NC,L]
RewriteCond %{HTTP_HOST} ^([^.]+)\.public\.lvh.me$
RewriteRule ^(.*)$ /var/www/%1/public/$1 [NC,L]
RewriteCond %{HTTP_HOST} ^([^.]+)\.lvh.me$
RewriteRule ^(.*)$ /var/www/%1/$1 [NC]
SET names utf8
show variables
mysql --default-character-set=utf8
show create table <tablename>
To disable screen blanking on Ubuntu Server
sudo vim /etc/default/grub
# make sure that GRUB_CMDLINE_LINUX_DEFAULT contains "consoleblank=0"
sudo update-grub
# reboot