ruby
å æ¥ãããã°æ¸ããä¸èª¿ãã¨æ¸ããããè¨èªã®ã¢ã¦ãããããä¸èª¿ãªã¨ãã¯ããã以å¤ã®ãã¨ãããã«éã...ãã¨ãã°é»ã ã¨ããã°ã©ã ãæ¸ããé³æ¥½ã«æµ¸ãã身ä½ãé ·ä½¿ããããªã©ã ãã¨ããããã§æææ¥ã天æ°ã¯æ´ããªãã£ããã®ã®ãç 究ã®ãã¼ã¿å¦çã«ä½¿ãRubyâ¦
404 Blog Not Found:ããæ°ã£ã¦ã©ãã§ããæ°? çµç±ã§è¦ã¤ããâã®è¨äºã 1ãã100ã¾ã§ã®æ°ãããªã³ãããããã°ã©ã ãæ¸ãããã ã3ã®åæ°ã®ã¨ãã¯æ°ã®ä»£ããã«ï½¢Fizzï½£ã¨ã5ã®åæ°ã®ã¨ãã¯ï½¢Buzzï½£ã¨ããªã³ããã3ã¨5両æ¹ã®åæ°ã®å ´åã«ã¯ï½¢FizzBuzzï½£ã¨ããªã³ããâ¦
CSVãèªãæ¹æ³ãæ¸ãæ¹æ³ããã®ã¬ã·ãã¯ãã使ããããªã®ã§è¦ãã¦ãããã Rubyã§CSVãèªã¿è¾¼ã require 'csv' CSV.parse("data.csv"){|row| p row } Rubyã§CSVãåºå ä¸è¨åç §ãwritterãå¼ã¶ã®ã¯ä¸åº¦ã ãã£ã½ãã ä»¥ä¸ Rubyã¬ã·ããã㯠第2ç 268ã®æä½è â¦
ãããæååãæ£è¦è¡¨ç¾ã§æå®ãã¦ã""ã§ç½®æãããã¨ããèãæ¹ãsub!ãããã¯gsub!ã使ãã sub系㯠第ä¸å¼æ°ã§æ£è¦è¡¨ç¾ã/hogehoge/ããããã¯ç¹å®ã®æååã"hogehoge"ã 第äºå¼æ°ã§ç½®æå ã®æåå æå®ããä½ç½®ã«æååãæ¿å ¥ããæ¹æ³ãã str.sub!(/\Aâ¦
Rubistã¨ãã¦ç²¾é²ãããããRubyã¬ã·ããã㯠第2ç 268ã®æã®ã¬ã·ãã®ãã¡ å¿ è¦ã«è¿«ãã㦠æåããé ã«ãåå¼·ã¨ã㦠使ç¨/å®è·µãããã®ãããã°ã«ããã¦ãããåå¿é²ãç¶ç¶ã®ããã®å ¬éã¨ããç¨éã®ä»ã«ããããååå¼·ããã®ã«â¦ãã¨ããå 容ãããã°å ãµã¼â¦
ããRailsã¯ã¤ã³ã¹ãã¼ã«ãã¦ãã(d:id:Hash:20071009)ã®ã ããããè¨äºãã¿ã¤ãããMacã§Ruby on Railsãå§ãããªããããã£ã¨ãã大ä¸å¤«ã£ã½ããªãMacã«Railsãã¼ãããã¤ã³ã¹ãã¼ã«ããä¸çªç°¡åãªæ¹æ³:Kenn's Clairvoyance - CNET Japanã§ãæå¾ã«ã¡ã³ãâ¦
é åaryã«ãã¼ã¿ãæºãã¦ãã£ã¦ãæå¾ã«ã¾ã¨ãã¦Hashã«ãã¦ãã¾ããkeyã¨valueã交äºã«æºãã¦ãããã¨ã count = 0 ary = [] for i in 0..10 do count += 1 ary << count ary << "hogeNo.#{count}" end newhash = Hash[*ary] > newhash[5] => hogeNo.5 ã¨ãâ¦
åã¯Rubyã好ãã ããæ¬è³ª*1ããã¯é ãã¨èªè¦ãã¦ãããå人ã«ãjavaããã¨ããããã¨å§ããããã Javaé£å¶ã¯2003å¹´é ãããEase of Developmentï¼EoDï¼ãã¨ããæ¨èªãæã¡åºãã¦ãã§ããéãã·ã³ãã«ãªããã°ã©ãã³ã°ãå®ç¾ãããã¨ãæè¨ãããã®æ¹åæ§ã¯â¦
å¿ è¦ãªããã°ã©ã ã好ããªããã«ä½ããªããæããããã°ã©ãã³ã°ã®ç·´ç¿ããã»ã¹ã«ããã¦ããã¯ã©ã¹ã®å©ç¨ããä¸ã¤ã®å£ãªããããªããããã ã¡ã¢ hoge = 2 def double(num) puts num*hoge end >double(100) => in `double': undefined local variable or metâ¦
å¯ãã¦æãåããªã⦠ã¹ãã³ã³ã§è¨ç®ãããã¨ãããã¥ã¼ãæå®ãããã¨ãã§ãããè¨ç®ã®å®è¡ã«ã¯é·ã ã¨ã³ãã³ããæ¸ããã°ãªããªãã®ã§ãé©å½ã«Rubyã§ã¹ã¯ãªãããæ¸ãã¦ãå¼æ°ã§ãï¼ããã¨ãã°ã空ãã¦ããã¥ã¼ã«è¨ç®ãæããããè¨å®ã«ããï¼ã¤ããã ã£ãâ¦
Rubyãããããããã£ã¦åå¼·ãæ·±ããªRubyã¯ãå¤åé常ã«åæ©çãªãã¨ãªã®ã ããæ°ã¥ãããã¨ãã¡ã¢çã«æ¸ããææ¥ã¯è¨ç®ç³»ã®RMSDããªããä¸å®å®ãªæ ¹æ ãæ¢ããã Rubyããã·ã§ã«ã³ãã³ã %x{}ã§å²ãã°ãããããã¯ã¯ãªã¼ãã§ãããã(backticksã¨ãã)ãããâ¦
ç 究室ã§ã¡ãã£ã¨ããããã°ã©ã ã使ãå¿ è¦ãåºããã®ã§ä½ã£ããPDBãã¡ã¤ã«ã®ç¹å®ã®æ®åºåãæ¸ãæããå¾ãAMBERããã±ã¼ã¸ã使ã£ã¦é©åãªæ§é ã«ç´ãã¦ãååååå¦è¨ç®(MDè¨ç®)ãè¡ãããã®PDBãã¡ã¤ã«ã®æ¸ãæããèªåã§ãã£ã¦ãããããã°ã©ã ï¼PDBãæâ¦
suã®å¾ã®ãã¹ã¯ã¼ããéããªãããªãã
rtfãã¡ã¤ã«ã§ã¼ãè³æãæ¸ãã¦ããæã ãå³2-3ã ããã£ãã·ã§ã³ã¨æ¬æãããã¹ã¦æ¤ç´¢ã㦠ãå³2-4ã ã«ãããã以éã®å³2-4ãå³2-5ãã©ãããã«ç½®ãæãããã JeditXã§ã¯æ£è¦è¡¨ç¾ã®æ¤ç´¢ã¯ã§ãããããããä¿åãã¦æ°å¤ã«å¤æãã¦ãã©ã¹ï¼ï¼ã¨ããå¦çã¯â¦
RubyOSAãè½ã¨ãããGem使ã£ã¦installã§ããªãã£ãããªãã§ã ã¾ã 使ã£ã¦ãªããããé常ã«wktkä¸ãRubyOSA: Ruby/AppleEvent BridgeWord2004ãæä½ããã¹ã¯ãªãããä½ã£ã¦ãï¼æã ããã§ã¯ãªããç 究ã®ã¹ãã¬ã¹çºæ£ã«ï¼ã AppleScriptã ãã使ã£ã¦ä½ãã®ã¯å¤§â¦
.bash_profileã§PATHéã å æ¥PATHã®è¨å®ãããããªãã£ãã .bash_profileå ã« export PATH=$PATH:/usr/local/bin:/opt/local/bin export MANPATH=$MANPATH:/opt/local/share/man ã¨è¨è¿°ããã°ãããportç¨ã¨ãlocalã«å ¥ããããããç¨ã MySQLã®ããã $ sâ¦
å¤ã«ç¨¼ãã éã®ä¸é¨ã§ä¸å¤ã®iBook G4 12inchãè²·ããï¼å¹´åã®ã¢ãã«ã ããã¦ã¼ã¶ã¼ã¤ã³ã¿ã¼ãã§ã¤ã¹ã®å å®ã«ã³ã£ãããwindowsããæç¶å¥½ãã ãUNIXè²ãã®Terminalãæä½ããããã¦ãããããã§ãä¸æ©ä¸è¨å®ã«å¥èµ°ãã¦ãããã¾ãTerminalã®è¨å®ããã.bashrcâ¦
Ruby翻訳è¨ç»ããã¢ã«ã´ãªãºã ãå¦ã¶ä¸ã§èªåçGoal㯠æ°ç¬è§£çããã°ã©ã ã©ã¤ãã¢ã¦ã解çããã°ã©ã ãä½ããã¨ãããããèªåã§çµã¿ç«ã¦ããããåãä»ããã¨å¤æãã©ã¤ãã¢ã¦ãã¨ã¯æããã£ãã²ã¼ã ãWikipedhiaã«é ç®ããã£ã¦ã³ã³ã£ã æè¿è²·ã£ãã®ã§â¦
itochanããã«å©è¨ãããã½ãããã³ã¯ã¯ãªã¨ã¤ãã£ã社ã«ãã®Rubyç¿»è¨³å ¬éã®æ¯éãåãã¦ã¿ããæ´ç°ææ´æ°ã«è©±ãéãã¦ããããããããã許å¯ãã¾ããã¨è¨±å¯ãããã ãã¾ãããã®ã§ãå 容ã«ããããã触ãã¤ã¤ãããã翻訳ãã¦ãããã ä¾ã®å¦ãå ¨ã¦è¦ãã«â¦
ãã®æ¬ã®å 容ãæ¼ç¿åé¡ãã¡ã¤ã³ã«Rubyã«ç¿»è¨³ãã¦ãããã æ¼ç¿1,2ã¯ç°¡åãããã®ã§3ãã10ã¾ã§ããç¶ããèªããã¯ãªãã¯ããã°æå¾ã¾ã§åºãã èè ã®æ´ç°ããã«ã«è¨±å¯ã¨ããã¨æã£ããã©ãæå人ãããã®ãæ¬ã«ã¯ã¢ãã¬ã¹å ¬éãã¦ãªããã°ã°ãã¨å¾æ´ä¼HPã«â¦
id:niraikanaibirdããã®ã¨ãã§çºè¦ã visualã¢ã¼ãã§å®è¡ãããã³ã¼ããé¸æã㦠:'w !ruby vimãããã£ã¬ã¯ã㪠ã:cdãã:pwdãã使ãããã«ã¬ã³ããã£ã¬ã¯ããªå¤æ´æ¹æ³ãåãã£ã¦å¹¸ããset HOME=C:\hogehogeã§è¨å®ã§ããã®ã
Rubyæ¸ãã¨ãã«ãWindowsã®ã¡ãªãããçãããã¨ãHTMLHelpãå ¥ãã¦ã¿ããid:secondlifeãããé å¸ãã¦ãCSSã綺éºã§ãæ°ã«å ¥ã£ãã
çµé¨ä¸è¶³ãææãããã®ã§å°å³ãªç·´ç¿ããã£ããããã å ã®åºæ¬ã¢ã«ã´ãªãºã ãRubyã¹ã¯ãªããã«ç¿»è¨³ãããæµç³ã«å ¨é¨å¤ä¼ã¿ä¸ã«ã¯ç¡çã ãã Ruby ã§ã¢ã«ã´ãªãºã çãåããçãªãã®ãå®ã¯ã¤ã³ã¿ã¼ã³ä¸ããä¸è©±ã«ãªï¼ry ãã¨ãDave Thomasã®Rubyæ¬ãåèã§â¦
ã¡ã¤ã³ã§ä½¿ã£ãFlickr以å¤ã®APIãããã£ã¦ã¿ãã ã¯ã¦ãªã¦ã§ããµã¼ãã¹ ããã«è²ã APIã¸ã®ãªã³ã¯ãã 人åæ¤ç´¢ã¯ã¦ãªãã¨ãªã質åAPI ã¯ã¦ãªexistAPI ã¯ã¦ãªããã¯ãã¼ã¯AtomAPI ã¯ã¦ãªããã¯ãã¼ã¯ä»¶æ°åå¾API ã¯ã¦ãªãã¼ã¯ã¼ãAPI ã¯ã¦ãªãã¤ã¢ãªã¼ãã¼ã¯â¦
sth.rhtmlã¯ç©ºã£ã½ã§ãsth.rbã§open("../sth.rhtml", "w")ãã¦{|io|ããï¼ãã¨æ¸ãè¾¼ãã§ãããprintã§HTML表è¨ï¼ãã¢ããã¥ã¡ã³ã使ãï¼éä¸ã§EOLãã¦MySQLãäºåãå¦çãã¦çµæ(s)ããæå¾ã«ãçæããsth.(r)htmlã«é£ã¶ã print cgi.header( { 'Status' =â¦
Rubyã®åºç¤ããå§ã¾ã...ãMySQL, MySQL/Ruby, CGI, HTML, CSS, eRubyãããã ã¢ããã§å©ãè¾¼ã¾ãããç²æ«ãªãããWebã¢ããªãä½ãã¾ã§ã«ãªã£ãã eRubyã¨CGIã®ãã©ã³ã¹ãé£ãããéçããã¦ãã ãããããã¡ãã¡rhtmlã§ä½ããªããã®ããå¿ è¦æ§ã¨ç¸è«ããªãâ¦
Rubyã¹ã¯ãªããå ã«mysqlãrequireããã¯ã¨ãªæãåãè¾¼ãã§ä½¿ç¨ããã ã¯ã¨ãªæã¯Myèªä½ã§è©¦è¡é¯èª¤ããã§ãããã®ãã³ãã require 'mysql' begin myh = Mysql.init myh.options (Mysql::SET_CHARSET_NAME, 'utf8') #æ¥æ¬èªã«å¯¾å¿ããã myh.connect('localâ¦
åã«ãã¡ã¢ã£ãæ°ãããã Ruby/MySQLã¯Rubyã§è¨è¿°ãããï¼pure rubyï¼MySQLã®Ruby API*1. MySQL/Rubyã¨ã»ã¼äºæãæ¯è¼ã¯ãã¡ã Ruby/MySQLâ¦Rubyã«ãããMySQLã¯ã©ã¹ã®æä½ãã *1:ãAPI(Application Program Interface)ãè¦ç´ã«å¾ã£ã¦ãã®æ©è½ããå¼ã³åºãâ¦
Rubyã§CGI*1æ¸ãã¦ããããã®å¤å´ãHTMLã«ããªãããªãããeRuby(embedded Ruby)ã¯ããã¹ããã¡ã¤ã«ï¼ä¾ãã°HTMLï¼ã«Rubyã®ã³ã¼ããåãè¾¼ãããã®âè¨èªâãRuby_script_fragment%>ã¿ããã«*2ã eRubyã解éããã«ã¯ãerubyï¼âå°æåï¼ãå¿ è¦ã Ruby Earringsâ¦
each_index {|index| .... } åè¦ç´ ã®ã¤ã³ããã¯ã¹ã«å¯¾ãã¦ãããã¯ãè©ä¾¡ãã¾ãã 以ä¸ã¨åãã§ãã (0 ... ary.size).each {|index| .... } self ãè¿ãã¾ãã å·¦å¼ while å³å¼ å³è¾ºã®å¼ãè©ä¾¡ããå¤ãçã®éã左辺ãç¹°ãè¿ãå®è¡ãã¾ãã 左辺ã®å¼ã rescâ¦