Skip to content

Instantly share code, notes, and snippets.

View michaelcontento's full-sized avatar

Michael Contento michaelcontento

View GitHub Profile
@michaelcontento
michaelcontento / clang version
Created June 11, 2012 17:06
Monkey - no stacktrace?
/Developer/usr/bin/clang++ -v ~/Workspace/private/monk 1
Apple clang version 3.0 (tags/Apple/clang-211.12) (based on LLVM 3.0svn)
Target: x86_64-apple-darwin11.3.0
Thread model: posix
@michaelcontento
michaelcontento / lxc-ubuntu.sh
Created January 3, 2012 20:45 — forked from dkulchenko/lxc-ubuntu
Script to generate LXC containers for EC2
#!/bin/bash
#
# Template script for generating ubuntu container for LXC with the same
# ubuntu relase as the host
#
# This script is based on lxc-debian for EC2 (Daniil Kulchenko <[email protected]>)
# wich itself is based on lxc-debian (Daniel Lezcano <[email protected]>)
#
@michaelcontento
michaelcontento / cake-some-fixture-wtf.php
Created December 19, 2011 10:29
CakePHP Fixture "Fun"
<?php
class SomeFixture extends CakeTestFixture
{
public $name = 'Table';
public $records = array(
array('A' => 1, 'B' => 2),
array('B' => 2, 'A' => 1)
);
}
@michaelcontento
michaelcontento / game.coffee
Created July 3, 2011 19:50
Backbone models connected with Faye based backend (frontend written in CoffeeScript)
$ ->
# === CONFIGURATION
GAME_DIV_ID = '#game'
FAYE_URL = 'http://localhost:9292/faye'
# === APPLICATION
GameModel = Backbone.Model.extend {}
GameView = Backbone.View.extend {
el: $(GAME_DIV_ID)
@michaelcontento
michaelcontento / primary_keys.sql
Created June 20, 2011 08:33
Shows combined primary keys on innodb
create table bla(
b int,
id int not null auto_increment,
primary key (b, id),
unique key (id)
) engine=innodb;
insert into bla (b) values (1), (2), (1), (2);
/* this looks like "order by id, b" because with small tables mysql doesn't use the primary key */
@michaelcontento
michaelcontento / demo.sql
Created June 20, 2011 08:32
MySQL: Insert utf8 via latin1-connection into utf8
--
-- First we create the table with charset=utf8
--
mysql> create table utf8 (msg varchar(10)) default charset=utf8;
Query OK, 0 rows affected (0.00 sec)
--
-- This is out demo-character (remember the hex value!)
--
@michaelcontento
michaelcontento / test.sh
Created June 9, 2011 10:19
Simple combination of inotifywait and phpunit
#!/bin/sh
if [ $# -ne 1 ]; then
echo "usage: $0 TEST-DIR"
exit 1
fi
testsDir=$1
if [ ! -d $testsDir ]; then
@michaelcontento
michaelcontento / joe.php
Created June 9, 2011 09:38
Simple regex for @joemanaco
<?php
$input = <<<EOF
### Section: Imports ###
text....
foo
### End Section ###
@michaelcontento
michaelcontento / .htaccess
Created May 30, 2011 16:02
RewriteRule with md5 cachebusting
RewriteEngine On
# Rewrite all URLs with md5 cachebusting
# e.g. /e0d97534e77671a12012a9a1effc3bda/css/style.css -> /css/style.css
RewriteRule ^[A-Z0-9]{32}/(.*)$ $1 [NC,N]
# Based on the Zend Framework manual
# see: http://framework.zend.com/manual/1.11/en/project-structure.rewrite.html
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
@michaelcontento
michaelcontento / google-grabber.sh
Created May 26, 2011 18:29
Grab profile URLs from Google and extract the users email (if public)
time curl -s http://www.gstatic.com/s2/sitemaps/sitemap-[001-002].txt \
| xargs -P10 -L1 -I{} sh -c "curl -s {} | egrep -o 'profiles.google.com/[^&\"]+' | cut -d'/' -f2 | egrep -v '^[0-9]+$'"