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 python3 | |
"""Python3 script template.""" | |
import argparse | |
def run(args): | |
pass | |
def parse_arguments(): |
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 argparse | |
import itertools | |
import os | |
import subprocess | |
""" | |
Run MUMmer on every pair of files from the list of input files. | |
""" | |
# Default path to the MUMmer binary |
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 | |
# Requirements: | |
# * The AWS CLI should be installed: https://aws.amazon.com/cli/ | |
# * A credentials file has the correct account credentials configured as default (see the CLI reference) | |
# * There exists a security group in the default region whose name is SSH | |
MYIP=$(curl -s http://checkip.amazonaws.com/) | |
#echo "Current IP is: $MYIP" |
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
# Get the list of top sites for a given country from Alexa, found here: | |
# http://www.alexa.com/topsites/countries/<country code> | |
# and transform it into a nice text file, one domain per line. | |
# Supply the country code as the first argument. Defaults to US. | |
require 'rubygems' | |
require 'open-uri' | |
require 'nokogiri' | |
BASE_URL = "http://www.alexa.com/topsites/countries" | |
country = ARGV[0] || "US" |
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
# Place this file in config/initializers | |
# load the libraries | |
require 'aws' | |
# log requests using the default rails logger | |
AWS.config(:logger => Rails.logger) | |
# here's how to load credentials from a file | |
#config_path = File.expand_path(File.dirname(__FILE__)+"/../aws.yml") | |
#AWS.config(YAML.load(File.read(config_path))) |
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
require 'sinatra' | |
require 'net/http' | |
require 'json' | |
ENDPOINT = 'https://accounts.google.com/o/oauth2/auth' | |
TOKEN_ENDPOINT = 'https://accounts.google.com/o/oauth2/token' | |
CLIENT_ID = '<your app client id>' | |
CLIENT_SECRET = '<your app client secret>' | |
REDIRECT_URI = 'http://localhost:4567/auth/google_oauth2/callback' | |
SCOPE = 'https://www.google.com/m8/feeds/' |
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
# Retry the block several times, with a timeout between retries | |
# Options: | |
# times - maximum number of retries | |
# timeout - timeout betwen retries, in seconds | |
# break_on - will break the rerty loop given that result from the block | |
# if break_on is a lambda, it will call it with the block result and break if it returns true | |
# @return the block's result | |
def retryable(options = {}, &block) | |
opts = {times:3, timeout:60, break_on:false}.merge(options) | |
(1...opts[:times]).each do |i| |
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
#define BUTTON 7 | |
#define LED 9 | |
int dir = 1; | |
int lum = 0; | |
boolean toggle = false; | |
void setup() { | |
pinMode(BUTTON, INPUT); | |
pinMode(LED, OUTPUT); |
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 ruby | |
# Explodes a minified css file, e.g. using YUI Compressor (http://developer.yahoo.com/yui/compressor/) | |
# Minified css (unlike obfuscated javascript) is still easily readable if only the spaces, newlines and | |
# indentations are put back in. This little ruby script does this with some simple regular expressions. | |
fn = ARGV[0] | |
css = IO.read fn | |
replacements = [ [/\s*\{/, " {\n\t"], [/;/, ";\n\t"], [/\t?\}/, "}\n\n"], ] |
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
# An implementation of the Damerau–Levenshtein algorithm for string distance | |
# See: http://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance | |
# Also based on: http://en.wikibooks.org/wiki/Algorithm_implementation/Strings/Levenshtein_distance#Ruby | |
module DamerauLevenshtein | |
def self.distance(a, b) | |
return b.length if a.empty? | |
return a.length if b.empty? |
NewerOlder