This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Build all Maven files and dump all of the jars into a directory. | |
""" | |
import os | |
import sys | |
import re |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Copyright 2013 Eddie Antonio Santos | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.List (sort) | |
-- Given a degree sequence, determines whether it is graphical. Returns a list | |
-- of steps from the base case to the original degree sequence. | |
graphical :: [Int] -> Maybe [[Int]] | |
graphical ds | even $ sum ds = graphical' ds [] | |
-- By the handshaking lemma, cannot be a graph with odd sum: | |
| otherwise = Nothing | |
graphical' ds previous |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Installs your SSH key on other hosts. A fabfile for lazy people. | |
""" | |
from fabric.api import task, run, put, env, cd | |
# Use sh instead of bash. | |
env.shell = '/bin/sh -l -c' | |
@task |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# If you have OS X and have UglifyJS installed, this uglifies Marginalize and | |
# puts the `javascript:` URL into the clipbord. Hoorah! | |
uglifyjs -c -m -o marginalize.min.js marginalize.js | |
printf 'javascript:' | cat - marginalize.min.js | pbcopy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from itertools import groupby | |
def k_sized_groups(sequence, k): | |
""" | |
Generates iterable groups with a maximum of size of K members from the | |
given sequence. | |
>>> [list(g) for g in k_sized_groups([1, 2, 3, 4], 2)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env runhaskell | |
import Data.List (intercalate) | |
joinLines input = unlines $ map joinLine (lines input) | |
where | |
joinLine line = intercalate "" (words line) | |
main = interact joinLines |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Maybe in Coffeescript | |
# Terminology from Haskell; API from Scala | |
# Inspired by https://gist.github.com/andyhd/1618403 | |
just = (value) -> | |
# Applying the monad will act as "map" by default | |
# To make people even lazier, 'this' is bound to the value anyway. | |
monad = (f) -> just f.call(value, value) | |
monad.getOrElse = -> value | |
monad.getOr = -> value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from itertools import islice, izip, chain | |
# Returns a set of shingles for the given entity. | |
def shingles(entity, w=3): | |
""" | |
Performs charachter-wise shingling on an entity. Natural language | |
processing! Returns the (frozen) set of all shingles for a given entity. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import yaml | |
import json | |
from bson.objectid import ObjectId | |
from itertools import count | |
def parse_database(database): |
OlderNewer