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
from sys import argv | |
from collections import defaultdict | |
from random import choice | |
class DefaultList(list): | |
def __getitem__(self, idx): | |
try: | |
return super().__getitem__(idx) | |
except IndexError: |
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
# R. Scott Reis - Implementation of Prim's Algorithm | |
# http://en.wikipedia.org/wiki/Prim%27s_algorithm | |
require 'sinatra' | |
require 'haml' | |
require 'json' | |
module Prim | |
class << self | |
def get_graph |
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
<div class="edit-inline"> | |
<span ng-show="editing"> | |
<input type="text" ng-model="text" /> | |
<button ng-click="editing = false">Save</button> | |
</span> | |
<span ng-hide="editing"> | |
<span ng-bind="text"></span> | |
<button ng-click="editing = true">Edit</button> | |
</span> | |
</div> |
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
prefix = (ARGV[0] || 2).to_i | |
words = (ARGV[1] || 5).to_i | |
corpus = `cat /usr/share/dict/words`.downcase | |
dict = Hash.new { |h,k| h[k] = [] } | |
corpus.split("\n").each do |word| | |
chars = "#{word} ".chars.to_a | |
until chars.length < (prefix + 1) do | |
dict[chars.first(prefix).join] << chars[prefix] | |
chars.shift |
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 | |
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )" | |
"$DIR/node_modules/.bin/forever" start \ | |
--watch --watchDirectory ${DIR} \ | |
--watchIgnore "$DIR/.*/*" \ | |
--watchIgnore "$DIR/public/*" \ | |
--watchIgnore "$DIR/logs/*" \ | |
--append -l "$DIR/logs/app.log" \ | |
--minUptime 1000 \ | |
--spinSleepTime 1000 \ |
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
require 'treetop' | |
module Mine | |
class IntegerLiteral < Treetop::Runtime::SyntaxNode | |
def to_i | |
text_value.to_i | |
end | |
end |
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
[user] | |
email = <YOUR EMAIL> | |
name = <YOUR NAME> | |
[color] | |
diff = auto | |
status = auto | |
branch = auto | |
interactive = auto | |
ui = true |
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
source ~/git-prompt.sh | |
source ~/git-completion.bash | |
PS1='\u:\w\[\033[32m\]$(__git_ps1)\[\033[0m\]$ ' |
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
require 'json' | |
require 'haml' | |
require 'sinatra' | |
get '/' do | |
haml :view | |
end | |
get '/request' do | |
content_type :json |
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
require 'sinatra' | |
require 'haml' | |
require 'json' | |
enable :sessions | |
get '/' do | |
session[:answer] = %w[A B C D].sample | |
haml :index | |
end |