Skip to content

Instantly share code, notes, and snippets.

View nomeyer's full-sized avatar

Nick Omeyer nomeyer

  • @Stepsize
View GitHub Profile
@nomeyer
nomeyer / code.ts
Created September 11, 2019 17:54
Anonymised Abstract Syntax Tree example
const lines = [
'I am a string',
'I am not a string',
'Lies',
'You got me',
];
function printLines(callback: () => void) {
lines.forEach((line, i) => console.log(`Line ${i}: ${line}`));
callback();
@nomeyer
nomeyer / dict_object_attributes.py
Created May 30, 2016 12:25
Method to be able to call dict() on Python objects and get a dictionary of attribute values
def __iter__(self):
for attr, value in self.__dict__.iteritems():
yield (attr, value)
@nomeyer
nomeyer / tree.md
Created May 19, 2016 16:14 — forked from hrldcpr/tree.md
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

from xml.dom.minidom import parse, parseString
import urllib2
# note - i convert it back into xml to pretty print it
print parse(urllib2.urlopen("http://search.twitter.com/search.atom?&q=python")).toprettyxml(encoding="utf-8")
@nomeyer
nomeyer / npm_list.sh
Last active March 14, 2016 14:53
List installed packages (from https://docs.npmjs.com/cli/ls)
npm ls