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
@ECHO OFF | |
REM Determine where is RUBY_BIN (where this script is) | |
PUSHD %~dp0. | |
SET RUBY_BIN=%CD% | |
POPD | |
REM Add RUBY_BIN to the PATH | |
REM RUBY_BIN takes higher priority to avoid other tools | |
REM conflict with our own (mainly the DevKit) | |
SET PATH=%RUBY_BIN%;%PATH% |
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 'mechanize' | |
m = Mechanize.new {|agent| | |
agent.user_agent_alias = 'Mac Safari' | |
} | |
URL = 'http://job.rikunabi.com/2015/s/?freeword=' | |
companies = %w(ハル研究所 任天堂 三菱 トヨタ) | |
companies.each do |param| | |
page = m.get(URL + param) |
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
var a = ["aa", "cc", "bb"]; | |
result = a.slice().sort(); | |
console.log(a); //=> ["aa", "cc", "bb"] // a は変更されない | |
console.log(result); //=> ["aa", "bb", "cc"] | |
var b = ["aa", "cc", "bb"]; | |
result = b.sort(); | |
console.log(b); //=> ["aa", "bb", "cc"] // b も変更されている | |
console.log(result); //=> ["aa", "bb", "cc"] |
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
str = <<PASTE | |
/usr/local/lib/pkgconfig/libcdt.pc | |
/usr/local/lib/pkgconfig/libcgraph.pc | |
/usr/local/lib/pkgconfig/libgvc.pc | |
/usr/local/lib/pkgconfig/libgvpr.pc | |
/usr/local/lib/pkgconfig/libpathplan.pc | |
/usr/local/lib/pkgconfig/libxdot.pc | |
/usr/local/lib/pkgconfig/osxfuse.pc | |
/usr/local/lib/pkgconfig/tcl.pc | |
/usr/local/lib/pkgconfig/tk.pc |
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
open('al', 'w').write %x{bower search angular}.to_s.split(/\n/).to_a.drop(2).map{|x| x.gsub /^\s+/, ''}.inject(''){|re, x| re += "#{x}\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
require 'drb' | |
require 'eventmachine' | |
require 'pp' | |
EM.run do | |
DRb.start_service() | |
obj = DRbObject.new(nil, 'druby://localhost:9000') | |
EM.add_periodic_timer(2) do | |
3.times{pp obj.pop} | |
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 'pp' | |
require 'clipboard' | |
module Downloader | |
@@target_file_exts = [:jpg, :png, :gif, :bmp, :doc, :pdf] | |
@@cache = [] | |
def clipboard_text | |
#%x(pbpaste).scrub | |
Clipboard.paste.scrub |
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 'pp' | |
max = 100 | |
first_prime = 2 | |
prime = [2] | |
list = (2..max).to_a | |
i = 2 | |
while list.size > 1 do | |
list = list.select{|x| x % i != 0} |
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 decrypt cypher | |
decoder = cypher.to_s.split('.').last.split(//).map{|x| x.to_i} | |
code = cypher.to_s.split('.').first.split(//) | |
decoder.inject("") {|res, x| | |
res += proc {|x| | |
if x == 0 then | |
" " | |
else | |
proc {|x| z = 'a'; x.times{z = z.succ}; z}.call( | |
code.shift(x).inject(:+).to_i |
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 'aws-sdk' | |
require 'pp' | |
# if not set region, it will set us-east by default | |
ec2 = AWS::EC2.new(region: 'ap-northeast-1') | |
# List up key pairs you have | |
#pp ec2.key_pairs.map(&:name) | |
# Available Regions |