Skip to content

Instantly share code, notes, and snippets.

View apinstein's full-sized avatar

Alan Pinstein apinstein

  • Atlanta, GA
View GitHub Profile
@apinstein
apinstein / gist:1067664
Created July 6, 2011 16:25
Test ionice
#!/bin/sh
# This should result in very different completion times for the 2 runs.
# This script is useful to be sure that ionice works on your kernel since it's possible to have the
# ionice command yet using it has no effect
# you can check your scheduler with something like
# cat /sys/block/sda1/queue/scheduler
# NOTE: I wrote this to help me figure out if ionice was working on my system. It doesn't seem to be, since the
# output of this script indicates that the priorities, while adjusted, don't get reflected in the real world timings.
# I don't know if my script is wrong or if my server is mis-configured.
@apinstein
apinstein / gist:1083411
Created July 14, 2011 20:50
Apache directives to log some requests w/performance info
# debug performance stuff
SetEnvIf Request_URI ^/panel panel-request
LogFormat "%h %l %u %t %T \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" debug_performance
CustomLog /Users/alanpinstein/dev/sandbox/virtualtour/log/debug_performance_log debug_performance env=panel-request
@apinstein
apinstein / gist:1083936
Created July 15, 2011 02:43
postgres table-as-queue lock experiment
#!/bin/bash
# RESULTS, feel free to repro yourself
#
# noLock FAIL
# accessShare FAIL
# rowShare FAIL
# rowExclusive FAIL
# shareUpdateExclusive SUCCESS
# share FAIL+DEADLOCKS
# shareRowExclusive SUCCESS
@apinstein
apinstein / gist:1266375
Created October 6, 2011 02:55
librets valgrind output
$ export USE_ZEND_ALLOC=0; valgrind --tool=memcheck --num-callers=30 --leak-check=full --show-reachable=yes [rets php script]
@apinstein
apinstein / gist:1281740
Created October 12, 2011 16:34
Redirecting STDOUT and STDERR for complex shell commands
(echo 'this is stdout' && this_is_stderr)
(echo 'this is stdout' && this_is_stderr) 1> /dev/null
(echo 'this is stdout' && this_is_stderr) 2> /dev/null
(echo 'this is stdout' && this_is_stderr) > /dev/null 2>&1
@apinstein
apinstein / gist:1281741
Created October 12, 2011 16:34
Redirecting STDOUT and STDERR for complex shell commands
#!/bin/sh
echo ">> STDOUT and STDERR"
(echo 'this is stdout' && this_is_stderr)
echo ">> STDERR only"
(echo 'this is stdout' && this_is_stderr) 1> /dev/null
echo ">> STDOUT only"
(echo 'this is stdout' && this_is_stderr) 2> /dev/null
echo ">> NOTHING"
(echo 'this is stdout' && this_is_stderr) > /dev/null 2>&1
<?php
manifest(array(
"pear", "apinstein.pearfarm.org/mp", "1.0.2",
));
@apinstein
apinstein / gist:1601324
Created January 12, 2012 16:05
mp-helper.php; calculate all migration re-sequencing
<?php
$fromBranch = 'master';
$toBranch = 'videoClips-integration';
// find common ancestor
$commonAncestor = commonAncestor($fromBranch, $toBranch);
print "Common ancestor of {$fromBranch}..{$toBranch} is {$commonAncestor}\n";
@apinstein
apinstein / gist:4480477
Created January 8, 2013 02:13
How to compile custom binary executables for heroku cedar stack. This is example is for ImageMagick.
# Custom ImageMagick build for Heroku via Vulcan
vulcan create vulcan-builder
curl -O http://www.imagemagick.org/download/legacy/ImageMagick-6.7.4-10.tar.gz
tar zxvf ImageMagick-6.7.4-10.tar.gz
vulcan build -v -s ./ImageMagick-6.7.4-10 -c "./configure --prefix /app/vendor/ImageMagick-6.7.4-10 '--disable-shared' '--with-quantum-depth=8' '--with-lcms' '--with-gslib' --'with-fontconfig' && make install" -p /app/vendor/ImageMagick-6.7.4-10
# ==> downloads output to /tmp/ImageMagick-6.7.tgz
cd /path/to/project
@apinstein
apinstein / shell_scripting_best_practices.md
Last active December 14, 2015 00:08
Shell Scripting best practices

Ensure a consistent execution environment

  1. Always start the script with a shebang line

    #!/bin/bash
    
  2. Always run the script directly