Skip to content

Instantly share code, notes, and snippets.

@sansumbrella
sansumbrella / Build.php
Created December 19, 2009 19:42
php static page creation
<?php
$base_url = "http://localhost/~username";
$builder = new Build($base_url);
$source = "index.php?about";
$target = "about.html";
$builder->write_file($source, $target);
Class Build
{
public $url; //base url
@sansumbrella
sansumbrella / keyboard_save.pde
Created August 12, 2009 19:14
Processing saveFrame function.
//this is part of why processing is awesome
void keyPressed()
{
if( key == 's')
{
saveFrame("frames/Generic-####.png");
}
}
@sansumbrella
sansumbrella / EventDispatcher.cpp
Created August 3, 2009 07:02
C++ observer pattern for event handling.
#include "EventDispatcher.h"
void EventDispatcher::addListener( Listener *l )
{
mListeners.push_back(l);
}
void EventDispatcher::removeListener( Listener *l )
{
mListeners.erase( std::remove( mListeners.begin(), mListeners.end(), l ), mListeners.end() );
@sansumbrella
sansumbrella / jsonp.php
Created May 14, 2009 22:41
php to return JSON objects. Works with jQuery.
<?php
$JSON = '{events:[{title:"title", info:"info"},{title:"title", info:"info"},{title:"title", info:"info"}]}';
header("Content-type: application/json");
echo $_GET['callback']."($JSON);"
?>
@sansumbrella
sansumbrella / Hosting Git repositories on DreamHost
Created May 7, 2009 21:24
Bash script to create and initialize a git repo on a dreamhost server
#Based on:
#http://casperfabricius.com/site/2008/09/21/keeping-git-repositories-on-dreamhost-using-ssh/
[email protected]
GIT_DOMAIN=whatever.you.want
DH_USER=home/yourusername
YEAR=`eval date +%Y`
#set up on the server
ssh $DREAMGIT_DOMAIN 'mkdir -p '$GIT_DOMAIN'/'$YEAR'/'$1'.git && cd '$GIT_DOMAIN'/'$YEAR'/'$1'.git && git --bare init'
#set up locally