Skip to content

Instantly share code, notes, and snippets.

git svn clone https://tuxxedo.googlecode.com/svn tuxx // check url
cd tuxx
git remote add origin $GITHUB_URL
git push origin
<?php
$conn = new MySQLi("localhost", "root", "password", "widget_corp");
if ($conn->connect_errno()) {
die("Failed to connect: " . $conn->connect_error());
}
$result = $conn->query("SELECT * FROM subjects");
// You wouldn't usually have this, as you only get an error if the sql's
// wrong
@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;
@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 / 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)
"""
http://scratchedguitar.dyndns.org:8000/listen
<?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) {
@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>
@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 / 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