Skip to content

Instantly share code, notes, and snippets.

View paultag's full-sized avatar

Paul Tagliamonte paultag

View GitHub Profile
@stianeikeland
stianeikeland / blackjack.hy
Last active August 29, 2015 14:07
blackjack kata in hy at bergen coding dojo
(require hy.contrib.loop)
(import [random [shuffle]])
(def ranks (+ (range 2 11) [:a :k :q :j]))
(def suits [:h :c :d :s])
;; OH MY IMPERATIVE GAAWD!
(def deck [])
(for [rank ranks
suit suits]
@barakmich
barakmich / gist:3162dca81838d3501e2e
Last active August 29, 2015 14:14
CA Triples Feedback

First, let's get a summary of what's going on:

$ cat ca | cut -f 2 -d " "| sort | uniq -c
  15066 </bill/id>
  15066 </bill/session>
  51722 </bill/sponsor>
 35194 
@paultag
paultag / gist:1313020
Created October 25, 2011 14:55
clear the screen in c++
#include <iostream>
using namespace std;
int main ( int argc, char ** argv ) {
char msg[] = {
0x1B, '[', '2', 'J', 0x1B, '[', 'H', '\0'
};
std::cout << msg;
}
@paultag
paultag / gist:4235162
Created December 7, 2012 18:09
python-sunlight in clojure-py
(ns sunup
(:require sunlight))
(defn frequencies [coll]
(reduce (fn [counts x] (assoc counts x (inc (get counts x 0)))) {} coll))
(print
(frequencies
(for [l (kwapply
(.-legislators sunlight/openstates)
@paultag
paultag / sunshell
Created December 12, 2012 16:35
sunshell for python-sunlight and bpython
#!/usr/bin/bpython -i
from sunlight import *
import json
import sys
if '--local' in sys.argv:
import sunlight.services.openstates
sunlight.services.openstates.service_url = 'http://localhost:8000/api/v1'
@paultag
paultag / clojtest.clj
Created December 13, 2012 23:39
Test Clojure dput-ng hook
; Copyright (c) Paul R. Tagliamonte <paultag@debian.org>, 2012, under the
; terms of dput-ng it's self.
(ns clojtest
(:require dput.core
dput.exceptions))
(defn log [x] ; for debug output
(.debug dput.core/logger x))
@paultag
paultag / gist:4333914
Created December 19, 2012 02:43
frickn' lisp in frickn' python
; vim: tabstop=2 expandtab shiftwidth=2 softtabstop=2 filetype=lisp
; Copyright (c) Paul Tagliamonte, in sofar as any of this is at all
; copyrightable.
(def hello "World!")
(def square (fn [arg]
(* arg arg)))
@paultag
paultag / gist:4333969
Created December 19, 2012 02:51
Python in lisp
; vim: tabstop=2 expandtab shiftwidth=2 softtabstop=2 filetype=lisp
; Copyright (c) Paul Tagliamonte, in sofar as any of this is at all
; copyrightable.
(puts "Hello, World!")
; "Hello, World!"
(import ["os"
"sys"])
@paultag
paultag / info.md
Last active December 10, 2015 02:09
Hython Runtime

tl;dr

PyPy is ruddy fast. So is Hy.

Time of fib(9), using a simple recursive implementation.

@olasd
olasd / output
Last active December 15, 2015 20:41
Parsley is fun.
⏚ [nicolasd:~/code/parsley] [parsley] $ python test_parsley.py
('root',
[(1, 0), (346, 0)],
('parens',
[(3, 0), (3, 36)],
('token', [(3, 1), (3, 12)], 'import-from'),
('token',
[(3, 13), (3, 28)],
'tests.resources'),
('token', [(3, 29), (3, 35)], 'kwtest')),