Skip to content

Instantly share code, notes, and snippets.

View phred's full-sized avatar
🌴
On vacation

Fred Alger phred

🌴
On vacation
View GitHub Profile
@phred
phred / sketch.py
Created April 22, 2009 03:58
Processing+jython color cube
"""
jython version of http://hipstersinc.com/blog/2007/5/16/jruby_processingorg_howto/
Spinning color cube controled by mouse motion.
1. Install Jython
2. Add Processing's core.jar to CLASSPATH: export CLASSPATH=/Applications/Processing.app/Contents/Resources/Java/core.jar
3. ~/jython2.5b3/bin/jython sketch.py
"""
#!/bin/sh
# Wrapper for IronPython on the Mac. Install Mono from here:
# http://www.go-mono.com/mono-downloads/download.html
#
# Thanks to this Japanese article; code truly is the universal language:
# http://textdirected.googlepages.com/IronPythonUnderMacOSXmonoJ.html
#
exec /Library/Frameworks/Mono.framework/Versions/Current/bin/mono /Library/Frameworks/Mono.framework/Versions/Current/lib/IPCE/ipy/ipy.exe "$@"
//
// Output a Couch view as CSV, fields ordered per the 'fields' local variable.
// This is designed for use with FoxyCouch, the RESTful Foxycart order manager.
//
// To install in a FoxyCouch[1] instance, use CouchApp to 'pull' the design documents
// and then make a 'lists' directory inside 'manager_screen'; then put the contents
// of this into 'orders_as_csv.js'. Then do a 'couchapp push'.
//
// (Yeah, I realize now that I should move the rest of FoxyCouch to CouchApp, because
// it rocks.)
@phred
phred / gist:206267
Created October 9, 2009 19:28
Comment on "advanced Javascript techniques" blog showing a nice way to format HTML-with-JS.
// Comment on http://sixrevisions.com/javascript/6-advanced-javascript-techniques-you-should-know/
pageContainer.innerHTML = array('',
'<h1>' + pageTitle + '</h1>',
'<div id="content">',
' <p>' + pageContent + '</p>',
' <div id="author_bio">',
' <p>' + authorBio + '</p>',
' </div>',
'</div>',
@phred
phred / gist:237322
Created November 17, 2009 22:14
init.d script example for controlling a PHP FastCGI pool
#!/bin/bash
# chkconfig: - 85 15
# description: controls the pool of PHP FastCGI daemons used to handle \
# dynamic requests from nginx.
PHP_SCRIPT=/opt/nginx/bin/world_php_fcgi
RETVAL=0
case "$1" in
start)
$PHP_SCRIPT
RETVAL=$?
@phred
phred / transaction.lasso
Created November 20, 2009 07:14
Lasso functions to decode and decrypt a FoxyCart datafeed.
[
Define_Tag('Decode_Raw', -Required='input');
Local('output' = bytes());
Local('ndx' = 1);
While(#ndx < #input->Length);
if(#input->Get(#ndx) == '%');
local: 'byte' = string(#input->Substring(#ndx+1, 2));
@phred
phred / default.php
Created December 2, 2009 21:39
Vanilla 2 plugin to maintain Vanilla 1 links after the upgrade.
<?php if (!defined('APPLICATION')) exit();
/*
Copyright 2008, 2009 FoxyCart, LLC
This is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this file. If not, see <http://www.gnu.org/licenses/>.
Contact Fred Alger at fred [dot] alger [at] foxycart [dot] com
*/
@phred
phred / permission_hammer.sh
Created December 15, 2009 22:17
Fix Plesk's vhost group permissions nonsense. Stick this in a cron job to make the headaches go away.
#!/bin/sh
#
# A hammer to fix group permissions on Plesk vhosts.
#
# Plesk creates httpdocs directories with correct permissions initially,
# and they work properly over FTP (sort of), however, they require special
# love to let Apache write to them; namely putting Apache in the psacln
# group, making sure that everyone's httpdocs are owned by that group,
# and setting the setgid bit on httpdocs and all of its subdirectories
# so that new directories created by Apache inherit the proper permissions
#!/bin/sh
# super-simple request per minute statistics from an Apache log file
# watch it live, now with JSON output!
# while [ /bin/true ]; do sh logstats.sh ; sleep 60 ; done
#
LOGFILE=/var/log/apache2/access_log
HOUR=`date +%H`
MIN=`date +%M`
MIN=`expr $MIN - 1`
@phred
phred / backup_cloudant_db.sh
Created January 26, 2011 16:48
Quick n' dirty shell script to back up a Cloudant database to a new, uniquely-named Cloudant DB.
#!/bin/sh
CLOUDANT_USER="myusername"
CLOUDANT_PASS="mypassword"
CLOUDANT_DB="mydb"
DATE=`date +"%Y-%m-%d\$%H.%M"`
BACKUP_NAME="${CLOUDANT_DB}_backup_${DATE}"
echo "Creating database named ${BACKUP_NAME}"