2008-01-01ãã1ã¶æéã®è¨äºä¸è¦§
Thread#interrupt()ã§ã¹ã¬ããã«å²ãè¾¼ã¿ã¾ãã (ç¹æ®ãªå ´åãã®ããã)å²ãè¾¼ã¾ããã¨ãã¹ã¬ããã®ãå²ãè¾¼ã¾ãããã©ã°ããtrueã«ãªãã¾ãã ã¹ã¬ããã§å®è¡ä¸ã®å¦çããã£ã³ã»ã«å¯è½ã§ããã°ãå®æçã«ãã®ãã©ã°ããã§ãã¯ãã¦ãtrueãªããã£ã³ã»ã«ããâ¦
next()ã§ã®ã¿ã¤ã ã¢ã¦ãããµãã¼ãããã¤ãã¬ã¼ã¿ãä½ã£ã¦ã¿ã¾ããã é常ã®java.util.Iteratorã®ã©ããã¼ã¨ãã¦ä½¿ãã 追å ã®APIã§ãããnext (long timeout, TimeUnit unit)ãã使ããã¨ã§ãã¿ã¤ã ã¢ã¦ãæå®ããã®æ¬¡è¦ç´ åå¾ãå¯è½ã§ãã ã¿ã¤ã ã¢ã¦ãæâ¦
ãµãã¯ã©ã¹ããç¶æ¿å ã¯ã©ã¹ã®APIãå¼ã³åºãã¨ãã«ä½¿ãsuperã§ãããRubyã®ãããJavaã®ãã¨ã使ã£ã¦ãã¾ãçãç®ã«ã Javaãâãããªã ããã£ã¦ã void hoge() { // ç¶æ¿ãã¨ã¯ã©ã¹ã®hoge()ãå®è¡ã super.hoge(); } Rubyã§ããªãããªã§æ¸ãã¡ããã¡ã§ãã dâ¦
ããã»ã¹ãéãã¦ãããã¡ã¤ã«ã調ã¹ãæ¹æ³ãç¥ã£ãã®ã§ã¡ã¢ããlsofãã³ãã³ãã使ãã¾ãã 以ä¸ã¯ ããã»ã¹ã26163ããéãã¦ãã ã/devãé ä¸ã®ãã¡ã¤ã« ã調ã¹ãå ´åã®ä¾ã $ lsof -p 26163 -a +d /devå®è¡çµæã§ãã COMMAND PID USER FD TYPE DEVICE â¦
Signal.trapã§ã·ã°ãã«ãéä»ãããå ´åã®å¦çãæå®ã§ãã¾ããããã使ã£ã¦ããã°ã©ã å®è¡ä¸ã«Ctrl+Cãæ¼ãããå ´å(SIGINTã®ã·ã°ãã«ãéä»ããã)ã«ç¹å¥ãªå¦çãå®è¡ã§ãã¾ãã # Ctrl + C ã§åæ¢ãããããå ´åã®å¦çãç»é² Signal.trap(:INT){ puts "SIâ¦
Deamonizeã®ã½ã¼ã¹ãããObjectSpace.each_object()ã使ãã¨ãçæããã¦ãããªãã¸ã§ã¯ãã®ä¸è¦§ãåå¾ã§ãã¾ããå¼æ°ã§ã¯ã©ã¹orã¢ã¸ã¥ã¼ã«ãæå®ããã¨ããã®ã¯ã©ã¹orã¢ã¸ã¥ã¼ã«ãç¶æ¿ãããªãã¸ã§ã¯ããåæããã¾ãã # ãã class Kitten def initializeâ¦
rubyããã°ã©ã ãdaemonã¨ãã¦å®è¡ããæ¹æ³ã«ã¤ãã¦ã deamonåã®æé deamonåã®æé ã«ã¤ãã¦ã¯ãPCè¦ãæ¸ã-ããã°ã©ã ã®ãã¼ã¢ã³åãã®è§£èª¬ã詳ããããã¤ã³ãã¯æ¬¡ã®éãã§ãã åããã»ã¹ã®çæ forké¢æ°ãå®è¡ãã¦åããã»ã¹ãçæãã親ããã»ã¹ãçµäºâ¦
Rubyã®ã©ã¤ãã©ãªã§ããã¾ã«æ¬¡ã®ãããªã³ã¼ããæå¾ã«ä»ãã¦ããã½ã¼ã¹ãè¦ããã¾ãã ... ã©ã¤ãã©ãªã®å®è£ (çç¥) if __FILE__ == $0 ... ã©ã¤ãã©ãªã®ãµã³ãã«ã³ã¼ãããããã® end ä½ãã¨æã£ãã®ã§ããããããã¦ãã㨠ã©ã¤ãã©ãªãrubyã§ç´æ¥å®è¡ããâ¦
ä»æ¥ã®ä¸å ·åãString#replaceFirstã®æ©è½ã¯ãæå®ãããæ£è¦è¡¨ç¾ã«ãããããæåã®æååãç½®æãããã§ãããæå®ãããæååã¨åãæåã®æååãç½®æãããããã§ã¯ããã¾ããããµã³ãã«ã // ããããå ´åã¯ãã¾ãç½®æããããã©ã String path = "/aâ¦
ãraise ãããå ´åãæååãã¡ãã»ã¼ã¸ã«æã¤RuntimeErrorãçºçãã¾ããJavaScriptã¿ããæååããã®ã¾ã¾é£ãã§ãããã¯ãã¾ããã begin raise "test" rescue RuntimeError puts $!.to_s end å®è¡çµæã§ãã testRuntimeErrorã¯StandardErrorã®ãµãã¯ã©â¦
Module.constantsã§ã¢ã¸ã¥ã¼ã«ã§å®ç¾©ãããå®æ°åã®ä¸è¦§ãåå¾ã§ãã¾ãã module Test FOO = 0 VAR = 1 # å®æ°: ããID KITTEN_MII = 0 KITTEN_TORA = 1 KITTEN_SHIRO = 2 KITTEN_KURO = 3 end puts Test.constants å®è¡çµæã§ãã KITTEN_SHIRO KITTEN_TORAâ¦
ã¢ã¸ã¥ã¼ã«é¢æ°ã¯ãdef . ... endãã®å½¢å¼ã§å®ç¾©ãã以å¤ã«ããModule#module_functionãã使ã£ã¦ä½æãããã¨ãå¯è½ã§ãã ãModule#module_functionãã¯Moduleã®privateé¢æ°ã§ãã å¼æ°ã¤ãã§å®è¡ããå ´åãæå®ããé¢æ°(ã·ã³ãã«ã§æå®)ãã¢ã¸ã¥ã¼ã«é¢æ°â¦
ããããèªä½ããªãã¦ããYahoo! UI Library: Profilerãªãã¦ã®ãããã¾ãã ãªãã¸ã§ã¯ããé¢æ°ããããã¡ã¤ã«å¯¾è±¡ã¨ãã¦ç»é²ãã¦ãããã¨ã§ããã®å¾ã®å¦çã§è¡ãããé¢æ°ã®å¼ã³åºããè¨é²/éè¨ãã¦ããã¾ãã åæ°ãå¹³åå¼ã³åºãæéãæ大/æå°å¼ã³åºãæâ¦
ã¤ã³ã¹ã¿ã³ã¹ã¤ãã·ã£ã©ã¤ã¶ãæå®ããã¨ãã¯ã©ã¹ã®ã¤ã³ã¹ã¿ã³ã¹çææã«ç¹å®ã®å¦çãè¡ããã¨ãã§ãã¾ãã ã¯ã©ã¹ã®ç´ä¸( class Hoge { /*ãã*/ } )ã«ã{;...}ãã®å½¢å¼ã§æ¸ãã¾ãã ã¹ã¿ãã£ãã¯ã¤ãã·ã£ã©ã¤ã¶ã¨åãããªã§ããã æå®ããå¦çã¯ããªãã¸â¦
ã³ã³ããã§ç®¡çãã¦ããã³ã³ãã¼ãã³ãã®ãããã¡ã¤ã«ãåãã¦ã¼ãã£ãªãã£ãæ¸ãã¦ã¿ã¾ãããã°ãã¼ãã«ã¤ã³ã¿ã¼ã»ãã¿ã¼ã使ã£ã¦ããã£ã¨ä½ãã¾ãã ã³ã³ããã§ç®¡çãã¦ããã³ã³ãã¼ãã³ãã®ã¡ã½ãããå¼ã³åºããåæ°ãæè¦æéãéè¨ãã¦è¡¨ç¤ºãã¾ãã ã³â¦
ã¯ãªãã¯è¨¼å¸ã«ã¢ã¯ã»ã¹ãã¦ãFXã®ã¬ã¼ããåå¾ããã¹ã¯ãªããã§ãã ClickClientãå©ç¨ãã¦ãã¯ãªãã¯è¨¼å¸WebServiceã«ã¢ã¯ã»ã¹ããã¬ã¼ããåå¾ãã¾ãã å©ç¨ã«ã¯ã¯ãªãã¯è¨¼å¸ã®ã¢ã«ã¦ã³ããå¿ è¦ã§ãã ã¬ã¼ãã¯10ç§ãã¨ã«åå¾ãå¼·å¶çµäºããã¾ã§åãã¾ãâ¦
Enumerable#injectã使ãã®ãã¹ãã¼ãããªã array = [12,343,112,55,74,11] # é åã®å¹³åå¤ãå¾ãã puts array.inject(0.0){|r,i| r+=i }/array.size # âã¯âã¨åã total = 0.0 array.each{|i| total += i} puts total / array.size å®è¡çµæã§ãã 101.16â¦
Selector Utilityã使ãã¨ãCSSã®ã»ã¬ã¯ã¿ã使ã£ã¦ããã«ãããããè¦ç´ ãæ¢ç´¢ãããã¨ãã§ãã¾ãã CSS3 Selectorã使ããã¨ã®ãã¨ã ç¹å®ã®ãã¼ããæå®ãã¦ããã®é ä¸ã対象ã«æ¤ç´¢ã§ãã¾ãã ããããããã¼ããã¹ã¦ãé åã§è¿ãã»ããæåã«è¦ã¤ãã£ãè¦â¦
Chartã使ã£ã¦CSVããæãç·ã°ã©ããä½ããµã³ãã«ã§ãã ãµã¼ãã¼ããCSVãã¡ã¤ã«ããã¦ã³ãã¼ããã¦è§£æããã°ã©ããä½æãã¾ãã Chartã®åºæ¬çãªä½¿ãæ¹ã¯ãã¡ããåç § YAHOO.widget.Chart.SWFURL = "http://yui.yahooapis.com/2.4.0/build/charts/assets/â¦
Findã使ãã¨ããã£ã¬ã¯ããªé ä¸ã®ãã¡ã¤ã«/ãã£ã¬ã¯ããªä¸è¦§ãç°¡åã«åæã§ãã¾ãã require 'find' # ./tmp 以ä¸ã®ãã¡ã¤ã«ãåæããã Find.find('./tmp') {|f| puts f } å®è¡çµæã§ãã ./tmp ./tmp/dir ./tmp/dir/c.txt ./tmp/dir/b.txt ./tmp/dir/a.tâ¦
Rubyã®ã¹ã¬ããã¯ãã¹ã¬ããåºæã®ãã¼ã¿ãæã¤ãã¨ãã§ãã¾ããThread.currentã§ç¾å¨å®è¡ä¸ã®ã¹ã¬ãããåå¾ã§ããã®ã§ãããã¨çµã¿åããã¦Javaã®ThreadLocalã®ããã«ä½¿ããã¨ãã§ãã¾ãã ts = [] 3.times{|i| ts << Thread.fork(i) {|i| # # ã¹ã¬ããåºâ¦
Futureãã¿ã¼ã³ã¯ãæéã®ãããå¦çã®éåæå®è¡ã¨å¦çå®äºã®å¾ ã¡åãããã¹ãã¼ãã«è¡ãããã®ãã¿ã¼ã³ã§ãã éåæã¹ã¬ããã®éå§ãå¾ ã¡åããå¦çããéåæå®è¡ãéå§ããé¢æ°ã¨å¼æå¸ã«é è½ãã å¼ã³åºãå´ãæéã®ãããå¦çã§ã¹ã¬ãããæèããå¿ â¦
Java5ã§è¿½å ãããStringBuilderã«ã¤ãã¦ãååã¯èãããã¨ãããã©ä½¿ã£ããã¨ã¯ãªãã£ããããã®ã§èª¿ã¹ã¦ã¿ãã以ä¸Javadocããã æåã®å¯å¤ã·ã¼ã±ã³ã¹ã表ãã¯ã©ã¹ StringBuffer ã¨ã ãããåãAPIãæ㤠ã¹ã¬ããã»ã¼ãã§ã¯ãªãã(StringBufferã¯ã¹ã¬ãâ¦
æååãã%ãå½¢å¼ã«ã¨ã¹ã±ã¼ãããé¢æ°ãæ¸ãã¾ãããã%ãå½¢å¼ã¯URLã¨ã³ã³ã¼ãã§ä½¿ãããã¨ã¹ã±ã¼ãã®æ¹å¼ã§ããURLã¨ã³ã³ã¼ãã§ã¯aã¨ãbã¨ãURLã§ä½¿ããæååãã¨ã¹ã±ã¼ãããå¿ è¦ã¯ããã¾ãããããã®é¢æ°ã¯ãã¹ã¦ã®æååã容赦ãªãã¨ã¹ã±ã¼ããã¾ããâ¦
JSLintã¨ããJavaScriptã®æ¤è¨¼å¨ãçºè¦ããã®ã§ãæ©éContainerJSããã§ãã¯ãã¦ã¿ã¾ãããWebUIãç¨æããã¦ããã®ã§ã½ã¼ã¹ã³ã¼ããã³ãããã¦ãã¿ã³ãæ¼ãã ããç°¡åã«ä½¿ãã¾ããã§ã以ä¸ãè¦ã¤ãã£ãä¸å ·åã è¡ã®çµããã«ã»ãã³ãã³ããªãã ãªã«ãã«çµâ¦
JavaScriptã®ã³ã¡ã³ããæãåºãããã°ã©ã ãæ¸ãã¦ã¿ã¾ãããstrscanã使ãã¨ããã£ã¨ã§ãã¾ãã require 'strscan' require 'kconv' class Tokenizer def tokenize(str) tokens = [] s = StringScanner.new( str ) while ( !s.eos? ) if ( s.scan( /\/\*((â¦
çµã¿è¾¼ã¿é¢æ°ã®sprintfã使ãã¨ç°¡åã«å®ç¾å¯è½ã§ããå ·ä½çã«ã¯æ¬¡ã®ããã«ãã¾ãã f = 108.233533 puts sprintf( "%.3f", f ) å®è¡çµæã§ã 108.234"%.3f"ã®é¨åãåºåãã©ã¼ããããæå®ãã¦ããé¨åã§ã以ä¸ã®å½¢å¼ã§æ¸ãã¾ãã(Rubyãªãã¡ã¬ã³ã¹ããã¥ã¢â¦
ã¹ã¬ããéã§å¦çã®å®äºãå¾ ã¡ããããã«ã¯ãConditionVariableãå©ç¨ãã¾ããConditionVariableã¯Javaã®ã¦ã§ã¤ãã»ãã(Object#wait,notify,notifyAllã使ã£ã¦è¡ãã¢ã¬ã)ã®ãããªæ©è½ãæä¾ããã¯ã©ã¹ã§ããããå©ç¨ãã¦ã¹ã¬ããéã§ã®å¾ ã¡åããæ©æ§(Guarâ¦
tmpdirãrequireããã¨ãDirã¯ã©ã¹ã«ä¸æãã¡ã¤ã«ãã£ã¬ã¯ããªãåå¾ããAPIã追å ããã¾ãã require 'tmpdir' # ä¸æãã£ã¬ã¯ããªãåå¾ããé¢æ°ã追å ãããã puts Dir.tmpdir å®è¡çµæã§ãã(Windowsç°å¢) /cygdrive/c/DOCUME~1/<ã¦ã¼ã¶ã¼å>/LOCALS~1/â¦
timeoutã使ãã¨ãä»»æã®å¦çã®å®è¡æéããã§ãã¯ããæå®æéããªã¼ãã¼ããå ´åä¾å¤ãçºçããããã¨ãã§ãã¾ãã require 'timeout' # 0.1ç§ä»¥å ã«å¦çãçµãããªãå ´åãã¿ã¤ã ã¢ã¦ãããã timeout(0.1) { sleep 1 puts "end" } å®è¡çµæã§ãã xxx/tiâ¦