Skip to content

Instantly share code, notes, and snippets.

View dckc's full-sized avatar

Dan Connolly dckc

View GitHub Profile
@dckc
dckc / sgp.py
Created November 3, 2011 02:23
Supergenpass algorithm in python
__author__ = 'Dan Connolly'
__contact__ = 'http://www.madmode.com/'
__license__ = 'dedicated to the public domain, aka CC0'
from base64 import b64encode
from hashlib import md5
import re
def gp2_generate_passwd(Passwd, Len):
'''
@dckc
dckc / sareport.py
Created November 8, 2011 22:13
SQLAlchemy test case that worked in 0.7.2 and doesn't in 0.7.3
from sqlalchemy import Table, Column, text
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.types import INTEGER, VARCHAR, TEXT
from sqlalchemy.sql import select, and_, func
Base = declarative_base()
institutions = ('kuh', 'kupi', 'kumc')
redcap_data = Table('redcap_data', Base.metadata,
@dckc
dckc / money.dart
Created November 11, 2011 05:49
Exploring Dart via the ERights money example
// compare with https://bitbucket.org/DanC/coffee-craft/src/682d06f02e99/money.coffee
// ugh... no nested classes? gotta pass thunks around?
class SealedBox {
final capture;
SealedBox(this.capture);
shareContent() { capture(); }
}
@dckc
dckc / money.scala
Created November 11, 2011 07:32
ocap money in scala
/** transcription of money example from "Smart Contracts"
http://www.erights.org/smart-contracts/index.html
http://www.erights.org/elib/capability/ode/ode-capabilities.html
*/
abstract class Purse { // should this go inside Mint somehow?
def getBalance(): Int // hmm... num type? typeclass trick?
def sprout(): Purse
def getDecr(): Object
def deposit(amount: Int, src: Purse)
@dckc
dckc / import_csv.py
Created November 15, 2011 18:00
why am I getting: sqlalchemy.exc.CompileError: The version of oracle you are using does not support empty inserts.
import csv
import sys
import logging
import sqlalchemy
def main():
logging.basicConfig(level=logging.DEBUG, stream=sys.stderr)
sl = logging.getLogger('sqlalchemy')
sl.setLevel(logging.DEBUG)
@dckc
dckc / gist:1479001
Created December 14, 2011 23:05
wierd sqlalchemy error
**********************************************************************
File "heron_policy.py", line 77, in heron_policy
Failed example:
facreq.user.repository_authz()
Exception raised:
Traceback (most recent call last):
File "/usr/lib/python2.6/doctest.py", line 1253, in __run
compileflags, 1) in test.globs
File "<doctest heron_policy[20]>", line 1, in <module>
facreq.user.repository_authz()
@dckc
dckc / url_update.py
Created May 25, 2012 06:37
url_update.py -- an example of balancing ocap style and python community norms
'''url_update -- assist in migrating URLs of Frontiers Research pages
>>> web_ua = _MostPagesOKButSome404(('20-million-clinical', 'out-big-5'))
>>> site = Frontiers(web_ua)
>>> src, dest = site.redirects[0]
>>> print site.verified_redirect(src, dest)
Redirect permanent /news.html http://frontiersresearch.org/frontiers/news
>>> print site.gone(site.retired[0])
@dckc
dckc / money.rs
Created October 18, 2012 17:56
sealing in rust
// http://dl.rust-lang.org/doc/0.4/tutorial.html#getting-started
// http://www.madmode.com/2011/11/capability-security-in-e-coffescript.html
// http://gitorious.org/repo-roscidus/e-core/blobs/fdf9643e419eea182b4d8d983f5b9955c7b73967/src/jsrc/org/erights/e/elib/sealing/SealedBox.java
extern mod std;
use cmp::{Eq};
mod sealing {
@dckc
dckc / structmatch.rs
Created October 26, 2012 03:10
struct matching problem (compile with rustc structmatch.rs --test)
extern mod std; // else --test goes wonky
extern mod rparse; // https://github.com/jesse99/rparse or: cargo install rparse
use rparse::{Parser, Combinators, ParseFailed, match0 };
pub fn space() -> Parser<@~str> { match0(|ch| ws_char.contains_char(ch)) }
const ws_char: &str = &" \t\r\n\x0A";
#[cfg(test)]
@dckc
dckc / rust-build.log
Created November 27, 2012 03:37
rust build error: unexpected token
connolly@pav:~/src/rust$ git pull origin
remote: Counting objects: 5323, done.
remote: Compressing objects: 100% (1656/1656), done.
remote: Total 4469 (delta 3494), reused 3682 (delta 2804)
Receiving objects: 100% (4469/4469), 1.26 MiB | 783 KiB/s, done.
Resolving deltas: 100% (3494/3494), completed with 396 local objects.
From https://github.com/mozilla/rust
4dc67c5..de0268b incoming -> origin/incoming
07edf90..68c73dc master -> origin/master
cd6f24f..be6613e snap-stage3 -> origin/snap-stage3