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
/* Returns probability of occuring below and above target price. */ | |
function probability(price, target, days, volatility) { | |
var p = price; | |
var q = target; | |
var t = days / 365; | |
var v = volatility; | |
var vt = v*Math.sqrt(t); | |
var lnpq = Math.log(q/p); |
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
# bootstrap a new rails 3.0 project from the 3-0-stable branch | |
# | |
# mkdir new_project | |
# | |
# place this Gemfile in new_project | |
# | |
# bundle install --path .gems | |
# bundle exec rails -v | |
# bundle exec rails new . | |
# |
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
# Extracted this code out that was not needed. | |
# Keeping here for future reference. | |
# | |
# Finds upcoming expiry dates for monthly equity options. | |
# | |
# Test data is the official CBOE expiration calendars for 2010/11. | |
require 'date' | |
require 'rubygems' |
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 tries | |
@tries ||= 1 | |
(@tries += 1) - 1 | |
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
// inject jquery | |
var head = document.getElementsByTagName("head")[0]; | |
var newScript = document.createElement('script'); | |
newScript.type = 'text/javascript'; | |
newScript.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js'; | |
newScript.onload = function() { head.removeChild(newScript); modifyDom() }; | |
head.appendChild(newScript); |
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 "rubygems" | |
require "sinatra/base" | |
require "sinatra/async" | |
require "redis" | |
module CometTest | |
class App < Sinatra::Base | |
register Sinatra::Async | |
puts ">> #{REDIS = Redis.new(:thread_safe => 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
#!/bin/bash | |
# Add this script to your ~/bin (ensure in $PATH) and chmod +x. | |
# Requires xdotool. | |
# | |
# Add this to your vimrc: | |
# " reload chrome on html/css/js save | |
# au BufWritePost *.{html,css,js} silent !reload-chrome.sh | |
CUR=$(xdotool getwindowfocus) | |
WID=$(xdotool search --onlyvisible --class "google-chrome" | sort -n | head -1) |
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
tell application "Safari" | |
activate | |
do JavaScript "window.location.reload();" in first document | |
end tell | |
tell application "MacVim" to activate |
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
# Send all monitors to power saving mode (standby) using the WIN32 API. | |
# | |
# Documentation for WM_SYSCOMMAND & SC_MONITORPOWER: | |
# http://msdn.microsoft.com/en-us/library/windows/desktop/ms646360(v=vs.85).aspx | |
require 'fiddle' | |
require 'fiddle/import' | |
require 'fiddle/types' | |
module User32 | |
extend Fiddle::Importer |
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
# Generate all possible combinations for a 46-point win in the game of | |
# Goofspiel. | |
# | |
cards = [*1..13] | |
res = [*4..13].map do |n| | |
cards.combination(n). | |
select { |cards| cards.reduce(:+) == 46 }. | |
map(&:sort). | |
map(&:reverse) |
OlderNewer