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
foo | |
bar |
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
module NotAble | |
def not | |
boolean_bizzaro_world | |
end | |
private | |
def boolean_methods | |
methods.select { |m| m.to_s.end_with? '?' } | |
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
SPYAIR - BEAUTIFUL DAYS | |
プラスにもっと変えていける | |
purasu ni motto kaete ikeru | |
this can be made better | |
そうやって信じていこう | |
sou yatte shijite ikou | |
let's go on beliving that way |
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
(1..10).each do |num| | |
sleep 0.5 | |
print "\r" | |
dashes, spaces = '-'*num, ' '*(10-num) | |
bar = "[#{dashes}#{spaces}]" | |
print bar | |
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
#!/usr/bin/env ruby | |
class Deploy | |
def self.all(remote='staging') | |
releases_txt = `heroku releases -r #{remote}` | |
app_txt, *release_strs = releases_txt.split("\n") | |
app, remote = app_txt[/===\s+(\S+)/, 1], remote | |
deploy_strs = release_strs.select {|str| str =~ /^v\d+\s+Deploy/} |
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
module Nottable | |
class Notter < BasicObject | |
attr_reader :orig | |
def initialize(orig) | |
@orig = orig | |
end | |
def equal?(other) | |
! orig.equal? other | |
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
class MarkdownText < String | |
def lines | |
split("\n").map { |l| MarkdownLine.new l } | |
end | |
def urls_to_links! | |
replace lines.map { |line| | |
line.solo_url? ? line.to_url_link : line | |
}.join("\n") | |
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
# first solution | |
(1..100).map{|n|s="#{'Fizz'if n%3==0}#{'Buzz'if n%5==0}";p s.empty?? n:s} | |
# second implemenation | |
(1..100).map{|n|p %W[#{n} Fizz Buzz FizzBuzz][n%15==0?3:n%3==0?1:n%5==0?2:0]} | |
(1..100).map{|n|p %w[Fizz Buzz FizzBuzz][n%15==0?2:n%3==0?0:n%5==0?1:7]||n} | |
# combined and shortened | |
(1..100).map{|n|p "#{n%3==0?n%5==0?'FizzBuzz':'Fizz':n%5==0?'Buzz':n}"} | |
(1..100).map{|n|p n%3==0?n%5==0?'FizzBuzz':'Fizz':n%5==0?'Buzz':n} |
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
i = 5 | |
x = [:Fizz][i%3] # => :Fizz || nil | |
# 5%3 | |
# [:Fizz][2] # => nil | |
str = "%sBuzz" % x # => 'Buzz' || 'FizzBuzz' | |
# "%sBuzz" % nil # => 'Buzz' | |
str = [str][i%5] # => ^ above str or nil | |
# 5%5 | |
# ['Buzz'][0] # => 'Buzz' | |
# |