Skip to content

Instantly share code, notes, and snippets.

View deontologician's full-sized avatar
🦀
🌎

Josh Kuhn deontologician

🦀
🌎
View GitHub Profile
from datetime import datetime, timedelta
from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class Version(Base):
@deontologician
deontologician / ipl.hs
Created February 7, 2014 01:47
Trying to prove (a > b) || (a < b) || (a == b)
{-# LANGUAGE TypeOperators, GADTs, StandaloneDeriving #-}
{-# OPTIONS_GHC -Wall #-}
import Prelude hiding(True, False, Bool, Eq)
data Z = Z
data S n = S n
data Nat n where
Zero :: Nat Z
@deontologician
deontologician / netezza_dialect.py
Last active August 29, 2015 13:57
Rough cut of a Netezza SQLAlchemy dialect. Mostly inherits from the Postgresql and PyODBC dialects.
Made an actual github repo for wiki/issues etc. Please see here:
https://github.com/deontologician/netezza_sqlalchemy
#![feature(macro_rules)]
extern crate libc;
use libc::{c_char, c_int, c_long};
#[link_name = "curses"]
extern {
fn setupterm (term: *c_char, fd: c_int, errret: *c_int) -> c_int;
fn tigetstr (s: *c_char) -> *c_char;
fn tparm (s: *c_char,
rustc --out-dir lib -L tmp src/term.rs && touch tmp/built
src/info/curses.rs:40:1: 40:12 error: macro definitions are not stable enough for use and are subject to change
src/info/curses.rs:40 macro_rules! def_escape(
^~~~~~~~~~~
src/info/curses.rs:40:1: 40:12 note: add #[feature(macro_rules)] to the crate attributes to enable
src/info/curses.rs:40 macro_rules! def_escape(
^~~~~~~~~~~
src/info/builtin.rs:711:1: 711:12 error: macro definitions are not stable enough for use and are subject to change
src/info/builtin.rs:711 macro_rules! def_escape(
^~~~~~~~~~~
fn main() {
let mut rows = [[ 1, 2, 3, 4],
[ 5, 6, 7, 8],
[ 9,10,11,12],
[13,14,15,16]];
for i in range(0, 4u) {
for j in range(0, 3u) {
/// Here's what I'd like to do
class Dog(object):
def __init__(self):
self.dict_ = {}
self.__dict__
def add(self, name, breed):
self.dict_[name] = breed
def __repr__(self):
{
"name": "Marmaduke",
"breed": "Mastif",
"jumping_height": 0.5,
"color": "brown",
}
def make_dog(name, breed, jumping_height, color='brown'):
return {
"name": name,
@deontologician
deontologician / qcombinator.py
Last active August 29, 2015 14:04
Prototype ReQL combinator library
# Examples:
#
# from qcombinator import q
# q.add(3) # is equivalent to: (lambda doc: doc.add(3))
# q.add(3).eq(4) -> (lambda doc: doc + 3 == 4)
# q.add(3).eq(4).or_('Dang!') -> (lambda doc: r.or_(doc + 3 == 4, 'Dang!'))
# q(3) -> r.expr(3)
# r.table('A').map(q.obj('ok')) -> r.table('A').map(lambda doc: {'ok': doc})
import sys
@deontologician
deontologician / rql.py
Created August 26, 2014 03:06
Script for running RethinkDB ReQL queries from the commandline
#!/usr/bin/env python2
'''Quick and dirty script for executing reql from the commandline'''
import json
import argparse
import rethinkdb as r