This file contains hidden or 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
package default; | |
import com.fasterxml.jackson.annotation.JsonProperty; | |
import com.fasterxml.jackson.databind.ObjectMapper; | |
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; | |
import com.google.common.base.Objects; | |
import com.google.common.collect.Lists; | |
import org.hibernate.validator.constraints.NotEmpty; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; |
This file contains hidden or 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
def date_xrange(s_dt, e_dt, inclusive=False): | |
ONE_DAY = timedelta(days=1) | |
days = (e_dt - s_dt).days | |
days = days + 1 if inclusive else days | |
return (s_dt + i*ONE_DAY for i in range(0, days)) |
This file contains hidden or 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
# loop foreva-eva | |
def loop(sequence): | |
while True: | |
for elem in sequence: | |
yield elem | |
# example usage, imagine you have a set of things you want | |
# to cycle through, removing bad ones as they appear | |
class ObjectPoolEmptyError(Exception): |
This file contains hidden or 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 bash | |
################################################################################ | |
# Use as a global mercurial/git pre commit or pre push hook to detect the type | |
# of project and run unittests before allowing a commit or push to a remote | |
# repository. | |
# | |
# Handy so that you don't have to remember to add test running hooks to every | |
# repo clone/fork you have. | |
# | |
# ********** MERCURIAL SETUP ************* |
This file contains hidden or 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
# requirements.txt | |
# pip install requests | |
# pip install BeautifulSoup4 | |
import codecs | |
import requests | |
from bs4 import BeautifulSoup | |
PER_LINE = 12 |
This file contains hidden or 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/ruby | |
# ************************************************************************** | |
# ### modified based on: | |
# http://stackoverflow.com/questions/123378/command-line-unix-ascii-based-charting-plotting-tool | |
# ### | |
# eplot | |
# Written by Christian Wolf | |
# | |
# eplot ("easy gnuplot") is a shell script which allows to pipe data easily | |
# through gnuplot and create plots quickly, which can be saved in postscript, |
This file contains hidden or 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
/** | |
<dependency> | |
<groupId>org.fusesource.leveldbjni</groupId> | |
<artifactId>leveldbjni-all</artifactId> | |
<version>1.7</version> | |
</dependency> | |
*/ | |
import com.google.common.base.Optional; | |
import org.iq80.leveldb.DB; |
This file contains hidden or 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 bash | |
open -a /Applications/IntelliJ\ IDEA\ 13\ CE.app/ pom.xml | |
# best as a bash alias :) |
This file contains hidden or 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 bash | |
# N.B. requires patch queues (mq) enabled in your .hgrc. to finish this up | |
# and turn into a real commit, do `hg qfinish -a` | |
now=`date +"%s"` | |
patch_name='$now-temporary' | |
hg qnew $patch_name | |
hg qpop |
This file contains hidden or 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 sys | |
class TestTriedToAccessNetwork(BaseException): | |
pass | |
if 'test' in sys.argv: | |
import socket | |
class PatchedSocket(socket.socket): |