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
| require 'octokit' | |
| def gh | |
| @gh ||= Octokit::Client.new auto_paginate: true, access_token: ENV['GH_ACCESS_TOKEN'] | |
| end | |
| def teams_with_ids(organization) | |
| gh.org_teams(organization).map {|t| [t.name, t.id]} | |
| 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
| require 'csv' | |
| require 'open-uri' | |
| require 'gruff' | |
| # loading original data | |
| body_count_data = CSV.read(open("http://files.figshare.com/1332945/film_death_counts.csv"), headers: true) | |
| # adding a new column with the full title and year | |
| body_count_data.map do |row| | |
| row << {"Deaths_Per_Minute" => (row["Body_Count"].to_i / row["Length_Minutes"].to_f), |
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
| # Silly Tank built for the Madrid.rb RTanque duel | |
| # Author: @xuanxu | |
| class Medusa < RTanque::Bot::Brain | |
| NAME = 'Medusa' | |
| include RTanque::Bot::BrainHelper | |
| def tick! | |
| move_to_destination | |
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
| # Dump production postgres database and save it locally | |
| Capistrano::Configuration.instance(:must_exist).load do | |
| namespace :db do | |
| desc "Backup the PostgreSQL database and download file to local" | |
| task :localdump, :roles => :db, :only => {:primary => true} do | |
| now = Time.now | |
| backup_time = [now.year,now.month,now.day,now.hour,now.min,now.sec].join('-') | |
| set :backup_file, "#{shared_path}/tmp/#{environment_database}-snapshot-#{backup_time}.sql" |
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 tip(msg); puts; puts msg; puts "-"*100; end | |
| # | |
| # 30 Ruby 1.9 Tips, Tricks & Features: | |
| # http://www.igvita.com/2011/02/03/new-ruby-19-features-tips-tricks/ | |
| # | |
| tip "Upgrading to Ruby 1.9 is simple: rvm install 1.9.2 && rvm --default 1.9.2" | |
| tip "Ruby 1.9 supports named captures in regular expressions!" |
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
| <!-- layout file --> | |
| <% if current_user %> | |
| Welcome <%= current_user.username %>. Not you? <%= link_to "Log out", logout_path %> | |
| <% else %> | |
| <%= link_to "Sign up", signup_path %> or <%= link_to "log in", login_path %>. | |
| <% end %> |