Skip to content

Instantly share code, notes, and snippets.

View hannahwhy's full-sized avatar

Hannah Yip hannahwhy

View GitHub Profile
reserved-dhcp-165-124-223-118:migrate davidyip$ RAILS_ENV=development rake db:migrate
(in /Users/davidyip/Projects/pathcore/pathcore)
== 20080812182649 AddUniqueIndexToCollectionGroupsRequisitionIdentifier: migrating
-- add_index(:collection_groups, :requisition_identifier, {:unique=>true})
rake aborted!
SQLite3::SQLException: SQL logic error or missing database: CREATE UNIQUE INDEX "index_collection_groups_on_requisition_identifier" ON "collection_groups" ("requisition_identifier")
@hannahwhy
hannahwhy / salsa20.hs
Created November 20, 2008 06:47
braindead implementation of djb's salsa20
import Bits
import Data.Word (Word32, Word64)
-- Utilities
concatBytes :: (Bits a) => a -> a -> a
concatBytes b1 b2 = (.|.) (shiftL b1 8) b2
le4 :: [Word32] -> [[Word32]]
le4 (x4:x3:x2:x1:[]) = [x1,x2,x3,x4]:[]
le4 (x4:x3:x2:x1:xs) = [x1,x2,x3,x4]:le4 xs
<html>
<head>
<link href="/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="container">
<div id="header">
Header
</div>
<div id="sidebar">
@hannahwhy
hannahwhy / gist:149620
Created July 18, 2009 17:19
a background generator
#!/usr/bin/env ruby
require 'rubygems'
require 'RMagick'
Width = 960.0
TotalDivisions = 24
Divisions = [ 4 + 1, 16 - 1, 4 ]
Colors = [ '#6c7174', '#c3c7cb', '#4b4d4e' ]
0
OrgName: RIPE Network Coordination Centre
OrgID: RIPE
Address: P.O. Box 10096
City: Amsterdam
StateProv:
PostalCode: 1001EB
Country: NL
this.on('beforewrite', function (store, action, record, options) {
var proceed = !!(record.event && !record.event.phantom);
if (proceed && record.createInProgress) {
queued.push(record);
return false;
}
if (proceed && record.phantom) {
record.createInProgress = true;
--
-- calculate sequence of die rolls needed to hit some probability target;
-- most useful in conjunction with take, e.g.
--
-- take 25 (dieProb 12 1%7)
--
-- originally written by me @ http://guyblade.livejournal.com/159423.html, and archived here
--
module DieProb where
From 95e94b3960aac7d08f9305cf59c84c18fafe0a9b Mon Sep 17 00:00:00 2001
From: David Yip <yipdw@northwestern.edu>
Date: Wed, 9 Sep 2009 17:22:15 -0500
Subject: [PATCH 2/2] First cut at a patch for key interpolation problems in validates_uniqueness_of.
---
Manifest.txt | 1 +
lib/composite_primary_keys.rb | 1 +
lib/composite_primary_keys/base.rb | 2 +
.../validations/uniqueness.rb | 170 ++++++++++++++++++++
#include <stdio.h>
int main(int argc, char **argv)
{
int a = 0x7FFFFFFF;
int i;
for(i = 0; i < 5; ++i) {
a = ( a < 0 ? --a : a++ );
printf("%d\n", a);
module Megahal
COMMAND = 'megahal'
OPTIONS = ['--no-prompt', '--no-wrap', '--no-banner']
def start_megahal
@io = IO.popen("#{COMMAND} #{OPTIONS.join(' ')}", 'w+')
end
def stop_megahal
@io.close