Skip to content

Instantly share code, notes, and snippets.

View andyvanee's full-sized avatar

Andy Vanee andyvanee

View GitHub Profile
@andyvanee
andyvanee / Setup the repo.md
Created June 6, 2012 18:14
Three repo server deploys

On the server

Set up the master bare repo in your home directory..

cd ~
git init --bare my-repo
git repo-config core.sharedRepository true
cd my-repo/hooks
<!doctype html>
<html>
<head>
<style type="text/css">
.container { width: 40%; margin: 0 auto; background-color: #DDF; height: 400px; padding: 10px 0;}
.textbox { width: 100%; padding: 4px; border-width: 1px; }
.text-wrapper { padding: 0 10px; margin-left: -10px; }
</style>
</head>
<body>
@andyvanee
andyvanee / NModel.php
Created July 18, 2012 19:32
Model Update is broken
<?php
//...
function update($dao = false, $convertTimeToUTC = true) {
//...
}
?>
@andyvanee
andyvanee / decomposition.coffee
Created August 24, 2012 00:00
CoffeeScript snippets
# Convert dashed, lowercase title to proper title
dashToTitleCase = (title) ->
properCase dashToSpace title
# Capitalize each space-separated word in the string
properCase = (xs) ->
xs.replace(
/\w\S*/g,
(xs) -> xs.charAt(0).toUpperCase() + xs.substr(1).toLowerCase()
)
@andyvanee
andyvanee / MyModule.py
Created September 20, 2012 07:26
Embed Python in Objective-C (without PyObjC)
def my_func():
return "embedding?"
@andyvanee
andyvanee / dns_alert.sh
Created September 26, 2012 07:52
Check continually for new page content (DNS or cache clearing)
PAGE="http://my.site.com/"
SEARCH="new-content"
CONTENT=`curl -# $PAGE | grep $SEARCH`
while [ -z "$CONTENT" ]
do
sleep 8
CONTENT=`curl -# $PAGE | grep $SEARCH`
done
@andyvanee
andyvanee / setup_pypy.sh
Created October 31, 2012 17:01
Setting up PyPy with virtualenv
# Set the next three lines to get the appropriate binary download from here:
# http://pypy.org/download.html
PYPY_VERSION="pypy-1.9"
PYPY_TAR=$PYPY_VERSION"-osx64.tar.bz2"
PYPY_URL="https://bitbucket.org/pypy/pypy/downloads/"$PYPY_TAR
# Target folder where pypy package will live
SRC_DIR=$HOME"/src"
PYPY_DIR=$SRC_DIR"/"$PYPY_VERSION
<?php
$query->update(function(&$row){
if ($row['my_name'] === 'tester') $row['my_name'] = 'random dude';
})->rowCount();
@andyvanee
andyvanee / convert_images.php
Created November 16, 2012 15:57
Process a list of files passed on the command line
<?php
// call this on a list of PDF's to convert, eg:
// $ find public_html/upload/rig -name '*.pdf' -print0 | xargs -0 php bin/convert_images.php $1
set_time_limit(5*60); // give it 5 minutes
$root_dir = dirname(dirname(__FILE__));
$filelist = array_slice($argv, 1);
$process = true; // actually process the files?
$reprocess = false; // reprocessed already processed files?
@andyvanee
andyvanee / gitdiff
Created February 22, 2013 22:28
Show all changes since a certain commit visually with FileMerge
#!/bin/sh
#
# This script was written by Toby White under an unknown license, and published
# on the Git mailing list:
#
# http://kerneltrap.org/mailarchive/git/2007/11/21/435536
#
# Superficial changes were made by Nathan de Vries to allow the script to be
# run under Leopard.
#