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/ruby | |
require 'json' | |
require 'stringio' | |
def count_swaps(sort_me) | |
is_sorted = false | |
swap_count = 0 | |
while is_sorted == false |
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
def aclosure(outer) | |
-> (inner) {inner + outer} | |
end | |
add3 = aclosure(3) | |
add10 = aclosure(10) | |
puts add3.call(5) | |
puts add10.call(5) |
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
function branchit() { | |
if [ $# -lt 3 ] | |
then | |
echo "Usage : habitbranch [b|f|c|r|p] description pivotalID" | |
return | |
fi | |
local category="$1" | |
local description="$2" | |
local pivid="$3" |
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
## Git branch cleanup | |
# remove remote branches merged into my local development | |
alias gitcleanupremote='git branch --merged development | grep -v "\*" | grep -v "master*" | grep -v "developoment" | xargs -I {} git push origin :{}' | |
# rename for deletion local branches merged into my local development | |
alias gitcleanup='git branch --merged development | grep -v "\*" | grep -v "master*" | grep -v "developoment" | xargs -I {} git branch -m {} "DELETEME-{}"' | |
# Delete branches marked for delete | |
alias gitdestroy='git branch | grep DELETEME- | xargs -n 1 git branch -d' |
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
$('.interstitial-ad iframe:visible') | |
.contents() | |
.find('head') | |
.append("<style type='text/css'> body { background: red; } </style>") | |
$('.interstitial-ad iframe:visible') | |
.contents() | |
.find('head') | |
.append("<style type='text/css'>#ad-button { height: 26px !important; top: 212px !important; left: 270px !important; } </style>") |
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
keypad = { | |
'2': ['A','B','C'], | |
'3': ['D', 'E', 'F'], | |
'4': ['G','H','I'], | |
'5': ['J','K','L'], | |
'6': ['M','N','O'], | |
'7': ['P','Q','R','S'], | |
'8': ['T','U','V'], | |
'9': ['W','X','Y','Z'] |
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
# There is an array stock_prices_yesterday where: | |
# * The indices are the time in minutes past trade opening time, which was 9:30am local time. | |
# * The values are the price in dollars of Apple stock at that time. | |
# For example, the stock cost $500 at 10:30am, so stock_prices_yesterday[60] = 500. | |
# Write an efficient algorithm for computing the best profit I could have made from 1 purchase and 1 sale of 1 Apple stock yesterday. | |
# No "shorting"—you must buy before you sell. You may not buy and sell in the same time step (at least 1 minute must pass). | |
def get_max_profit(stock_prices_yesterday) |
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
# AngelList Interview | |
# March 27, 2015 | |
# create HTML table given width and height | |
# | |
# Example: | |
# w = 2 | |
# h = 3 | |
# would generate: | |
# - 1 2 | |
# 1 1 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
# Command Line Tic Tac Toe Game | |
# | |
# On the command line: | |
# | |
# $ ruby tic_tac_toe.rb | |
# Class that controlls the game. | |
# | |
# Examples | |
# |
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
# Configure Rails Environment | |
ENV["RAILS_ENV"] = "test" | |
if ENV['COVERAGE'] | |
require 'simplecov' | |
SimpleCov.start do | |
add_filter '/test/' | |
end | |
end | |
require File.expand_path("../dummy/config/environment.rb", __FILE__) |
NewerOlder