Skip to content

Instantly share code, notes, and snippets.

@davidvanvickle
davidvanvickle / gist:1335638
Created November 3, 2011 02:40
replace php-cgi with php-fpm
sudo apt-get install php5-fpm
sudo /etc/init.d/php-fpm start
top
sudo tail -f /var/log/php5-fpm.log
tab tab
sigkill
@davidvanvickle
davidvanvickle / nginx client_max_body_size
Created November 4, 2011 18:38
nginx client_max_body_size
For upload problems.
nginx.conf
http block
client_max_body_size 5m;
@davidvanvickle
davidvanvickle / run shell script from php cgi.php
Created December 6, 2011 01:18
run shell script from php cgi
function syscall($command){
$result = '';
if ($proc = popen("($command)2>&1","r")){
while (!feof($proc)) $result .= fgets($proc, 1000);
pclose($proc);
//return nl2br($result);
return $result;
}
return '';
}
@davidvanvickle
davidvanvickle / random.js
Created December 30, 2011 19:19
JS random number function
function randomAddOn () {
return '' + (Math.floor(Math.random()*1000*((new Date()).getSeconds())));
}
@davidvanvickle
davidvanvickle / list.sh
Created December 31, 2011 00:30
shell - file to list, get first line
limit_a=`cat limit`
limit=${limit_a[0]}
@davidvanvickle
davidvanvickle / xml.sh
Created December 31, 2011 00:32
shell - read xml value
if [ -e "yfollowers" ]
then
NAMES=`cat yfollowers`
for value in $NAMES
do
if [[ $value =~ \<screen_name\>([0-9a-zA-Z_]*)\<\/screen_name\> ]];then
i=1
n=${#BASH_REMATCH[*]}
while [[ $i -lt $n ]]
@davidvanvickle
davidvanvickle / php-dwn-bin.php
Created January 10, 2012 21:48
php download a binary
$data = 'hello world';
$source_url = 'https://domain.com/chart?chid=' . md5(uniqid(rand(), true));
// params (http_build_query will later urlencode)
$qrcode = array(
'cht' => 'qr',
'chs' => '177x177',
'chl' => $data);
// send the request
@davidvanvickle
davidvanvickle / ascii.sh
Created April 13, 2012 05:41
convert file to ascii
# see man page, args may vary
# to force conversion, use -c also
iconv -t ISO-8859-1 -f UTF-8 < utf.txt > asc.txt
@davidvanvickle
davidvanvickle / remove-exif.sh
Created May 17, 2012 20:24
Remove EXIF data from JPG
# show EXIF data
exiftool image.jpg
# first install exiftool, then use "-All=" to wipe all EXIF data from JPG
# this will modify image.jpg and create backup file image.jpg_original
exiftool -All= image.jpg
http://www.howtogeek.com/115051/become-a-vi-master-by-learning-these-30-key-bindings/
Mode Switching
As a short recap, vi is a modal editor – there’s an insert mode and a standard command mode. In insert mode, vi functions similar to a normal text editor. In command mode, you take advantage of these key bindings.
i – Enter insert mode.
Escape – Leave insert mode. If you’re already in command mode, Escape does nothing, so you can press Escape to ensure you’re in command mode.
Moving the Cursor
Vi uses the hjkl keys to move the cursor in command mode. Early computer systems didn’t always have arrow keys, so these keys were used instead. One advantage of these keyboard shortcuts is that you don’t have to move your fingers from the home row to use them.