Want to create a Gist from your editor, the command line, or the Services menu? Here's how.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Gist UserScript Install Link | |
// @author Erik Vold | |
// @namespace gistUserScriptInstallLink | |
// @include http://gist.github.com/* | |
// @version 0.1 | |
// @license GPL version 3 or any later version; http://www.gnu.org/copyleft/gpl.html | |
// @datecreated 2010-01-28 | |
// @lastupdated 2010-01-28 | |
// @description This userscript will add an 'Install' link to all userscript files (which end with .user.js by necessity). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%@ 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>:" . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
OlderNewer