2007-05-01ãã1ã¶æéã®è¨äºä¸è¦§
select ã® from ã«ãã¼ãã«ã並ã¹ãã¨ããã¼ãã«å士ãç·å½ããã§çµåããã¾ããããã«whereã§æ¤ç´¢æ¡ä»¶ãæå®ãã¦çµãè¾¼ãã¨ãå é¨çµåããå ´åã¨åããããªåºåãå¾ããã¨ãã§ãã¾ãã çµåãããã¼ãã« mysql> select * from kittens; +----+-------+-----â¦
JDI(Java Debug Interface)ã§ã¹ã¬ãããã³ããã¨ãã¾ãã JDIã¯ããã®åã®éããä»®æ³ãã·ã³ã®ãããã¬ãé¡ä¼¼ã·ã¹ãã ã«æç¨ãªæ å ±ãæä¾ããJava API ã§ãã ãªã¢ã¼ãããã®ãããã°ãæ¨æºã§ãµãã¼ããã¦ãã¾ãã JDKæ·»ä»ã§ãããå®è£ ã¯tools.jarå ã«ããã¾â¦
YAMLã§ã¯ãåç §ã使ãã¾ãã(åç §ãããå´ãã¢ã³ã«ã¼ãåç §ããå´ãã¨ã¤ãªã¢ã¹ã¨ããã¾ãã)YAML(kitten.yml): --- strains: - &mike # "&<ã¢ã³ã«ã¼å>"ã§ã¢ã³ã«ã¼ãè¨å® name: "ä¸æ¯" description: "è¶è²ã»é»ã»ç½ã®3è²æ¨¡æ§ã§ãã" - &scottish-fold name: "â¦
FreeMarkerã¯æ±ç¨ãã³ãã¬ã¼ãã¨ã³ã¸ã³ã§ãã ã¢ãã« + ãã³ãã¬ã¼ã â åºå ã¢ãã«ã«ã¯ä»»æã®ãªãã¸ã§ã¯ããæå®å¯è½ãã¢ãã«ã®ã¡ã½ãããå¼ã³åºããçµæãåºåãããã¨ãã§ãã¾ãã ãã®ä»ãåºæ¬çãªå¶å¾¡æ§æ(forãif)ããµãã¼ãã ãµã³ãã«(æååã¨æ°åâ¦
JDKæ·»ä»ã®ã¢ããã¼ã·ã§ã³å¦çãã¼ã«ãaptãã使ã£ã¦ã¿ã¾ãããããå©ç¨ãã¦ã ãµã¼ãã¼APIã«å¯¾å¿ããã¯ã©ã¤ã¢ã³ãã¤ã³ã¿ã¼ãã§ã¤ã¹ãä½ã ã¢ããã¼ã·ã§ã³ã§ç¤ºããããµã¼ãã¹ã®ä¸è¦§ãä½ã ãªã©ã¢ããã¼ã·ã§ã³ãå ã«ããã½ã¼ã¹ã³ã¼ãããªã½ã¼ã¹ã®çæãå¯è½ã§â¦
transactionãå©ç¨ãã¦ãä¸é£ã®æ´æ°å¦çãã¢ãããã¯ã«å®è¡ãã¾ãã ãã©ã³ã¶ã¯ã·ã§ã³ã使ã ãã¼ãã«å®ç¾©: CREATE TABLE kittens ( id int(11) NOT NULL auto_increment PRIMARY KEY, name VARCHAR(255), color VARCHAR(255), age int(4) ) TYPE = InnoDB ;â¦
Generic typeä»ãã¤ã³ã¹ã¿ã³ã¹ãã¤ã³ã¸ã§ã¯ã·ã§ã³ããã«ã¯ãTypeLiteralã使ç¨ãã¾ããã¤ã³ã¸ã§ã¯ã·ã§ã³å : import java.util.List; import com.google.inject.Inject; import com.google.inject.Singleton; class Kitten { // Generic typeä»ãã®Listãåãâ¦
ã¢ããã¼ã·ã§ã³ã使ç¨ãã¦ããµã¼ãã¹ã¤ã³ã¿ã¼ãã§ã¤ã¹ã¨å®è£ ãååä»ãã§é¢é£ã¥ãã¾ãã èå¥ç¨ã¢ããã¼ã·ã§ã³ã«ã¯ã@BindingAnnotationãè¨å®ãã¾ãã(è¨å®ããªãã¨ã¨ã©ã¼ã«ãªãã¾ã) Moduleã§ãannotatedWith()ã¾ãã¯Keyãå©ç¨ãã¦ãååä»ãã§ã¤ã³ã¹ã¿ã³â¦
ã¢ããã¼ã·ã§ã³ãä½ã£ã¦ã¿ã¾ãã ä½æ ã¯ã©ã¹ãã¤ã³ã¿ã¼ãã§ã¤ã¹ã¨åãããã«ä½æã§ãã¾ãããclassãã®ä»£ããã«ã@interfaceãã§ã¢ããã¼ã·ã§ã³ã§ãããã¨ã宣è¨ãã¾ããæ§æ: <修飾è©> @interface <ã¢ããã¼ã·ã§ã³å> { ... }ãµã³ãã«(Mike.java): public â¦
sun.reflect.Reflection#getCallerClass( int )ã§ã¡ã½ããã®å¼ã³åºãå ã¯ã©ã¹ãåå¾ãã¾ããå¼æ°ã§ã¹ã¿ãã¯ã®æ·±ããæå®ãã¾ãããµã³ãã«: import sun.reflect.Reflection; public class GetCallerClass { public static void main( String[] args ) { new Mâ¦
Guiceçµã¿è¾¼ã¿ã®Namedã¢ããã¼ã·ã§ã³ãå©ç¨ãã¦ããµã¼ãã¹ã¤ã³ã¿ã¼ãã§ã¤ã¹ã¨å®è£ ãååä»ãã§é¢é£ã¥ãã¾ãã Moduleã§ãã¤ã³ã¿ã¼ãã§ã¤ã¹+ååãã¨ãå®è£ ãé¢é£ã¥ãã(Names#namedã¯Namedã¢ããã¼ã·ã§ã³ãçæããã¦ã¼ãã£ãªãã£ã§ãã) ã¤ã³ã¹ã¿ã³ã¹åå¾æâ¦
Guiceã§ã¯ä»¥ä¸ã®ã¤ã³ã¸ã§ã¯ã·ã§ã³æ¹å¼ããµãã¼ãããã¦ãã¾ãã ãã£ã¼ã«ãã¤ã³ã¸ã§ã¯ã·ã§ã³ ã³ã³ã¹ãã©ã¯ã¿ã¤ã³ã¸ã§ã¯ã·ã§ã³ ã¡ã½ããã¤ã³ã¸ã§ã¯ã·ã§ã³(set*ã«éããä»»æã®ã¡ã½ãããæå®ã§ãã¾ã) ãã£ã¼ã«ãã¤ã³ã¸ã§ã¯ã·ã§ã³(Mii.java): import com.googlâ¦
ãµã¼ãã¹ã¨å®è£ ã®é¢é£ä»ãããã¹ã³ã¼ãã®æå®ã¯ã¢ããã¼ã·ã§ã³ã§è¡ããã¨ãã§ãã¾ãããµã¼ãã¹ã¤ã³ã¿ã¼ãã§ã¤ã¹: import com.google.inject.ImplementedBy; /** * ãµã¼ãã¹ã®ã¤ã³ã¿ã¼ãã§ã¤ã¹ */ @ImplementedBy(KittenImpl.class) // å®è£ ãKittenImplã§ãâ¦
SWTã使ã£ã¦JavaããWin32APIãå®è¡ããä¸çªæåã®ã¦ã¤ã³ãã¦ã®ã¿ã¤ãã«ãåå¾ãã¾ãã 注æ:使ç¨ãã¦ããã¯ã©ã¹ã¯JavaDocçã§ã¯éå ¬éã«ãªã£ã¦ãã¾ããä»å¾å¤æ´ããããããµãã¼ããããªããªã£ããããå¯è½æ§ãããã¾ãã æºå SWT: The Standard Widget Toâ¦
Preferences APIã§Windowsã¬ã¸ã¹ããªãå©ç¨ã§ãã¾ãã 注æ:èªã¿æ¸ãã§ããã®ã¯æ±ºãããããã¼ã以ä¸ã®å¤ã§ããä»»æã®ãã¼ã®å¤ãåå¾ããããå¤æ´ãããã¯ã§ãã¾ããããµã³ãã«: Preferences root = Preferences.systemRoot(); root.put( "kitten", "mii" );â¦
Guiceããåå¾ããã¤ã³ã¹ã¿ã³ã¹ã«ã¤ã³ã¿ã¼ã»ãã¿ãé©ç¨ãã¾ãããããModuleã§æ示ãã¾ãããµã¼ãã¹ã¨å®è£ : /** * ãµã¼ãã¹ã®ã¤ã³ã¿ã¼ãã§ã¤ã¹ */ static interface Kitten { void meow (); } /** * ãµã¼ãã¹ã®å®è£ */ static class KittenImpl implements Kâ¦
Guiceããåå¾ããã¤ã³ã¹ã¿ã³ã¹ã¯ãããã©ã«ãã§ã¯ãæ¯åä½æãããã¾ããã·ã³ã°ã«ãã³ã«ããã«ã¯Moduleã§æ示ãã¾ããã¤ã³ã¿ã¼ãã§ã¤ã¹ã¨å®è£ : /** * ãµã¼ãã¹ã®ã¤ã³ã¿ã¼ãã§ã¤ã¹ */ static interface Cat {} /** * ãµã¼ãã¹ã®ã¤ã³ã¿ã¼ãã§ã¤ã¹ */ static iâ¦
Guiceã使ã£ã¦ã¿ã¾ãã åç´ãªãµã³ãã« DIã³ã³ãããããµã¼ãã¹ã®ã¤ã³ã¹ã¿ã³ã¹ãåå¾ããã ãã®åç´ãªãµã³ãã«ã§ããã¤ã³ã¸ã§ã¯ã·ã§ã³ãªãã Injector DIã³ã³ããã«è©²å½ããµã¼ãã¹ã®å®è£ ã¯ããããåå¾ãã¾ãã Module DICONãã¡ã¤ã«ã«è©²å½ããµã¼ãã¹ã¨å®è£ â¦
Continuationã§ä¸æããå¦çãåéãã¾ãã ä¸æããå ´æã§çµã¿è¾¼ã¿é¢æ°ãcallccããå®è¡ã ãããã¯ã«æ¸¡ãããContinuationãè¨é² å¾ã§Continuation#callãå®è¡ããã¨ããcallccããå®è¡ããä½ç½®ã«æ»ã£ã¦å¦çãåéã§ãã¾ãã continuation = nil puts "staâ¦
åå¼·ã®ææãå ±åããã³ã¼ãã¼ã§ããæå§ãã«ã¡ãã£ã¨åã«ä½ã£ãWebã¢ããªã±ã¼ã·ã§ã³ãç´¹ä»ãã¾ãã æ¦è¦ ãMiiãã¯ãããããç«ã®åçã表示ããã ãã®Webã¢ããªã±ã¼ã·ã§ã³ã§ãããå©ç¨ã¯ä»¥ä¸ããã>ãMiiãããååæ°å³ã ç²ããæã«å¹æ絶大ãããããç«â¦
catch,throwã§ãã¹ãããããããã¯ãä¸æ°ã«æãã¾ããthrow ã§æããå ´åãcatchã®æ»ãå¤ã¯throwã®ç¬¬2å¼æ°ã§ãã puts catch(:A) { 5.times {|i| puts "outer loop:" << i.to_s 5.times {|j| puts "inner loop:" << i.to_s << "-" << j.to_s throw :A, "canâ¦
Hash#mergeã§ããã·ã¥ããã¼ã¸ãã¾ãããããã¯ã渡ãããå ´åã2ã¤ã®ããã·ã¥ã«åããã¼ããã£ãéã«å®è¡ããããããã¯ãè©ä¾¡ããå¤ã使ç¨ããã¾ãããµã³ãã«: h = {:a=>"a", :b=>{ :aa=>"aa" }, :c=>"c" } h2 = {:x=>"x", :b=>{ :bb=>"bb" }, :c=>"c" } #â¦
SQLã¤ã³ã¸ã§ã¯ã·ã§ã³ã®èå¼±æ§ããªãããããfindã§ã®æ¤ç´¢æ¡ä»¶ã®æå®æ¹æ³ã«ã¯æ³¨æãå¿ è¦ã§ãã Ãã:conditions=>"name = '" + name + "'"ãã®ããã«æ¡ä»¶ãèªåã§ä½æããã®ã¯å±éºã âã:conditions=>"name = ?", nameããã:conditions=>{:name=>name}ãã¨ãâ¦
ã©ããã¦ããã°ã©ãã«ã»ã»ã»ããã°ã©ã ãæ¸ããªãã®ã?ãã: 1ãã100ã¾ã§ã®æ°ãããªã³ãããããã°ã©ã ãæ¸ãããã ã3ã®åæ°ã®ã¨ãã¯æ°ã®ä»£ããã«ï½¢Fizzï½£ã¨ã5ã®åæ°ã®ã¨ãã¯ï½¢Buzzï½£ã¨ããªã³ããã3ã¨5両æ¹ã®åæ°ã®å ´åã«ã¯ï½¢FizzBuzzï½£ã¨ããªã³ããããã¨ã â¦
find_by_*ã§å±æ§ãæ¡ä»¶ã«ãã¼ã¿ãæ¤ç´¢ã§ãã¾ãã find_by_* å±æ§ãæ¡ä»¶ã«ãã¦ãããã«ãããããæåã®ãã¼ã¿ãåå¾ find_all_by_* å±æ§ãæ¡ä»¶ã«ãã¦ãããã«ããããããã¼ã¿ããã¹ã¦åå¾ ãã¼ã¿ ãã¼ãã«å®ç¾©: CREATE TABLE kittens ( id int(11) NOT NULLâ¦
Hash#dupã§ããã·ã¥ãè¤è£½ãã¾ããå帰çãªã³ãã¼ã¯è¡ããã¾ããã(shallow copy)ãµã³ãã«: h = { :a=>"aa", :b=>{ :x=>"xx", } } # è¤è£½ h2 = h.dup p h p h2 puts "---" # å¤æ´ h2[:a] = "edit" h2[:b][:x] = "edit" # :bã®å¤ã®ããã·ã¥ã¯å ±æããã¦ãããâ¦
ActiveRecord::Base#find ã§ãã¼ãã«ãããã¼ã¿ãæ¤ç´¢ã§ãã¾ãã å¼æ°ã«å¿ãã¦ä»¥ä¸ã®æ¤ç´¢ãå¯è½ã§ãã IDã§æ¤ç´¢ æ¡ä»¶ã«ãããããæåã®ãã¼ã¿ãæ¤ç´¢ æ¡ä»¶ã«ããããããã¹ã¦ã®ãã¼ã¿ãæ¤ç´¢ ãã¼ã¿ ãã¼ãã«å®ç¾©: CREATE TABLE kittens ( id int(11) NOT NULâ¦
ActiveRecordã§1:nãªã¬ã¼ã·ã§ã³ã®ãã¼ã¿ãæ±ãã¾ãã ãã¼ãã«å®ç¾© CREATE TABLE kittens ( id int(11) NOT NULL auto_increment PRIMARY KEY, strain_id int(11) default NULL, name VARCHAR(255) ); CREATE TABLE strains ( id int(11) NOT NULL auto_incrâ¦
Hpricotã§ã¹ã¯ã¬ã¤ãã³ã°ãã¾ãã ã¤ã³ã¹ãã¼ã« gem install hpricothpricotã¯Cã§æ¸ãããæ¡å¼µã©ã¤ãã©ãªã使ç¨ãã¦ãã¾ããCygwinç°å¢ã ãããããã¾ããããã¤ã³ã¹ãã¼ã«æã«ç°å¢ã«åããã¦ã³ã³ãã¤ã«ããããããmakeãgccãå¿ è¦ã§ããã 使ã£ã¦ã¿ã ãã¼â¦
JDK6ããããã®ã§ãJavaScriptãå®è¡ãã¦ã¿ã¾ããHelloWorld (JDKã®ãµã³ãã«ã®ä¸¸åã): ScriptEngineManager factory = new ScriptEngineManager(); ScriptEngine engine = factory.getEngineByName("JavaScript"); engine.eval("print('Hello World')"); åºâ¦