JSã§RSAæå·ã使ãããã¤ä½¿ã£ã¦ã¿ã http://cryptico.wwwtyro.net/éµä½ã var pass = 'kazusuke'; var rsa_key = cryptico.generateRSAKey(pass, 1024); var pub_key = cryptico.publicKeyString(rsa_key); 'hello'ãæå·å var enc = cryptico.encrypt('helâ¦
Macã¯ãã¡ã¤ã«ãä½æãããæã«ãã©ã«ãã¢ã¯ã·ã§ã³ãå®è¡ã§ãã ãã©ã«ãã¢ã¯ã·ã§ã³ã¯Automatorã§ä½ãã Automatorããshell scriptãå®è¡ã§ãã ãã©ã«ãã¢ã¯ã·ã§ã³ãä½ã£ã automatorå ã®shellscriptããã¯ã³ã©ã¤ãã¼ãå¼ã³åºã /usr/bin/ruby -rubygems -â¦
é貨ã¿ãããªè¡¨ç¤º 1234567890.to_s.reverse.split(/(\d{3})/).select{|i|i.size>0}.join(',').reverse => "1,234,567,890"1234567890.to_s.reverse.gsub(/(\d{3})/,'\1,').reverse => "1,234,567,890"
sipsã£ã¦ããã³ãã³ãã©ã¤ã³ãã¼ã«ãMacã«å ¥ã£ã¦ããã®ã§ãããã使ãã¨ããä½ãã sips -s format icns icon.png -z 128 128 --out appIcon.icns
æ°ããMacããgit pushããã remote: *** Project description file hasn't been set remote: error: hook declined to update refs/heads/master ! [remote rejected] master -> master (hook declined)ããããã¨ã©ã¼ãã§ã¦pushã§ããªãããªã¢ã¼ããªãã¸â¦
rvm default do ruby hoge.rbã¨ã rvm system do gem listã¨ã rvm jruby-1.6.7 do ruby -vããã°ãã
yankã³ãã³ãã¯gemcutterã«å ¥ã£ã¦ãã®ã gem install gemcutter gem yank goldfish-poi -v 0.0.1 ååã¨ãã¼ã¸ã§ã³ãæå®ãã¦åé¤ãã
ï¼è§£æ±ºãããä¸ã«æ¸ããï¼ããå®è¡ãã㨠#!/usr/bin/env ruby require 'rubygems' require 'hashie' arr = Array.new 3.times do |i| arr.push Hashie::Mash.new(:count => i, :text => 'test'*i) end arr.each do |i| p i puts "count : #{i.count}" puts â¦
rvmã§ãæ°ããrubyã«ä¹ãæããæã«ãããããruby-1.8.7-p352 â 1.8.7-p358ã«ããã¨ããã rvm get latest rvm reload rvm list known rvm install 1.8.7-p358 gem listãä¿åãã¦ãã㦠gem list | ruby -lane 'puts $_.split(/\s/)[0]' > ~/gems.txt ããâ¦
herokuã§sinatraåãããã åèã«ãã http://devcenter.heroku.com/articles/quickstart http://devcenter.heroku.com/articles/ruby http://www.machu.jp/diary/20111002.html#p01 ãµã¤ã³ã¢ãã https://heroku.com ã§ãµã¤ã³ã¢ãããã¡ã¼ã«ãæ¥ãã®ã§confâ¦
capybara-webkitã§æ®å½±ãã縦é·ã®webãã¼ã¸ã¹ã¯ãªã¼ã³ã·ã§ãã(PNG)ãã1:1.41ã®A4縦é·ã§å°å·ã§ãããµã¤ãº(JPEG)ã«åå²ããã https://github.com/probablycorey/mini_magick brew install imagemagick gem install mini_magick mini_magickç #!/usr/bin/enâ¦
ä»ã¾ã§homebrewã§å ¥ãããpdfjamã使ã£ã¦ããã®ã ããmacportsã«ãããªãpdflatexã«ä¾åãã¦ããã®ã§ãã¾ã使ããããªãã prawn(https://github.com/prawnpdf/prawn)ã使ãã¨Rubyã ãã§ä½ããã®ã§ãä¹ãæãããã¨ã«ããã prawnã¯pngãå ¥ããã¨é ããªãã®â¦
capybara使ãã¨ç°¡åã«ãã£ããã£ã§ããããã¨ãã¨jsã®headless testã®çºã®ãã¼ã«ãªã®ã§jsãå®è¡ããããè¯ãã Macã®å ´å brew install qt gem install capybara capybara-webkit #!/usr/bin/env ruby require 'rubygems' require 'capybara-webkit' driver â¦
ImageMagick imagemagickã«ã¤ãã¦ããidentifyã³ãã³ãã使ã identify ãã¡ã¤ã«åçµæ ãã¡ã¤ã«å PNG 1200x4702 1200x4702+0+0 8-bit DirectClass 890KB 0.000u 0:00.000 mini_magick ImageMagickã®Rubyã©ããã¼ã gem install mini_magick#!/usr/bin/env â¦
phantomjsã§ããã http://d.hatena.ne.jp/Jxck/20111102/1320230249 ã¨æã£ã¦ãã¤ã³ã¹ãã¼ã«ããã®ã ã brew install phantomjsä¸ç·ã«webkit2pngã¨ããpythonã§æ¸ããããã¼ã«ãã¤ãã¦ããã ãã£ããã£ãã¦ã¿ã webkit2png http://shokai.org/blog/ ãããâ¦
applescriptã§å°å·ãã§ããã®ã ããå°çã®ãããªäºã«ãªã£ã¦ããã®ã§åç¹ã«å¸°ã£ã¦lpr ããªã³ã¿ä¸è¦§ãåå¾ lpstat -s USBãsambaã§æ¥ç¶ããããªã³ã¿ãã§ã¦ãã ããªã³ã¿ãæå®ãã¦ãã¡ã¤ã«ãå°å·ãã lpr -P ããªã³ã¿å ãã¡ã¤ã«åå°å·ã®è¨å®ã¯ããã®ããªã³ã¿â¦
commitã®diffãgrepãããã®ã ããgitã ãã§æ¤ç´¢ããæ¹æ³ãããããªãã£ãã®ã§ã¨ãããã~/diffã«å ¨commitã®diffãæ¸ãã ãã mkdir ~/diff git log | grep '^commit' | ruby -lane 'puts $F[1].strip' | ruby -lane 'arr=ARGF.to_a.map{|i|i.strip}; for i â¦
git-id-date.rb #!/usr/bin/env ruby require 'date' if ARGV.size < 1 STDERR.puts "ruby #{$0} 2011-08-15" STDERR.puts "ruby #{$0} 2011-08-15 2011-09-30" exit 1 end date_start = Date.parse(ARGV.shift) date_end = ARGV.empty? ? Date.today : Dateâ¦
ããããä¸å¯§ã«å¤æããããã«ãã --to_snake 'ShoHashimoto' => 'sho_hashimoto' 'sho_hashimoto' => 'sho_hashimoto' 'shokai' => 'shokai' 'SHOKAI' => 'shokai' 'This is a pen' => 'this_is_a_pen' 'EventMachine::HTTPRequest' => 'event_machine_httâ¦
http://ja.wikipedia.org/wiki/ã¨ã¤ãã»ã¯ã¤ã¼ã³ããã¼æ©ãã ãã©ããã¨ç¶ºéºã«ã§ããã å帰+lambda渡ãã¯å帰ãå·»ãæ»ããªãã§è¯ãã®ã§æ¸ããããã å¤ãªæ¸ãæ¹ããªãããã«ãããã©20è¡ãã£ãã #!/usr/bin/env ruby def put(size=8, queens=[], &block) bâ¦
mlab(masui lab)ã¯majan labã«ãªãã¾ããã æ¸ ä¸è²ã®é çãã¿ã¼ã³æ°ã調ã¹ãã 1ã0ã4æã2ã0ã4æ...9ã0ã4æãã§åè¨14æã«ãªãã®ãæ£ããé çãªã®ã§ããªãã°å¯è±ªçã«5é²æ°ã使ããchin-itsu.rb for i in 0..(("4"*9).to_i(5)) res = i.to_s(5) puts '0â¦
http://curb.rubyforge.org/classes/Curl/Easy.html open(out_fname, 'w+') do |out| Curl::Easy.perform(url) do |easy| easy.http_auth_types = [:basic, :digest] easy.username = 'shokai' easy.password = 'homuhomu' easy.on_body do |data| out.printâ¦
http://curb.rubyforge.org/ Ruby+Curlã§å¤§ããªãã¡ã¤ã«ããã¦ã³ãã¼ããã¤ã¤ãé度ãç£è¦ãã¦é ãã£ããåæããã ãã¦ã³ãã¼ãé度ã¯ã ãã ãä¸ãã£ã¦ãããã®ãªã®ã§ãéå§å¾ãã°ããã¯é ãã¦ãåæããªãããã«ããã æ®éã«easy performãã¦ã大éã®warâ¦
ã¿ããã«ã·ã³ãã«ã«ã§ããã®ã§æ¸ãã¦ãã ruby -e 'p 2.upto(ARGV[0].to_i).to_a.delete_if{|i| 2.upto(i/2).to_a.detect{|j|i%j == 0} }' 2000[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103â¦
sudo apt-get install mecab-ipadic-utf8 mecab Rubyãã¤ã³ãã£ã³ã°ã¯ãã£ã¦ãããã¾ãæå³ãªãæ°ãããã®ã§ã使ããªãã§ãããmecab-split-term.rb #!/usr/bin/env ruby def mecab_parse(str) `echo '#{str}' | mecab`.split(/[\r\n]/).map{|i| i.split(/\tâ¦
Rubyãå ¥ããªãããç´å¾ããããããã¨ã©ã¼ãã§ãããã«ãªã£ã openssl/ssl-internal.rb:30: [BUG] Segmentation fault openssl1.0ã¨ãªã³ã¯ããRubyããã«ããã¦ãã¾ãã¨ãããªããããã http://www.cozmixng.org/~w3ml/index.rb/rabbit-shockers/msg/793Maâ¦
cd ~ git clone https://github.com/creationix/nvm.git ~/.nvm . ~/.nvm/nvm.sh nvm install v0.6.2 nvm alias default v0.6.2[[ -s "$HOME/.nvm/nvm.sh" ]] && source "$HOME/.nvm/nvm.sh" export NODE_PATH=/usr/local/lib/node_modules:$HOME/node_modulâ¦
sinatra+mongoidã§ã http://mongoid.org/docs/installation/configuration.html ã«ããããã«mongoid.ymlãä½ã£ã¦ Mongoid.load!("path/to/your/mongoid.yml") ã§èªã¿è¾¼ã¾ãã¦ãmodelãnewããæç¹ã§"db_name must be a string or symbol (TypeError)"ãèµ·â¦
booksãã£ã¬ã¯ããªä¸ã®*.txtãå ¨ã¦æ¨æºåºåçµç±ã§rubyã®ããã°ã©ã ã«æ¸¡ãããæ cat books/*.txt | nkf -u | ruby -Ku make_dict.rb > dict.txt ããã§ããã®ã ãããã¡ã¤ã«ãå¤ã㨠"argument list too long" ã¨è¨ããã¦ãã¾ãã xargsã¨findã使ã£ããã§ãâ¦
ãã®ãsinatraã§coffee-scriptã使ã£ã¦ãã¢ããªãMac(Leopard)ã®apache2ã§åããã https://github.com/shokai/sinatra-template ã¾ãã³ã¼ãã¼ãããã brew install coffee-script gem install coffee-script which coffeenodeçãå ¥ããããã§ãèªåã§rubyâ¦