This file contains hidden or 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 user | |
| @user ||= retreive_user | |
| end | |
| private | |
| def retreive_user | |
| #... do stuff to get user | |
| db.results | |
| end |
This file contains hidden or 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
| --- | |
| :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: "" |
This file contains hidden or 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 Hash | |
| def to_money | |
| Money.new(self[:cents], Money::Currency.wrap(self[:currency])) | |
| end | |
| end | |
| class Money | |
| class Currency | |
| def to_h | |
| { |
This file contains hidden or 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 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 |
This file contains hidden or 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
| #!/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] |
This file contains hidden or 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
| #################### | |
| # WITH HASH ROCKET # | |
| #################### | |
| if @last_tweet_seen | |
| @tweets_hash = client.home_timeline( | |
| :since_id => @last_tweet_seen, | |
| :count => 200, | |
| :include_entities => true | |
| ) |
This file contains hidden or 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
| 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) |
This file contains hidden or 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 score | |
| Player.score_weights.inject(0) do |sum, (attribute, weight)| | |
| sum + (self.send(attribute) * weight) | |
| end | |
| end |
This file contains hidden or 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
| # 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, | |
| } |
This file contains hidden or 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
| <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> |