Skip to content

Instantly share code, notes, and snippets.

@rmasters
rmasters / gist:1637232
Created January 19, 2012 02:18
Templating example
Two directories:
/public -> For publically accessible files
/templates -> For templated code, not publically accessible
Make pages in /public which have database/$_GET/etc. code in them (business logic/controller logic). At the end of them do:
$contentPath = __DIR__ . "/../templates/index.php";
require __DIR__ . "/../templates/layout.php";
@rmasters
rmasters / gist:1585395
Created January 9, 2012 22:44
Started re-writing the UPSU:Radio site in LOLCODE
HAI
BTW The UPSU:Radio website, rewritten in LOLCODE
CAN HAS STDIO?
GIMMEH REQUEST
VISIBLE "UPSU:RADIO"
I HAS A COUNTER BTW Incrementer for the nav loop
@rmasters
rmasters / duper.py
Created September 25, 2011 22:32
CSV merge-subtract-doo-dah
#!/usr/bin/python
"""
Imports two exported CSV files containing tabular data, merges them and
outputs the difference between one list and the merged copy.
"""
import csv
# Import
@rmasters
rmasters / gist:1057189
Created June 30, 2011 20:43
Blueprint CSS rules to achieve equal-height columns.
/**
* A couple of CSS rules to achieve equal-height columns in Blueprint CSS
*/
/* Apply to the sub-grid container */
.equalcolumns {
overflow: hidden;
}
/* Note column classes must start with their span-x attribute */
@rmasters
rmasters / gist:951925
Created May 2, 2011 17:03
Ubuntu recovery with encrypted home directory
For when Ubuntu crashes out and you need to backup from a live CD.
Source: http://ubuntuforums.org/showthread.php?t=1534704
1. Locate the ubuntu filesystem in /media, it'll have a name like /media/8805834782... - it's UUID.
2. If the dir isn't encrypted you'll be able to browse /media/UUID/home/user/*, otherwise it'll have two files about ecryptfs - follow to the next step.
3. If the dir is encrypted you'll need to mount it - for this you will need the passphrase and filename encryption key signature:
4. First add the passphrase (see 4a if you don't know it):
$ sudo ecryptfs-add-passphrase --fnek
Passphrase: <enter passphrase>
<?php
$array = array(
array("id" => 1, "user" => "Ross"),
array("id" => 2, "user" => "Adam"),
array("id" => 3, "user" => "Ben")
);
$iterator = new RecursiveArrayIterator($array);
foreach ($iterator as $key => $value) {
http://scratchedguitar.dyndns.org:8000/listen
@rmasters
rmasters / secret_santa.py
Created November 20, 2010 17:27
Generate single-direction pairs of people for secret santa (i.e. A sends to B, but not B sends to A).
"""
Secret santa matching attempt
"""
import random
"""
Match people randomly to others, for example in a secret santa
Takes a list of people as an input and returns a list of tuples (person a sending to person b)
"""
@rmasters
rmasters / Question.php
Created November 3, 2010 16:15
Aim: confuse rich
<?php
class Model_Question extends WebApp_Model
{
protected $id;
protected $question;
protected $choices = array();
protected $asker;
protected $asked;
protected $visible = true;
@rmasters
rmasters / Question.php
Created November 3, 2010 16:15
Aim: confuse the hell out of rich
<?php
class Model_Question extends WebApp_Model
{
protected $id;
protected $question;
protected $choices = array();
protected $asker;
protected $asked;
protected $visible = true;