Skip to content

Instantly share code, notes, and snippets.

@erikvold
erikvold / gistUserScriptInstallLink.user.js
Created January 29, 2010 06:04
This userscript will add an 'Install' link to all userscript files (which end with .user.js by necessity).
@defunkt
defunkt / clients.md
Created April 18, 2010 14:09
A list of Gist clients.

Gist Clients

Want to create a Gist from your editor, the command line, or the Services menu? Here's how.

Editor Support

@jaywilliams
jaywilliams / csv_to_array.php
Created April 30, 2010 23:18
Convert a comma separated file into an associated array.
<?php
/**
* Convert a comma separated file into an associated array.
* The first row should contain the array keys.
*
* Example:
*
* @param string $filename Path to the CSV file
* @param string $delimiter The separator used in the file
* @return array
#!/bin/bash
#
# General all-covering MediaTomb transcoding script.
#
#############################################################################
# Edit the parameters below to suit your needs.
#############################################################################
# Subtitles imply transcoding; set to 1 to disable subtitle rendering.
# For divx this doesn't matter much but for mp4, mkv and DVD it does.
@gregawoods
gregawoods / split_to_explode.sh
Created September 23, 2011 13:59
Search a directory for PHP files and replace instances of split() with explode()
for file in $(egrep --include=*.php -rl "([^a-zA-Z_]+)split\(" .)
do
# you might replace 'preg_split' with 'explode' if you don't require regex support
sed -E "s/([^a-zA-Z_]+)split\(/\1preg_split\(/g" $file > /tmp/tempfile.tmp
mv /tmp/tempfile.tmp $file
done
@sandermarechal
sandermarechal / daemon
Created March 5, 2012 11:12
PHP problem using passthru() on bash script that uses process replacement
#!/bin/bash
# Start daemon, using a syslog file descriptor as logfile
# This causes the phing.php passthru() to hang
./daemon.php >(logger -t daemon.php)
# This will work fine from phing.php
# ./daemon.php out.log
@garthhumphreys
garthhumphreys / NSLog-format-specifiers.txt
Created March 30, 2012 16:56
NSLog format specifiers
%@ Object
%d, %i signed int
%u unsigned int
%f float/double
%x, %X hexadecimal int
%o octal int
%zu size_t
%p pointer
%e float/double (in scientific notation)
@jasperf
jasperf / searchanddestroy.sh
Last active February 1, 2022 19:09
Hacked Search and Desctroy Bash commands #security #unix
#Search for eval(base64_decode)
find . -name \*.php -exec grep -l "eval(base64_decode" {} \;
#Look for world writable files
find . -type d -perm -o=w
#last logins + ip addresses from where the user logged in
last -i | grep youruser
last -if /var/log/wtmp.1 | grep youruser
@eddmann
eddmann / dump.php
Created September 10, 2012 17:35
An alternative to 'var_dump'
function dump()
{
$args = func_get_args();
echo "\n<pre style=\"border:1px solid #ccc;padding:10px;margin:10px;font:14px courier;background:whitesmoke;display:block;border-radius:4px;\">\n";
$trace = debug_backtrace(false);
$offset = (@$trace[2]['function'] === 'dump_d') ? 2 : 0;
echo "<span style=\"color:red\">" . @$trace[1+$offset]['class'] . "</span>:" .
@andrewvc
andrewvc / preg_avgs_shell.sh
Created September 30, 2012 17:26
Thinking Stats first exercise, using shell instead of python
#!/bin/sh
split_cmd='cut -b 275,276,277,278,279 2002FemPreg.dat'
first_avg=`$split_cmd | grep '1 1$' | cut -b 1,2 | awk '{s += $1} END { print s/NR }'`
other_avg=`$split_cmd | grep -v ' 1$' | grep '1..$' | cut -b 1,2 | awk '{s += $1} END { print s/NR }'`
hours_diff=`echo "($first_avg-$other_avg)*168" | bc`
echo First borns: $first_avg weeks
echo Non-first borns: $other_avg weeks
echo Difference: $hours_diff hours