2008-08-01ãã1ã¶æéã®è¨äºä¸è¦§
as3corelibã§æä¾ããã¦ããJSONã¦ã¼ãã£ãªãã£ã使ã£ã¦ãJSONã®ã¨ã³ã³ã¼ãã¨ãã³ã¼ããè¡ããµã³ãã«ã§ãã package { import flash.display.*; import flash.text.*; import com.adobe.serialization.json.JSON; public class JsonSample extends Sprite { â¦
Flex SDK 3.1.0ããã¦ã³ãã¼ãããã¨ãflexTasksãªãAntã¿ã¹ã¯ãæ·»ä»ããã¦ããã®ã§ããããå©ç¨ãã¦ã®mxmlã®ã³ã³ãã¤ã«ã試ãã¦ã¿ã¾ããã以ä¸ãæé ã®ã¡ã¢ã§ãã 1.flexTasks.jarãAntã®ã©ã¤ãã©ãªã«è¿½å ããã Flex SDKã®ã¢ã¼ã«ã¤ããå±éãããã£ã¬ã¯ãâ¦
Rubyãªãã¡ã¬ã³ã¹ããã¥ã¢ã« ã»ãã¥ãªãã£ã¢ãã«ããããProcã¯ãã®æç¹ã§ã®ã»ã¼ãã¬ãã«ãè¨æ¶ããããã®Procãªãã¸ã§ã¯ããcallãããã¨ã è¨æ¶ãã¦ããã»ã¼ãã¬ãã«ã§å®è¡ãããããã¨ã®ãã¨ã # ã»ã¼ãã¬ãã«0ã§ä½ã£ãproc p0 = proc { $SAFE } # ã»ã¼ãâ¦
keita_yamaguchi ãããããææ°ã®Rubyã§ã¯æ±æç¶æ ã«ããã¡ã½ããå¼ã³åºãã®å¶éãä¿®æ£ããã¦ããã¨ã®æ å ±ãé ããã®ã§(ãããã¨ããããã¾ã!)ãææ°ã®Rubyãã¤ã³ã¹ãã¼ã«ãã¦è©¦ãã¦ã¿ã¾ããã $ ruby -v ruby 1.8.7 (2008-08-11 patchlevel 72) [i386-cygâ¦
注 (2008-08-28) ææ°ã®Ruby(1.8.7-p72)ã§ã¯ã¡ã½ããå¼ã³åºãå¶éã®åä½ãä¿®æ£ããã¦ãã¾ããææ°ã®ç°å¢ã§ã®å¶é表ã¯ãç¶ æ±æãããã¯ã©ã¹ã®å©ç¨ãåç §ãã ããã æ±æãããã¯ã©ã¹ã®å©ç¨ã«ã¤ãã¦ãæ°ã«ãªã£ã¦ãããã¨ã®æ¤è¨¼çµæãã¾ã¨ããã ã¯ã©ã¹ã®æ±æ â¦
ãã£ã±ããã¡ããã¨æ¸¬ã£ã¦ã¿ããããªãã¨ãããã¨ã§ãããã°ã©ã ä¸ã§ç»åãæãçµããã¾ã§(=graphics.drawRectãctx.fillRectãã復帰ããã¾ã§)ã®å¦çæéãåºåããããã«ãã¦ã¿ã¾ããã âFlashã§æã âCanvas+JavaScriptã§æã(ExplorerCanvasãè¨å®æ¸ã¿ãâ¦
Flashã¨Canvas+JavaScriptã®ã©ã£ã¡ãæç»ãæ©ãããåè§ã16*16*16=4096åæãã¹ã¯ãªãããæ¸ãã¦è©¦ãã¦ã¿ã¾ããã âFlashã§æã âCanvas+JavaScriptã§æã(ExplorerCanvasãè¨å®æ¸ã¿ãIEã§ãè¦ãã¾ãã) ã¡ããã¨ã¯è¨ã£ã¦ãªããã©ãä½åããªãã¼ããã¦è©¦ãâ¦
Rubyã«æ¨æºæ·»ä»ããã¦ããCSVã©ã¤ãã©ãªã§ããããªãã追è¨ããµãã¼ãããã¦ããªããããªã®ã§ã¡ãã£ã¨æ¹é ãã¦ã¿ã¾ããã以ä¸ã®ã³ã¼ãããã¼ãããã¨ãCSV.openã®modeã¨ãã¦ãaã,ãabããæå®ã§ããããã«ãªãã¾ãã require 'csv' # 追è¨ããµãã¼ããããâ¦
apacheã¨åããã·ã³ã®8080ãã¼ãã§åä½ãã¦ããWebrickãµã¼ãã¼ã«å¤é¨ããapacheçµç±ã§ã¢ã¯ã»ã¹ã§ããããã«ããããã¨ãããã¨ã§mod_proxyã§apacheããªãã¼ã¹ãããã·ã«ããã以ä¸ã¯ã ãhttp:///foo/ãã«ã¢ã¯ã»ã¹ãããå ´åã«ã apacheã¨åããã·ã³ã®8080â¦
âã¿ãããªããããã¯ã§å¦çãåãåã£ã¦ããã°ã¤ã³ãã¦å®è¡ããAPIããã£ã¦ã # ãã°ã¤ã³ãã¦ä½ããã def do_as( user ) begin # ãã°ã¤ã³ãã¦.. puts "login as #{user}" # ãããã¯ã®å¦çãå®è¡ # å¼æ°ã¨ãã¦ã»ãã·ã§ã³IDã渡ã yield "sid-#{user}" ensuâ¦
Class.newã§ååã®ä»ãã¦ããªãã¯ã©ã¹ãåçã«ä½æã§ãã¾ãã # ç¡åã®ã¯ã©ã¹ãæ°è¦ä½æ kitten = Class.new # ã¡ã½ãããmeow!ãã追å ã(define_methodã¯privateã¡ã½ãããªã®ã§ç´æ¥ã¯å¼ã³åºããªãã) kitten.send(:define_method, :meow) {|i| puts "meow!â¦
Rubyã§ã¯ã©ã¹ã®ããããããã¤ããµãã¼ãããã«ã¯ã©ããã£ãæ¹æ³ãããããªãã¨èãã¦ã¿ãã æ¡1:evalã使ã ããããRubyã§ã¯ããã¼ãæ¸ã¿ã¯ã©ã¹ãå¾ããæ¸ãæãããã¨ãã£ããã¨ãå¯è½ãªã®ã§åç´ãªæ段ã¨ãã¦ã¯æ°ããã¯ã©ã¹ãæ¸ãããæååãèªã¿è¾¼ãã§eâ¦
succãªããã®ãè¦ã¤ããã i = 10 puts i.succ # 次ã®æ´æ°ãè¿ã å®è¡çµæã§ãã 11ãªãã ã¼ããã㧠i += 1 ã¨ãããªãã¦ãããããããã¨ãæã£ããã©ããInteger#succ!ãã¯ãªãã®ãã»ã»ã»ãNumeric é¢é£ã¯ã©ã¹ã¯immutableã¨ã®ãã¨(âIntegerãã)ããµããâ¦
ãµã¼ãã¹ã¢ãã«ãæå®ãããã¨ã§ãNeedleã®ã¬ã¸ã¹ããªã«ç»é²ãããµã¼ãã¹ã®çæã¿ã¤ãã³ã°ãå¶å¾¡ã§ãã¾ãã æå®å¯è½ãªãµã¼ãã¹ã¢ãã«ã¨ãã¦ã¯ä»¥ä¸ã®ãããªãã®ãç¨æããã¦ãã¾ãã :singleton 常ã«åãã¤ã³ã¹ã¿ã³ã¹ãè¿ãã :prototype ãªã¯ã¨ã¹ãã®ãã³ã«â¦
Javaã®ã³ã¬ã¯ã·ã§ã³ãã¬ã¼ã ã¯ã¼ã¯ã§ããªãã¿ã®Setã§ãããRubyã§ã¯æ·»ä»ã©ã¤ãã©ãªã¨ãã¦æä¾ããã¦ãã¾ãã require 'set' # Setãä½ãã # å¼æ°ã§Enumerableãæå®ã§ãããã®è¦ç´ ãSetã«è¿½å ãããã set = Set.new(["a","b","c"]) #set = Set["a","b","c"â¦
ä¾ãã°ãã¹ãããããªã¹ããä½æããå ´åã List<List<String>> nested = new ArrayList<List<String>>(); List<String> list1 = new ArrayList<String>(); list1.add( "a" ); list1.add( "b" ); list1.add( "c" ); nested.add(list1); List<String> list2 = new ArrayList<String>(); list2.add( "d" ); list2.add( "e"</string></string></string></string></list<string></list<string>â¦
ãexec:javaãã§OKã http://repo1.maven.org/maven2ã§é å¸ããã¦ããã®ã§ãç¹ã«ã¤ã³ã¹ãã¼ã«ã¨ããªãã«ä½¿ãã¾ãã http://repo1.maven.org/maven2/org/codehaus/mojo/exec-maven-plugin/ããã©ã°ã¤ã³ã ãªãã·ã§ã³ã§ã¡ã¤ã³ã¯ã©ã¹ã¨å¼æ°ãæå®ãã¾ãã $ mvnâ¦
<ç¶æ¿å ã®å> { <追å ã®å®ç¾©...> }ã§ãç¶æ¿å ã®åã«åè´ããããã«è¿½å ã®å®ç¾©ãæã¤åãä½æ?ã§ãã¾ããä¾ãã° // Catæ´¾çã§ãã¤meowã¡ã½ãããæã¤ä½ããå¼æ°ã¨ãã¦åãä»ããé¢æ° def meow( foo: Cat { def meow:Unit } ) = { foo.meow } ã¿ãããªCompoundâ¦
æå®ãã£ã¬ã¯ããªé ä¸ã®jarãã¡ã¤ã«ãããdeprecatedãªJavaã¯ã©ã¹ãæ¢ãã¹ã¯ãªãããæ¸ãã¾ãããjavaclassã使ã£ã¦ã¾ãã #!/usr/bin/ruby # å¼æ°ã§æå®ãããã£ã¬ã¯ããªé ä¸ã®jarããdeprecatedãªJavaã¯ã©ã¹ãæ¢ã # # 使ãæ¹: ./find_deprecated.rb <æ¢ç´¢â¦
å é±ã«å¼ãç¶ããä»é±ãå³ããæãã§ãããªã¢ã«ããã¨ãããã¨ã§ãå°ãããç¶ãã¾ããã容赦ã(ããããå°ããã ããã ãã¼ãã¨ãã話ãããã¾ããã)
rubyã®nilã¯ãªãã¸ã§ã¯ãã§ãããªã®ã§Objectã®APIã使ãã¾ãã puts nil.to_s puts nil.object_id puts nil.hash å®è¡çµæã§ãã 4 4
ãã¾ããã ãã©ãuntilãªãã¦ãã£ããã ã¼ã # until # æ¡ä»¶ãtrueã«ãªãã¾ã§å¦çãç¹°ãè¿ãã i = 0 until i >= 3 puts i+=1 end puts "---" # 修飾åã¨ãã¦ã使ããã i = 0 puts i+=1 until i >= 3 å®è¡çµæã§ãã 1 2 3 --- 1 2 3unlessã¨ç©ºç®ãã¦ãå¯è½â¦
remove_constã§ã¢ã¸ã¥ã¼ã«ããã¯ã©ã¹å®ç¾©ãæ¶ããã¨ãã§ãã¾ãã module Test class Foo; end end # ã¯ã©ã¹å®ç¾©ãæ¶ãã # remove_constã¯privateã¡ã½ãããªã®ã§sendã§éãã Test.send(:remove_const, :Foo) # æ¶ãããã¯ã©ã¹ã¯å©ç¨ã§ããªããªãã begin Teâ¦
ã»ã¼ãã¬ãã«4ã§ã¯ãããã¬ãã«ã¸ã®ã¯ã©ã¹ã®è¿½å ã¯ã§ãã¾ããããæ±ããã¢ã¸ã¥ã¼ã«ãç¨æãã¦ããã«è¿½å ãããã¨ã¯å¯è½ã§ãã # ãããã¯ãå®è¡ããSecurityErrorã¨ãªãã®ã確èªããã def expects_security_error begin yield if block_given? raise "æå¾ â¦
Rubyãªãã¡ã¬ã³ã¹ããã¥ã¢ã« - ã»ãã¥ãªãã£ã¢ãã«ãããRubyã§ã¯ãã»ã¼ãã¬ãã«ã«ããã¹ã¬ãããå®è¡å¯è½ãªæä½ãå¶éããã¾ãã ã»ã¼ãã¬ãã« ã¹ã¬ããã®ã»ãã¥ãªãã£ã¬ãã«ã示ãå¤ã0ãã4ã¾ã§ãããåºæ¬çã«æ°ã大ãããªãã»ã©å¶éãå¢ããã ã¹ã¬ããâ¦
ã¢ããã¼ã·ã§ã³ã使ã£ã¦ã·ãªã¢ã©ã¤ã¶ãã«ã§ãããã¨ãæ示ã§ãã¾ãã // ã¢ããã¼ã·ã§ã³ã使ã£ã¦ã·ãªã¢ã©ã¤ã¶ãã«ã§ãããã¨ãæ示 @serializable class Foo {} // âã¯âã¨åã class Var extends java.io.Serializable {} // ç¢ºèª println( "Foo: " + new Foâ¦
Function#chainã§è¤æ°ã®é¢æ°ãé£çµãã¦ã1ã¤ã®é¢æ°ã«ã§ãã¾ãã // é£çµããé¢æ°ã®é å var fs = Array( (i:Int)=>i+2, (i:Int)=>i*3, (i:Int)=>i-2) // é£çµããé¢æ°ãå®è¡ã println( Function.chain(fs)(4) ) å®è¡çµæã§ãã 16
existsãç°¡åã val array = Array("a", "b", "c") if ( array.exists( i=> "a".equals(i) ) ) println( "exist" ) else println( "not exist" ) findãã¦ãisEmptyã§è©ä¾¡ããã¨ãã if ( array.find( i=> "a".equals(i) ).isEmpty ) println( "not exist" )â¦
Scala ã§ãã*ãã使ãã¾ã! println( "a"*20 ) å®è¡çµæã§ãã aaaaaaaaaaaaaaaaaaaa
WEBrickã®HTTPãµã¼ãã¼ã¯ãã:ServerTypeãè¨å®å¤ã¨ãã¦ãWEBrick::Daemonããæå®ããã¨ãdaemonã¨ãã¦åä½ããããã«ãªãã¾ããå ·ä½çã«ã¯âã®ãããªæãã # httpãµã¼ãã¼ s = HTTPServer.new( :Port => 8080 :ServerType=>WEBrick::Daemon ) å¾ã¯æ®éã«ãµâ¦