Skip to content

Instantly share code, notes, and snippets.

View semmons99's full-sized avatar

Shane Emmons semmons99

View GitHub Profile
def user
@user ||= retreive_user
end
private
def retreive_user
#... do stuff to get user
db.results
end
---
:aed:
:priority: 100
:iso_code: AED
:name: United Arab Emirates Dirham
:symbol: "\xD8\xAF.\xD8\xA5"
:subunit: Fils
:subunit_to_unit: 100
:symbol_first: true
:html_entity: ""
@semmons99
semmons99 / gist:842113
Created February 24, 2011 12:34
Money#to_h proposal
class Hash
def to_money
Money.new(self[:cents], Money::Currency.wrap(self[:currency]))
end
end
class Money
class Currency
def to_h
{
def move(params = {})
current_move = params[:current_move]
next_move = params[:next_move]
return up if current_move > @current_location
return down if current_move < @current_location
return open_door(next_move) if current_move == @current_location
idle
end
#!/usr/bin/env ruby
require_relative "../lib/elevator_simulation"
unless ARGV.length == 1
warn "Please specify an input file for the simulation."
exit
end
data = ARGV[0]
####################
# WITH HASH ROCKET #
####################
if @last_tweet_seen
@tweets_hash = client.home_timeline(
:since_id => @last_tweet_seen,
:count => 200,
:include_entities => true
)
module RubyFight
class Application < Sinatra::Base
get '/fight/:player1/vs/:player2' do
player1_github = params[:player1].gsub(".json", "")
player2_github = params[:player2].gsub(".json", "")
player1 = Player.fetch(github: player1_github)
player2 = Player.fetch(github: player2_github)
def score
Player.score_weights.inject(0) do |sum, (attribute, weight)|
sum + (self.send(attribute) * weight)
end
end
# Score weights
def self.score_weights
{
public_repo_count: 200,
public_gist_count: 50,
followers_count: 50,
gems_count: 200,
total_downloads: 10,
average_downloads: 15,
}
<job>
<id> <%=h @job.id %></id>
<moment_id> <%=h @job.moment_id %></moment_id>
<name> <%=h @job.name %></name>
<message> <%=h @job.message %></message>
<email> <%=h @job.email %></email>
<complete> <%=h @job.complete %></complete>
<trigger_at><%=h @job.trigger_at %></trigger_at>
<created_at><%=h @job.created_at %></created_at>
</job>