Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / 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 / 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 / php-curl-post.php
Created September 22, 2011 02:40
php curl post and write to file
$ch = curl_init($post_url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array('data1'=>'val','data2'=>'val2')));
$data_str = curl_exec($ch);
curl_close($ch);
file_put_contents($path_to_xml_data,$data_str);
@davidvanvickle
davidvanvickle / php-curl-get-json.php
Created September 22, 2011 02:36
php curl get json
$ch = curl_init('http://domain.com?'.http_build_query(array('type'=>'stuffIndex','request'=>'getIt')));
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$resp = curl_exec($ch);
curl_close($ch);
$d = json_decode($resp,true);
if ($d && isset($d['akey'])) {
}
@davidvanvickle
davidvanvickle / git-notes.txt
Last active September 27, 2015 07:28
GIT notes
Pull to web host
git init
git remote add origin [email protected]:username/domain.git .
git pull origin master
http://nvie.com/posts/a-successful-git-branching-model/
branches: