- @hamajyotan (SAKAGUCHI Takashi)
- office ummm
- rubyist
- slowlife engineer (farmer, programmer)
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 "mkmf" | |
$libs += " -lstdc++ " | |
create_makefile("human") |
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
/* =================================================== | |
* bootstrap-transition.js v2.1.1 | |
* http://twitter.github.com/bootstrap/javascript.html#transitions | |
* =================================================== | |
* Copyright 2012 Twitter, Inc. | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* |
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
# Dollar class. | |
# | |
# d1 = Dollar.new 12345 # => $ 12,345.00 | |
# d1.dollar # => 12345 | |
# d2 = Dollar.new 1234, 567 # => $ 1,239.67 | |
# d2.cent # => 67 | |
# d3 = Dollar.new 1239, 67 # => $ 1,239.67 | |
# d2 == d3 # => true | |
# d4 = Dollar.new 12345, 2 # => $ 12,345.02 | |
# (d1..d4).to_a # => [$ 12,345.00, $ 12,345.01, $ 12,345.02] |
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
# -*- encoding: utf-8 -*- | |
class Hoge | |
def moe | |
`ls -l` | |
end | |
end | |
describe "hoge" do | |
let(:hoge) { Hoge.new } |
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 | |
# Usage: ./hoge KEYWORD | |
# | |
# ./hoge Java | |
# => | |
# 名前 Java<br/> パラダイム 構造化プログラミング 構造化・命令型プログラミング... | |
# | |
require 'net/http' |
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 'active_record/relation' | |
# Usage | |
# | |
# class User | |
# scope :foo, -> { where(name: 'foo') } | |
# scope :bar, -> { where(name: 'foo') } | |
# end | |
# | |
# > User.foo.or User.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
def with_retry times: 2, catch: StandardError | |
yield binding.local_variable_defined?(:tries) ? binding.local_variable_get(:tries).to_i : 0 | |
rescue *catch | |
raise unless (tries = tries.to_i + 1) < times | |
retry | |
end | |
# or | |
def with_retry times: 2, catch: StandardError |
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 f *args | |
args.map(&:to_s).permutation.map { |x| x.join.to_i }.max | |
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 | |
require 'bundler' | |
Bundler.require | |
Capybara.run_server = false | |
Capybara::Session.new(:poltergeist).tap do |page| | |
page.visit 'https://www.so-net.ne.jp/retail/w/' | |
page.within 'form[name=Login]' do | |
page.find('input[name=IDToken1]').set ENV['ZEROSIM_ID'] |
OlderNewer