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
git branch | grep -v master | sed s/^..// | xargs git branch -D |
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 compute(number) | |
sieve((2..number).to_a, [], Math.sqrt(number)) | |
end | |
def sieve(list, primes, stopper) | |
return primes + list if list.first >= stopper | |
primes << list.shift | |
list.reject! { |n| n % primes.last == 0 } | |
sieve(list, primes, stopper) | |
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
require 'bundler/setup' | |
Bundler.require | |
require 'active_record' | |
require 'action_controller/railtie' | |
require 'action_view/railtie' | |
# ActiveRecord::Config | |
ActiveRecord::Base.configurations = {'development' => {:adapter => 'sqlite3', :database => ':memory:'}} | |
ActiveRecord::Base.establish_connection :development |
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
words = %w(foo bar baz) | |
regexp = Regexp.union(words) |
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
package main | |
import "fmt" | |
// 料理を作るI/F | |
type Cooker interface { | |
Cook() string | |
} | |
// 塗るI/F |
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 KaraokeMachine | |
def initialize(melody_string) | |
@melody = Melody.parse(melody_string) | |
end | |
def transpose(amount) | |
@melody.transpose(amount).present | |
end | |
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
package main | |
import "fmt" | |
// 料理を作るI/F | |
type Cooker interface { | |
Cook() string | |
} | |
// 塗るI/F |
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
uname -a |
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
#logs | |
@timeline = Timeline.find(current_user) | |
@timeline.each do |activity| | |
p activity.date | |
p activity.balance | |
p activity.outgo | |
p activity.income | |
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
sub group_by(&@) { | |
my $block = shift; | |
my %result; | |
for (@_) { | |
my $key = $block->($_); | |
$result{$key} = [] unless exists $result{$key}; | |
push @{ $result{$key} }, $_; | |
} |
NewerOlder