Skip to content

Instantly share code, notes, and snippets.

@yendor
yendor / ParallelTask.php
Created November 14, 2011 05:54
Base class for doing forked, parallel execution in PHP easily
<?php
class ParallelTask
{
protected $pid = null;
public $max_workers = 8;
protected $num_workers = 0;
public function run()
@yendor
yendor / notify-apache-errors.sh
Created November 14, 2011 05:08 — forked from dave1010/notify-apache-errors.sh
notify-apache-errors.sh
#!/bin/bash
# use ubuntu's notification system to let us know when there's something new in the apache error log
TAIL=/usr/bin/tail
if [ -x /usr/bin/inotail ]; then
TAIL="/usr/bin/inotail"
fi
$TAIL -n0 -f /var/log/apache2/error.log | while read line
do
openssl x509 -in mydomain.crt -out mydomain.pem -outform PEM
<Proxy *>
SetOutputFilter DEFLATE
</Proxy>
<Location />
# GZIP COMPRESSION.
# For all browsers turn on html, css and javascript gzip compression
# For old browsers turn OFF all gzip compression
# For IE6 gzip html only
# Allow gzip compression for html, css, and javascript
AddOutputFilterByType DEFLATE text/html text/javascript text/css application/x-javascript
#!/bin/sh
# Exit if an undefined variable is referenced
set -o nounset.
# Exit if there is an error
# set -o errexit
if ( set -o noclobber; echo "$$" > "$lockfile") 2> /dev/null;
then
trap 'rm -f "$lockfile"; exit $?' INT TERM EXIT
<?php
$supervars = array('_POST', '_GET', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES');
$gpc = array('_ENV', '_GET', '_POST', '_COOKIE');
foreach ($gpc as $gpc_var) {
foreach ($$gpc_var as $key => $val) {
if (!in_array($key, $supervars)) {
$$key = $val;
global $$key;
}
@yendor
yendor / pull.php
Created October 16, 2008 23:10
Pull files from staging to production with rsync
#!/usr/bin/env php -f
<?php
define('CONFIG', $_ENV['HOME'].'/.push/config');
if (!file_exists(CONFIG)) {
echo "ERROR: There is no config file at ".CONFIG."\n";
exit(1);
}
@yendor
yendor / push.php
Created October 16, 2008 22:55
Push files from staging to production with rsync
#!/usr/bin/php -f
<?php
define('CONFIG', $_ENV['HOME'].'/.push/config');
if (!file_exists(CONFIG)) {
echo "ERROR: There is no config file at ".CONFIG."\n";
exit(1);
}
@yendor
yendor / OSX Configuration Settings
Created September 11, 2008 04:53
Some basic things to get OSX the way I like it
# prevent textmate writing metadata files (._) to network shares
defaults write com.macromates.textmate OakDocumentDisableFSMetaData 1
# Make the dock icons for hidden windows transparent
defaults write com.apple.Dock showhidden -bool YES
killall Dock
# Add a recent applications stack to the dock
defaults write com.apple.dock persistent-others -array-add '{ "tile-data" = { "list-type" = 1; }; "tile-type" = "recents-tile"; }'
killall Dock