Skip to content

Instantly share code, notes, and snippets.

View paultag's full-sized avatar

Paul Tagliamonte paultag

View GitHub Profile
@paultag
paultag / gist:5188459
Last active December 15, 2015 02:39
hy + pymongo
(import-from pymongo Connection)
(def connection (Connection "localhost" 27017) "test")
(def db connection.test)
(def hello db.test)
(for [x (.find hello {"hello" {"$exists" true}})]
(print (get x "hello")))
@paultag
paultag / spread.js
Created January 24, 2013 14:30
ECMAScript 6 spread operator
/* See:
http://bit.ly/WhXvb3
for the Traceur */
var foo = [9, 9, 9],
bar = [2, 2, 2],
baz = [1, 1, ...foo, 1, 1, ...bar, 1, 1];
console.log(baz);
/* Output: 1,1,9,9,9,1,1,2,2,2,1,1 */
@paultag
paultag / scraper.clj
Created December 31, 2012 20:24
scrape the debian pts with hython
#!/usr/bin/env hython
; not actually clojure ...
(import "urllib2")
(import-from "lxml" "html")
(defn form-pts-url [developer]
"Return the PTS URL for a given developer."
(+ "http://qa.debian.org/developer.php?login=" developer))
@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.

@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 / 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)))
from sunlight import openstates
bills = filter(
lambda x: x != [],
[
[
y['url'] for y in x['documents']
] for x in openstates.bills(q="rifle", fields='documents', state='ct')
]
)
@paultag
paultag / throbber_deux.this.is.not.c
Created October 26, 2010 06:59
Throbber ( Take Deux )
/*
* "Throb" effect ( Part Deux )
*
* Paul Tagliamonte, 2010. ( Peace, Love and C++, baby )
*
* This code is released under the Bacon license.
* If you like this code enough, consider sending me bacon.
*
* That or GPL-3+.
*
@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 / 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'