Skip to content

Instantly share code, notes, and snippets.

@Dru89
Dru89 / StringSwitch.java
Created July 28, 2011 20:57
Testing strings in switch statements with Java 1.7
public class StringSwitch {
public static void main(String... args) {
System.out.println("String x = new String(\"asdf\");");
System.out.println("String y = new String(\"asdf\");");
System.out.println("String z = \"asdf\";");
String x = new String("asdf");
String y = new String("asdf");
String z = "asdf";
System.out.format("x == y : %s\n", x==y ? "true" : "false");
@Dru89
Dru89 / prose.zsh
Created November 28, 2012 21:58
My ZSH Theme
# proze.zsh-theme
# Most of this was taken from http://stevelosh.com/blog/2010/02/my-extravagant-zsh-prompt/
# Determine what character to use in place of the '$' for my prompt.
function repo_char {
git branch >/dev/null 2>/dev/null && echo '☿' && return
echo '○'
}
# Display any virtual env stuff with python.
@Dru89
Dru89 / facebook_profiles.py
Created December 6, 2012 01:04
Display a list of names for people's user ids.
import json
import urllib2
facebook_ids = [] # Input ids here like ["1234567890", "1234567890", "1234567890", "1234567890"]
to_show = 15 # how many profiles do you want to see?
def get_name_for(id):
return json.loads(urllib2.urlopen("http://graph.facebook.com/{0}".format(id)).read())["name"]
@Dru89
Dru89 / gist:5510529
Created May 3, 2013 16:14
sample git hook for jekyll
GIT_REPO=$HOME/myrepo.git
TMP_GIT_CLONE=$HOME/tmp/myrepo
PUBLIC_WWW=/var/www/myrepo
git clone $GIT_REPO $TMP_GIT_CLONE
cd $TMP_GIT_CLONE
jekyll --no-auto $TMP_GIT_CLONE $PUBLIC_WWW
cd $HOME
rm -Rf $TMP_GIT_CLONE
exit
module Jekyll
LIQUIDY_TAGS = ['{{', '}}', '{%', '%}']
class StaticFile
def is_liquidy
case File.extname(self.path)
when '.html'
text = File.read(self.path)
LIQUIDY_TAGS.any? { |tag| text.include? tag }
else
ORIGIN_GIT_REPO=/path/to/my/origin/repo.git
###############################
# Method 1: You don't care if the clone is a repo, you just want the files
# (useful for builds/etc that you aren't manually working with)
TMP_GIT_CLONE=/path/to/local/clone
git clone $GIT_REPO $TMP_GIT_CLONE
# if you do some build logic, it could go here like:
# cd $TMP_GIT_CLONE/
@Dru89
Dru89 / prose.zsh-theme
Created July 10, 2014 20:04
My ZSH Theme
# Most of this was taken from http://stevelosh.com/blog/2010/02/my-extravagant-zsh-prompt/
# Determine what character to use in place of the '$' for my prompt.
function repo_char {
git branch >/dev/null 2>/dev/null && echo '☿' && return
echo '○'
}
# Display any virtual env stuff with python.
function virtualenv_info {
@Dru89
Dru89 / turtles.py
Created September 4, 2014 21:47
Get all the images from http://xkcd.com/1416/
# Get all the images from http://xkcd.com/1416/
import urllib2
import json
ids = []
def process(id):
if id in ids: return
ids.append(id)
@Dru89
Dru89 / coffeelint.json
Created December 27, 2014 21:33
The SASS and CoffeeScript linting files that I use
{
"no_backticks": {
"level" : "ignore"
},
"no_tabs" : {
"level" : "error"
},
"no_trailing_whitespace" : {
@Dru89
Dru89 / word_bubbles_solver.py
Created May 28, 2015 06:39
A simple(ish) script written in python to solve puzzles for the Word Bubbles game. I hacked on this for about a day, so I'm not sure how well it works.
import argparse
import os
import re
import sys
from collections import defaultdict, Counter
from copy import deepcopy
EXAMPLE_PUZZLE = [
['n', 'e', 'e', 't'],