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 'nokogiri' | |
require 'open-uri' | |
URL = "http://www.wunderground.com/US/TX/173.html" #change this if you're not in cedar park | |
TIMESTAMP = /^\d\d\/\d\d\/\d\d\d\d/ | |
$seen = {} |
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
#tunables! | |
VERBOSE = false | |
MAX_DEBT = 15_000 | |
MIN_DEBT = 500 | |
MAX_APR = 30 | |
DEBT_MONEY = 1500 | |
SIMULATION_ATTEMPTS = 1000 | |
class Debt |
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 setCurrentUserFilter() { | |
Ext.Ajax.request({ | |
url: "/convs/current_user_to_json", | |
success: function(transport) { | |
var response = Ext.decode(transport.responseText); | |
alert("received response!"); | |
alert("setting response to: " + response); | |
user_combo.setValue(response); | |
} | |
}); |
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 current_user_to_json | |
render :json => {:user => current_user.display_name, | |
:user_id => current_user.id, | |
:job_title => current_user.job_title, | |
:avatar => nil} | |
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
def problem37 | |
#The number 3797 has an interesting property. Being prime itself, it is possible to | |
#continuously remove digits from left to right, and remain prime at each stage: | |
#3797, 797, 97, and 7. | |
#Similarly we can work from right to left: #3797, 379, 37, and 3. | |
#primes = [37, 797, 3797] | |
primes = [] | |
lefts = [2,3,5,7] | |
rights = [3,7] |
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
Math.module_eval do | |
def self.variance(population) | |
n = 0 | |
mean = 0.0 | |
s = 0.0 | |
population.each do |x| | |
n += 1 | |
delta = x - mean | |
mean = mean + (delta / n) | |
s = s + delta * (x - mean) |
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
class Module | |
def alias_method_chain(target, feature) | |
# Strip out punctuation on predicates or bang methods since | |
# e.g. target?_without_feature is not a valid method name. | |
aliased_target, punctuation = target.to_s.sub(/([?!=])$/, ''), $1 | |
yield(aliased_target, punctuation) if block_given? | |
with_method, without_method = "#{aliased_target}_with_#{feature}#{punctuation}", "#{aliased_target}_without_#{feature}#{punctuation}" | |
alias_method without_method, target |
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
# Settings specified here will take precedence over those in config/environment.rb | |
# In the development environment your application's code is reloaded on | |
# every request. This slows down response time but is perfect for development | |
# since you don't have to restart the webserver when you make code changes. | |
config.cache_classes = false | |
# Log error messages when you accidentally call methods on nil. | |
config.whiny_nils = 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
def people_complexity(people, land) | |
(floor(people.urban * land.urban))! + (floor(people.rural + land.rural))! | |
end | |
women_multiplier = 25 | |
people * people_complexity(women, usa - alaska) * women_multipier * people_complexity(men, usa - alaska) |
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
#here's what the scrape method looks like | |
def scrape!(&block) | |
next_link = nil | |
self.logged_in do | |
loop do | |
break if next_link == "none" | |
response = next_link ? | |
self.http_get(next_link) : |
OlderNewer