ã³ãã³ãã©ã¤ã³ã®Flashéçºç°å¢ãæ´ãã
HTML5ã¸ã®æµããå éãã¦ããæ¨ä»ã§ããããã®ã¨ããä»äºã®ä¸ã§Flashã«è§¦ãæ©ä¼ãå¤ããªã£ã¦ãã¾ããã
ãã£ãããªã®ã§ãå¿ããªããã¡ã«ActionScriptã«ããFlashéçºç°å¢ãæ´ããæé ãã¡ã¢ãã¦ãããã¨æãã¾ãã
åææ¡ä»¶
ãã¤ã³ãã¯ä»¥ä¸ã®2ã¤ã
- ã³ãã³ãã©ã¤ã³ã§å®çµãããã¨
- ç¡æã§ã§ãããã¨
ãããã«åä½ç¢ºèªã¯ãã©ã¦ã¶ã使ã£ã¦ããã¾ããããã®ä»ã®ä½æ¥ã¯åºæ¬çã«SSHæ¥ç¶ããã¿ã¼ããã«ä¸ã§è¡ãã¾ãã
ãµã¼ã㯠CentOS 5.5 64bitçãã¯ã©ã¤ã¢ã³ã㯠Windows 7 64bitçã§ãããµã¼ãæ©ã«ã¯GUIç°å¢ã¯å ¥ã£ã¦ãã¾ããã
Javaå®è¡ç°å¢ã®æºå
å¾è¿°ããFlex SDKãåä½ãããããã«ãJavaå®è¡ç°å¢(JRE)ãå¿ è¦ã«ãªãã¾ãã
ä¸è¨ãã¼ã¸ãããä»å㯠Linux x64 RPM ããã¦ã³ãã¼ããã以ä¸ã®ã³ãã³ãã§ã¤ã³ã¹ãã¼ã«ãã¾ãã2010å¹´11æ20æ¥ç¾å¨ã®ææ°ç㯠Version 6 Update 22 ã§ããã
$ sudo sh jre-6u22-linux-x64-rpm.bin ... $ which java /usr/bin/java $ java -version java version "1.6.0_22" Java(TM) SE Runtime Environment (build 1.6.0_22-b04) Java HotSpot(TM) 64-Bit Server VM (build 17.1-b03, mixed mode)
ã³ã³ãã¤ã©ã®æºå
ã³ã³ãã¤ã©ã«ã¯Adobeãå ¬éãã¦ãã Flex SDK ãå©ç¨ãã¾ãã
Flex SDKã«ã¯2種é¡ããããªã¼ãã³ã½ã¼ã¹ãããã¯ãã®ã¿ã§æ§æããã Open Source Flex SDK ã¨ãããã«ãªã¼ãã³ã½ã¼ã¹ã§ãªããã®ãå«ãã Free Adobe Flex SDK ãç¨æããã¦ãã¾ããã©ã¡ããç¡æã§ä½¿ããã¨ãã§ãã¾ãã
ä»åèªåãæ³å®ãã¦ããç¨éã§ã¯ãªã¼ãã³ã½ã¼ã¹çã§ç¹ã«ä¸è¶³ã¯ãªãã®ã§ãã©ã¤ã»ã³ã¹ã馴æã¿ã®ããMPLã§ããããªã¼ãã³ã½ã¼ã¹çã使ããã¦ããããã¨ã«ãã¾ããã
ä¸è¨ãã¼ã¸ä¸ã® Open Source Flex 4 SDK ãªã³ã¯ãããã¦ã³ãã¼ãã§ãã¾ãã2010å¹´11æ20æ¥ç¾å¨ã®ææ°ç㯠Flex 4.1 Update Release (4.1.0.16076) ã§ããã
ZIPããã±ã¼ã¸ã«ãªã£ã¦ãã¾ãã®ã§ãé©å½ãªå ´æã«å±éããä¸ã®binãã£ã¬ã¯ããªã«PATHãéãã¦ããã¾ãã
$ unzip flex_sdk_4.1.0.16076_mpl.zip -d ~/flex ... $ echo 'export PATH=$HOME/flex/bin:$PATH' >> ~/.bashrc $ . ~/.bashrc $ which mxmlc ~/flex/bin/mxmlc $ mxmlc -version Version 4.1.0 build 16076
ãµã³ãã«ããã°ã©ã ã®ä½æ
æ©éãªã«ãä½ã£ã¦ã¿ã¾ãã
package { import flash.display.Sprite; import flash.display.Bitmap; import flash.display.BitmapData; import flash.text.TextField; import flash.text.TextFieldAutoSize; import flash.text.TextFormat; import flash.events.Event; [SWF(width="640", height="480", frameRate="30")] public class HelloWorld extends Sprite { private var base:Sprite; public function HelloWorld():void { var txtFld:TextField = new TextField(); txtFld.autoSize = TextFieldAutoSize.LEFT; txtFld.text = 'Hello World!'; var fmt:TextFormat = new TextFormat(); fmt.size = 32; txtFld.setTextFormat(fmt); var bmpData:BitmapData = new BitmapData(txtFld.width, txtFld.height); bmpData.draw(txtFld); var bmp:Bitmap = new Bitmap(bmpData); bmp.smoothing = true; bmp.x = -(bmp.width / 2); bmp.y = -(bmp.height / 2); base = new Sprite(); base.x = 320; base.y = 240; base.addChild(bmp); addChild(base); addEventListener(Event.ENTER_FRAME, onEnterFrame); } private function onEnterFrame(event:Event):void { base.rotationY += 4; } } }
ä¸ã®ã³ã¼ããHelloWorld.asã¨ãããã¡ã¤ã«åã§ä¿åãã以ä¸ã®ã³ãã³ãã§ã³ã³ãã¤ã«ãã¾ãã
$ mxmlc HelloWorld.as
ã³ã³ãã¤ã«ãå®äºããã°ãåããã£ã¬ã¯ããªã«HelloWorld.swfã¨ãããã¡ã¤ã«ãä½æããã¦ãã¾ãããã¨ã¯ããããã©ã¦ã¶ã§èªã¿è¾¼ãã ãã§ãã
ãã£ãããµã¼ãä¸ã§éçºãã¦ããã®ã§ããããã³ã³ããã¨ãªãHTMLãã¡ã¤ã«ãä¸ç·ã«ä½ã*1ããã®ã¾ã¾Apacheçµç±ã§åç §ã§ããããã«ãã¦ãã¾ãã®ã楽ã§ãããã
ã¡ãªã¿ã«ãä¸è¨ã®ãµã³ãã«ã¯åã« "Hello World!" ãå転ããã ãã®ã·ã³ãã«ãªFlashã§ãã
ã³ã³ãã¤ã«ãªãã·ã§ã³
ä¸è¨ã®ã³ãã³ãã§ã³ã³ãã¤ã«ããã¨è¦åã¡ãã»ã¼ã¸ãåºã¾ããããã㯠-static-link-runtime-shared-libraries ãªãã·ã§ã³ãä»ãããã¨ã§åé¿ã§ãã¾ãã
$ mxmlc -static-link-runtime-shared-libraries HelloWorld.as
ã³ã³ãã¤ã«ãªãã·ã§ã³ã¯ãä¸è¨ã®ããã«ã³ãã³ãã©ã¤ã³ããæå®ããä»ã«ãè¨å®ãã¡ã¤ã«ã«æ¸ãã¦ãããã¨ãã§ãã¾ãã
è¨å®ãã¡ã¤ã«ã«ã¯ã${FLEX_ROOT}/frameworks/flex-config.xml ã«é ç½®ããã¦ããå ±éè¨å®ãã¡ã¤ã«ã¨ãã³ã³ãã¤ã«å¯¾è±¡ãã¡ã¤ã«ãã¨ã®ãã¼ã«ã«è¨å®ãã¡ã¤ã«ãããã¾ãã
ãã¼ã«ã«è¨å®ãã¡ã¤ã«ã¯ãã³ã³ãã¤ã«å¯¾è±¡ã®ASãã¡ã¤ã«ã¨åããã£ã¬ã¯ããªã« -config.xml ãµãã£ãã¯ã¹ãã¤ãã¦ç½®ãã¦ããã¾ããä¾ãã°å ç¨ã® HelloWorld.as ã®å ´åãHelloWorld-config.xml ã¨ãããã¡ã¤ã«ãåããã£ã¬ã¯ããªã«ç½®ãã¦ããã¨ãã³ã³ãã¤ã«æã«ç¹ã«æå®ãããªãã¦ãèªã¿è¾¼ãã§ããã¾ãã
ä»ã«ããload-config ãªãã·ã§ã³ã«ãã£ã¦æ示çã«è¨å®ãã¡ã¤ã«ãæå®ãããã¨ãã§ãã¾ãã
è¨å®ãã¡ã¤ã«ã®ãã©ã¼ãããã¯ãä¸çªåç´ãªå½¢ã ã¨ä»¥ä¸ã®ããã«ãªãã¾ãã
<?xml version="1.0" encoding="UTF-8"?> <flex-config> <static-link-runtime-shared-libraries>true</static-link-runtime-shared-libraries> </flex-config>
ãªãã·ã§ã³æå®ã®åªå 度ã¯ãã³ãã³ãã©ã¤ã³ãªãã·ã§ã³ ï¼ load-config ã§æå®ããè¨å®ãã¡ã¤ã« ï¼ ãã¼ã«ã«è¨å®ãã¡ã¤ã« ï¼ flex-config.xmlãã¨ãªã£ã¦ãã¾ãã
ãªãã·ã§ã³ã®ç°¡åãªãªã¹ãã¯ä»¥ä¸ã®ã³ãã³ãã§ç¢ºèªã§ãã¾ãã
$ mxmlc -help advanced list details
Makefile
é »ç¹ã«ã³ã³ãã¤ã«ãè¡ãå ´åãmake ã ant ãªã©ã®ãã«ããã¼ã«ã使ããã¨ã«ãªããã¨æãã¾ããèªåã¯ä½¿ãæ £ãã make ãå©ç¨ãã¦ãã¾ãã
ã·ã³ãã«ãªswfçæç¨Makefileã¯ä»¥ä¸ã®ãããªå½¢ã«ãªãã¾ãã
MXMLC = mxmlc MXMLCFLAGS = TARGETS = HelloWorld.swf all: $(TARGETS) clean: $(RM) $(TARGETS) .SUFFIXES: .as .swf .as.swf: $(MXMLC) $(MXMLCFLAGS) $<
traceãã°ã®åºå
ãããã°çã® Flash Player ã§ã¯ trace() é¢æ°ã使ã£ã¦ãã¡ã¤ã«ã¸ã®ãã°åºåãè¡ããã¨ãã§ãã¾ãã
ä¸è¨ãã¼ã¸ãããããã°çãã¬ã¤ã¤ã¼ããã¦ã³ãã¼ããã¦ã¤ã³ã¹ãã¼ã«ãã¾ãã
ã¹ã¿ã³ãã¢ãã³çãããã¾ãããFirebugã¨çµã¿åããã¦ä½¿ããã¨ä¾¿å©ãªã®ã§ãèªåã¯ä¸è¨ãã¼ã¸ä¸ã® "Windows Flash Player 10.1 Plugin content debugger (for Netscape-compatible browsers)" ãã¤ã³ã¹ãã¼ã«ãã¦Firefoxã§åããã¦ãã¾ãã*2
次㫠mm.cfg ãã¡ã¤ã«ã«ä»¥ä¸ã®è¨å®ãå ãã¾ãããã¡ã¤ã«ãç¡ããã°æ°è¦ä½æãã¾ãã
ErrorReportingEnable=1 TraceOutputFileEnable=1
mm.cfg ãã¡ã¤ã«ã¨ trace() é¢æ°ããã®åºåãè¨é²ããããã°ãã¡ã¤ã«ã®å ´æã¯ä»¥ä¸ã®ãã¼ã¸ãåç §ãã¦ãã ãããWindows 7 ã®å ´å㯠Windows Vista ã¨åãå ´æã«é ç½®ããã¦ãã¾ãã
trace() é¢æ°ã«ãããã°åºåãæå¹ã«ããã«ã¯ãswfãdebugãã©ã°ä»ãã§ã³ã³ãã¤ã«ããå¿ è¦ãããã¾ãã
è¨å®ãã¡ã¤ã«ã§æå®ããå ´åã¯ä»¥ä¸ã®ããã«ãªãã¾ãã
<?xml version="1.0" encoding="UTF-8"?> <flex-config> <compiler> <debug>true</debug> </compiler> <static-link-runtime-shared-libraries>true</static-link-runtime-shared-libraries> </flex-config>
JavaScriptã³ã³ã½ã¼ã«ã¸ã®ãã°åºå
ã¾ãã¯ãã£ã¨ç°¡åã« console.log() ã使ã£ã¦FirebugãGoogle Chromeã®JavaScriptã³ã³ã½ã¼ã«ã«ã¡ãã»ã¼ã¸ãåºåãããã¨ãã§ãã¾ãã
ActionScriptããJavaScriptãå¼ã³åºãã«ã¯ ExternalInterface ã¯ã©ã¹ã使ãã¾ãã以ä¸ã®ãããªã¡ã½ãããã©ããã«å®ç¾©ãã¦ããã¨ä¾¿å©ãã¨æãã¾ãã
import flash.external.ExternalInterface; public function log(message:Object):void { ExternalInterface.call('console.log', message.toString()); }
ãã㧠log() ã¡ã½ããã«æ¸¡ããå¼æ°ãFirebugãGoogle Chromeã®JavaScriptã³ã³ã½ã¼ã«ã«è¡¨ç¤ºããã¾ãã
fdbã«ãããªã¢ã¼ããããã°
ãã£ã¨æ¬æ ¼çãªãããã°ã«ã¯ActionScriptã®ãããã¬ã§ãã fdb ãå©ç¨ã§ãã¾ããfdb 㯠Flex SDK ã«å梱ããã¦ãã¾ãã
éçºç°å¢ã¨å®è¡ç°å¢ãåä¸ãã¹ãã§ãããã¿ã¼ã³ããã£ã¨ãã·ã³ãã«ãªã®ã§ãããä»åã¯fdbããµã¼ãä¸ã§ããã¬ã¤ã¤ã¼ãã¯ã©ã¤ã¢ã³ãä¸ã§åä½ãããç¶æ ã§ãããã°ãè¡ãã¾ãã
ã¾ããtraceãã°åºåã®éã«è¡ã£ãããã«ãdebugãã©ã°ä»ãã§swfãã³ã³ãã¤ã«ããã¯ã©ã¤ã¢ã³ãä¸ã®ãããã°çãã¬ã¤ã¤ã¼ã§èµ·åãã¾ãã
次ã«ãµã¼ãä¸ã§ä»¥ä¸ã®ã³ãã³ããå®è¡ããfdbãæ¥ç¶å¾ ã¡åãç¶æ ã«ãã¾ãã
$ fdb Adobe fdb (Flash Player Debugger) [ãã«ã 16076] Copyright (c) 2004-2007 Adobe, Inc. All rights reserved. (fdb) run Player ãæ¥ç¶ããã®ãå¾ ã£ã¦ãã¾ã
ã¯ã©ã¤ã¢ã³ãä¸ã®ãããã°çãã¬ã¤ã¤ã¼ãå³ã¯ãªãã¯ããã¡ãã¥ã¼ä¸ã®ããããã¬ã¼ããã¯ãªãã¯ãã¦ããã«ã表示ãæ¥ç¶å ã«ãã»ãã®ã³ã³ãã¥ã¼ã¿ã¼ããé¸ãã§ãµã¼ãã®IPã¢ãã¬ã¹ãå ¥åãã¾ãã
ãæ¥ç¶ããããé¸æããã¨ããããã°çãã¬ã¤ã¤ã¼ãå¾ ã¡åãç¶æ ã®fdbã«æ¥ç¶ãããããã°ã»ãã·ã§ã³ãéå§ãããfdbã«ãããããã°ãå¯è½ãªç¶æ ã«ãªãã¾ãã
ãªãããã®éããµã¼ãã¯ã¯ã©ã¤ã¢ã³ãã«å¯¾ã㦠TCP/7935 ã®ãã¼ããéãã¦ããå¿ è¦ãããã¾ãã
$ fdb Adobe fdb (Flash Player Debugger) [ãã«ã 16076] Copyright (c) 2004-2007 Adobe, Inc. All rights reserved. (fdb) run Player ãæ¥ç¶ããã®ãå¾ ã£ã¦ãã¾ã Player ãæ¥ç¶ããã¾ãããã»ãã·ã§ã³ãéå§ãã¦ãã¾ãã ãã¬ã¼ã¯ãã¤ã³ããè¨å®ãã¦ãcontinueãã¨å ¥åããã»ãã·ã§ã³ãåéãã¦ãã ããã [SWF] /sample/HelloWorld.swf - 2,287 ãã¤ã (解åå¾) (fdb)
å¦çã®æåãããããã°ãè¡ãªãããå ´åãã»ãã·ã§ã³ãéå§ããç¶æ ã§ãããã°çãã¬ã¤ã¤ã¼ãåä½ãã¦ãããã¼ã¸ãåèªã¿è¾¼ã¿ããã°OKã§ãã
fdbã«ãããããã°ã®è©³ç´°ã¯ä»¥ä¸ã®ãã¼ã¸ãåèã«ãªãã¾ãã
ãã®ä»
ãã¨ã¯ãªãã¡ã¬ã³ã¹ããã®ä»è³æãåèã«ããªããéçºãé²ãã¦ããã¾ãããªãã¡ã¬ã³ã¹ã«ã¯æ§ã ãªããã±ã¼ã¸ãè¨è¼ããã¦ãã¾ãããFlex SDK ã§å©ç¨å¯è½ãªã®ã¯ flash, mx, spark ã®3ã¤ã®ããã±ã¼ã¸ã ãã§ãã®ã§æ³¨æãã¦ãã ããã
ä»ã«Flashãéçºãã¦ããä¸ã§è©°ã¾ããããããªã®ã¯ãã¯ãã¹ãã¡ã¤ã³ããªã·ã¼ã¾ããã§ããããã
Flashã§ã¯ãã¹ãã¡ã¤ã³ã®éä¿¡ãè¡ãå ´åãéä¿¡å ã®ãµã¼ãã«ã¯ãã¹ãã¡ã¤ã³ããªã·ã¼ãã¡ã¤ã« "crossdomain.xml" ãè¨ç½®ããã¦ããããã¤é©åãªè¨å®ããªããã¦ããå¿ è¦ãããã¾ãããã㯠URLLoader/URLRequest ã®ãããªåçºãªã¯ã¨ã¹ãã®å ´åããSocket/XMLSocket ã®ãããªæç¶çæ¥ç¶ã®ãããªå ´åãåæ§ã§ãã
Flashéçºã¯ã¾ã ã¾ã 触ãå§ããã°ããã§æ £ãã¦ãã¾ããããã¼ã¡ã¼ã¡è²ã 試ãã¦ãããã¨æãã¾ãã
ããããªç»åãAA Quineåãããï¼
ãã®è¾ºã®æµããè¦ã¦æ¥½ãããã ãªãã¨æã£ãã®ã§çä¼¼ãã¦ã¿ã¾ããã
- RubyでうどんげQuine(とAA型Quineの作り方講座) - ぬいぐるみライフ(仮)
- 404 Blog Not Found:perl - Quine.pm で(ほぼ)あらゆるPerl Scriptをquineに
- うどんげQuineに対抗して遊んでみた - As Sloth As Possible
ãã¯ããQuine
ã¾ãã¯ãã¡ãããã
â»2010å¹´9æ20æ¥è¿½è¨ï¼ãã¯ãããæ´æ°ãã¾ãããGistã®ã³ã¼ããæ´æ°æ¸ã¿ã§ãã詳ããæ´æ°å 容ã¯è¨äºæ«å°¾ã®è¿½è¨æ¬ã«ã¦ã
eval$s=%w~ a=->(b,c, d,e,f){%`#{(c)?"re quire'zlib';":' '}g=Marshal.load(#{ (c)?'Z lib::Inflate.infl ate(':''}'#{b}'. unpack('m')[0]#{(c)?')': ''});h= 'eval$s =%w'<<126<<($s*#{d} );i=' ';j=- 1; #{ e*f}.times{|k|i<< (g[ k]== 1? h[j+=1]:32);i<<10i f (k% #{e} ==#{e-1})};i[-7,6] =' ' < <126<< '.join';puts(i)#`}; $*[ 0]? ( require' RMagick';include(Ma gi ck );l=$*[0];m =($*[1]||80).to_i;n= Qu a ntu mRange*( $*[2]||0.5).to_f;o= Im a g eL ist.new(l ).flatten_images;p= o. c olu mns; q=o.rows;r=->(o){(p > q ) ? o .re size (m ,m*q/p/2):o.resize (m * p / q ,m /2)}; o=( p>m||q>m)?r[o.bile v el_ch an ne l (n )] :r [o].b ile vel_channel(n);e= o. columns ;f= o.r o w s;rais e('INVALID_ IMAGE_DATA')if(e<0||f <0 );s=''; o.ea ch _pixel {|t|s<<((t.red< n)?'1':'0')};s[0,10] ='1 '*10;s[ -6,6 ]= '1'*6; u= s.count('1');v=Marshal.dump(s.rev erse.to_i(2 ));r eq u ire'z l ib';w=Z lib::Deflate.deflate(v) ;c= v.size> w.siz e+37;b=[(c) ?w:v] .pack('m').tr(10.chr,'');d=u/b. size+1;x=a[b,c,d,e,f]; raise(' INSU FFICIENT_ CAPACITY')if(u<x.size +15);e val($s=x)):eva l(a[' eJ wlkLFL w1AQxr/XlKbQQjpmaiq4u XSz4JD 8KQHXDs4iJOIf0 FmoHZ3 ddJJIoHYodXUMLnVo8Yl gXjHm 81694fhx7+5731 2zPT5S C/ yHDiUZzzDQdIGKAYpSEmo qpGQiVClk5A4IUoW44hqp i6Ft niBT0CIgE3E00I5QiNFoo D1ome12YUIhooXeiCiEH N Ue1o6QiD Xx4FqKcB id9edkNug1ovhiRUbGv x pn ZkrG9bTzm 3FnaabMJ 0u ysHRNiYKzg6KT1Lb2y N yt 9zWWrlf/iN4H145vdnt 6 9mC9pC+cyILyCjLwrHvK L vY Qi5DWdwNYJsSr1IGt5H faa2z2ffY4my3xbX96KkGcW0f3d Cq ccC2 dQ cukN8yT6tLr mm xJJ1 jlbttEc6p+fer4On6juuXxna+HBVX+lW hf/wF n292 m',true, 4 ,80, 40])#a=->(b ,c,d,e,f){%`#{(c)?"requ ir e'zlib';":' '}g=Ma rs hal .load(#{(c) ?'Zlib::Inflate.infl ate(' :' '}'#{ b} '.u npack('m')[ 0]#{(c)?' )':''}) ;h='e va l$s=% w' << 126<<($s*#{d });i= ''; j=-1 ;#{e* f }.tim e s{ |k|i<<(g[k] ==1? h[j+=1]:3 2) ;i << 10if (k % #{e}==#{e-1} )} ; i[-7,6]=''<< 12 6< < '. join '; puts(i)#`};$ *[ 0]?( require'RMa gick '; ~.join
ãã¯ããã§ãã
å ã¤ã©ã¹ãã¯ãã¡ããããåããã¾ããããã®å ´ãåãã¦å¾¡ç¤¼ç³ãä¸ãã¾ãã
AA Quine ãçæãã AA Quine
Quineã¨ããããã«ã¯ãæ®éã«å®è¡ããã°å½ç¶èªåèªèº«ãåºåãã¾ãã
$ ruby mikusan.rb | diff mikusan.rb - $
ãã親åãªãã¯ããã¯ãããã«å¼æ°ã¨ãã¦ç»åãã¡ã¤ã«ãæå®ããã¨ããã®ç»åã®Quineãçæãã¦ããã¾ãã
ä¾ãã°ãããªãããã
$ ruby mikusan.rb mikusan2.gif | tee mikusan2.rb eval$s=%w` d=Marshal.load ('BA hsKwHI/wM AAAAAAAAAAAA AAAA AAAAAAAAAgP8fAAAAAAAAAODxHwAAAMD/Aw B4/P/ //x/w+Q MAHv 9/AADg+/wHAN//B wAAAH 7+PwD /fwAAAAA/ ///A/ x8AAACAnz+AYP wDIAAA gP8fABD4ACCAA ID/DwAMfAA44AEA /w8ABh wAf2BuAP4PAAMOgF 9wCAD8HwABB8DHM CAA+B8 AgAPwgz C AI fAfAMAD+ I E5HCTwHwDAIfwc O QAw8D 8 A 4Dn+fzr+P/A/A PA 9Pv88 +D/ 4PwD wPx//OPg//D8 A+ D8f +HDIP/w fA Pi/ D+ MAGDD+EwD8/ w/ DAB gw/hEA / P8H f gBwOP8YAP7/ B wAA gL9/G AD +/ w 8AAADYHxgA /v9 /AAAA+ A MI AP / //w9wAP8A DAD/ ///j/x 88 AAw A// / / Az4fDgAEA P// / wGzcQA ABg D /// +B 8/AAAAYA// //wf vYA AACAP////HP/wE A AwD ////xzL8BAAEA ////+fz4A4 ABAP/ ///3 E+APA AAD///9/ ZvgH YAAA////f2P wB2AA/A=='. unpack('m' )[0]) ;c='eval $s= %w'<<96<<($ s*3);r='';j= -1;3200.tim es{|i |r<<( d[i ] ==1?c[j+ =1]:32);r<< 10if(i%80== 79)}; r[ -7, 6] =' '<<96<<'. j oin';puts(r)#d=Mar sh al .l oa d('BAhsK w HI/wMAAAAAAAAAAAA AAAAAA AAA AAA AgP8fAAA AA AAAAODxHwAAAMD/AwB 4/P///x /w+QMAHv 9/ AADg+/wHAN//BwAAAH7 +P wD/fwAA AA A////A/x8AAACAnz+AYPwD IAAAgP8 f ABD4ACCAAID/DwAMfAA44AEA/w8A Bhw Af2BuAP4 PA AMOgF9wCAD8HwABB8DHMCAA+B8 AgAPwgzCAIfAfAMA D+IE 5H CTwHwDAIfwcOQAw8D8A4Dn+fzr +P/A/ APA9P v88 + D/4PwDwPx//OPg//D8A+D8f+H DI P/ wf APi /D +MAGDD+EwD8/w/DABgw/hEA/P 8Hf gBwO P8YA P7 /BwAAgL9/GAD+/w8AAADYHxgA /v9/ AAAA+ AM IA P ///w9wAP8ADAD////j/x88AAw A////Az4 fDgAEAP///w Gz cQAABgD///+B8/AAAAYA////w fvYA AA CAP////H P/ w EAAwD////xzL8BAAEA////+fz 4A4AB AP//// 3E+APAA AD ///9/ZvgHYAAA////f2PwB2AA /A=='. u np ack('m' )[ 0]);c='eval$s=%w'<<96<<($s*3);r =' '; j=-1;320 0. times{|i|r<<(d[i]==1?c[j+=1]:32 ); r< <10if(i %8 `.join $ ruby mikusan2.rb | diff mikusan2.rb - $
å ã¤ã©ã¹ãã¯ãã¡ããããåããã¾ããããããã¨ããããã¾ãã
使ãæ¹
$ ruby mikusan.rb [ç»åãã¡ã¤ã«ã®ãã¹] [é·è¾ºã®ãµã¤ãº(ããã©ã«ã:80)] [äºå¤åã®ãããå¤(ããã©ã«ã:0.5)]
ãã£ããã¨ãã使ãæ¹ã¯ä»¥ä¸ã®éãã§ãã
- å®è¡ã«ã¯ RMagick 2 ãå¿ è¦ã§ãã*1
- å¼æ°ãã¤ããã«å®è¡ããã¨ãèªèº«ãåºåãã¾ãã
- ç»åãã¡ã¤ã«ã®ãã¹ãæå®ããã¨ããã®ç»åããAA Quineãçæãã¦åºåãã¾ããèªèå¯è½ãªç»åã®å½¢å¼ã¯ RMagick ã«ãªã³ã¯ããã ImageMagick ã«ä¾åãã¾ãã
- 2ã¤ç®ã®å¼æ°ã«é·è¾ºã®ãµã¤ãºãæå®ã§ãã¾ããç»åã¯ãã®ãµã¤ãºã¾ã§ç¸®å°ãããã¯æ¡å¤§ãã¦ããAAåããã¾ãã横é·ã®ç»åã®å ´åã¯æ¨ªãµã¤ãºã縦é·ã®ç»åã®å ´åã¯ç¸¦ãµã¤ãºãããã§æå®ããå¤ã«åããããã¾ãã
- 3ã¤ç®ã®å¼æ°ã«ã¯ãç»åãç½é»äºå¤åããéã«ãã©ããããã®æ¿ãã®è²ã¾ã§ãé»ã¨ãã¦å¤å®ãããã0.0ã1.0ã¾ã§ã®å¤ã§æå®ãã¾ãã1.0ã«è¿ã¥ããã»ã©ãããå¤ãã®è²ãé»ã¨ãã¦å¤å®ãããããã«ãªãã¾ãã
ããã«æ³¨æäºé ã¨ãã¦ã
- ã©ããªç»åã§ãQuineåã§ããããã§ã¯ããã¾ãããAAåããéã«ãæåãé ç½®ã§ããé åâ¦ã¤ã¾ãé»ã¨å¤å®ãããé åãååã«åå¨ããªãã¨ãèªåèªèº«ã®ã³ã¼ããæ ¼ç´ããããªããããã¨ã©ã¼ãåãã¦æ¢ã¾ãã¾ããå¼æ°ã§ä¸ãããµã¤ãºããããå¤ãå¤æ´ããã¨é»ã®é åãå¢æ¸ãã¾ãã®ã§ãè²ã 調æ´ãã¦ã¿ã¦ãã ããã*2
- å®éã«ã¯ç»åã®ç¸¦ãµã¤ãºã¯æå®ãããå¤ãããããã«ååã«ç¸®å°ããã¾ããä¸è¬çãª1ãã¤ãæåã縦é·ãªããã§ããããã§ãã¾ã ã¢ã¹ãã¯ãæ¯ã«éåæãããå ´åããã©ã³ã*3ãå¤æ´ãã¦ã¿ãã¨ããããããã¾ããã
- ç·ã®ç´°ãç»åãè²ã®èãç»åã¯Quineåãã«ããã§ãããããå¤ãããããªã©ãã¦ç¡çããQuineåãããã¨ãã§ãã¾ããããã¾ã綺éºãªçµæã«ãªãã¾ãããQuineåã«é©ããç»åã¯ãç·ãé»ãã¦å¤ªãã¦ã¯ã£ããã¨ãã¦ãã¦ãç»åå ¨ä½ã«å¤§ãã対象ãæããã¦ããã¿ã¤ãã®ãã®ã¨ãªãã¾ããè¤éã§å¤§ããªã¤ã©ã¹ãã¯ã©ããã¦ãé£ãããã¢ã¤ã³ã³ç»åç³»ãæ¯è¼çé©ãã¦ããã¨æãã¾ãã
ä¸èº«ã®è©±ãããã£ã¨ã
- çæãããQuineã«ã¯ãå·¦ä¸ã« "eval$s=%w`" ããå³ä¸ã« "`.join" ãå¿ ãæ¿å ¥ããã¾ãããã®è¾ºãä¸æããã¨èª¿æ´ã§ããããã«ãããã£ãã®ã§ãããã³ã¼ããé·ããªãããã¦å¸¸èçãªãµã¤ãºã®AAã«åã¾ããªããªãããã ã£ãã®ã§æ念ãã¾ãããä¸çªæåã®ãã¯ããã ãã¯æåã§èª¿æ´ãã¦ããã¾ãã
- äºå¤åããAAãã¼ã¿ã¯ç°¡åãªã©ã³ã¬ã³ã°ã¹ç¬¦å·åãè¡ã£ã¦ãµã¤ãºãå§ç¸®ãã¦ãã¾ããç»åã®ã¿ã¤ãã«ãã£ã¦ã¯ç¬¦å·åããªãæ¹ããµã¤ãºãå°ããã±ã¼ã¹ãããã¾ãã®ã§ããããµã¤ãºã®å°ãããã®ãæ¡ç¨ããããã«ãªã£ã¦ãã¾ãã
- ãã®ä»ã¯ãè¨äºã®æåã«ã¯ã£ãå ãã¿ãªã³ã¯å ã¨ã»ã¼åãææ³ã使ããã¦ããã£ã¦ãã¾ãã
ããããå¤æãã¦ã¿ã
ãã¡ãã¡Quineåããã³ã¼ãããã®ã¾ã¾è²¼ãä»ããã¨é·ããªã£ã¦ãã¾ãã®ã§ãå ç»åã¨ãQuineåãããã®ãç»ååãããã®*4ã並ã¹ã¾ãã
ããããã¾
ä¾ãã°ç§ã®ã¢ã¤ã³ã³ããã£ããã嬢æ§ã§ãããæ¯è¼çQuineåããããã¿ã¤ãã®ç»åã§ãã
$ ruby mikusan.rb ozeusama.png 80 0.6
æ©èãã
ãããçµµãQuineåã«é©ãã¦ãã¾ããã¨ããããã®AA Quineèªä½ãæåã«ãããããçµµãªã®ã§å½ç¶ã¨ããã°å½ç¶ã§ããã*5
$ ruby mikusan.rb sanaesan.png 80 0.49
ãããçµµã¯ãã¡ããããåããã¾ããããããã¨ããããã¾ãã
èªéãã
å®å
¨ã«ä¸è´ã*6
$ ruby mikusan.rb jichoushiro.jpg 200
ç»åã¯ãã¡ããããåããã¾ããããããã¨ããããã¾ãã
大ããªãã¯ãã
é å¼µãã°ãããªå¤§ããªã¤ã©ã¹ãã ã£ã¦ï¼*7
$ ruby mikusan.rb mikusan3.png 1024 0.6
ç»åã¯ãã¡ããããåããã¾ããããããã¨ããããã¾ãã
ãããªãµã¤ãºã§ãã¡ããã¨Quineã«ãªã£ã¦ã¾ãã
$ ruby mikusan.rb mikusan3.png 1024 0.6 > ookinamikusan.rb $ ruby ookinamikusan.rb | ruby | ruby | ruby | ruby | ruby | diff ookinamikusan.rb - $
æå¾ã«
ä¸çªæåã®ãã¯ããQuineãçæããã³ã¼ããã¯ã£ã¦ããã¾ãã
ããã¤ã以ä¸ã®ããã«å®è¡ãã¦ãä¸çªæåã®ãã¯ãããä½ãã¾ãããããã°ååã®ãã¯ããã¨ãã®åµé 主ã
$ ruby quineaa.rb mikusan.png 90 0.6 > mikusan.rb
ãã¡ãã¯ã¸ã§ãã¬ã¼ã¿ã¨ãã¦ã®ã³ã¼ããµã¤ãºãçµæ§ãã*8ãããããç¨åº¦ãã£ãã·ãã£ã大ãã*9ç»åã§ãªãã¨ãçæã¯é£ããããããã¾ããã
æå¾ã®æå¾ã«
å ãã¿ã®å ãã¿çãªè³æãã¯ã£ã¦ããã¾ãã
æ¬å½ã«åãQuineã¯æå³ããããã¾ããã*10
â»è¿½è¨ï¼2010å¹´9æ20æ¥ï¼
å¾ããè¦ç´ãã¦ã¿ããè²ã ã¨ç¡é§ãå¤ãã£ãã®ã§ã mikusan.rb 㨠quineaa.rb ãæ´æ°ãã¾ããã
å¦çé¨ã®ã³ã¼ãéãæ¸ã£ã*11ããããã¯ãããã¹ãªã åãã¦ã¾ãã
æ°ãããã¯ããã¯
$ ruby quineaa.rb mikusan.png 80 0.6 > mikusan.rb
ã§çæãã¦ã¾ãã
æ´æ°å 容ã¯ä»¥ä¸ã®éãã§ãã
- 大æµã®å ´åã«ããã¦ãã©ã³ã¬ã³ã°ã¹ç¬¦å·åããZlibã使ã£ã¦å§ç¸®ããã»ãããã¼ã¿ãµã¤ãºãå°ãããªã£ããããç´ ç´ã«Zlibã使ãããã«ãã¾ããã
- ã©ã ãå¼ã®æ§æãããçããã®ã«å¤æ´ãã¾ããã
- ifæãä¸é æ¼ç®åã«ç½®ãæãã¾ãããï¼ifèå¥åã¯é¤ãï¼
- ãã®ä»ãåãæ©è½ãæã¤ããçãå称ã®ã¡ã½ãããå¼ã¶ããã«ãããªã©ãæåæ°ãåæ¸ãã調æ´ãè¡ãªãã¾ããã
- çæããã³ã¼ãä¸ã«ããã¯ã¹ã©ãã·ã¥ãå«ã¾ãã¦ãããç¹å®ã®AAãã¿ã¼ã³ã§æ£ããåä½ããªããªã£ã¦ããããããããä¿®æ£ãã¾ããã
ãã¨ãæ¸ãå¿ãã¦ãã¾ããããRuby 1.9以éã§ãªãã¨åä½ããªãã¨æãã¾ãã
*1:ãã¼ã¸ã§ã³1ç³»ã§ã¯åä½ç¢ºèªãã¦ãã¾ããã
*2:ãã ããå ã çã£ç½ãªç»åã¯ã©ãé å¼µã£ã¦ãQuineåã§ãã¾ããã
*3:ãããã¯line-heightãªã©ã®å¤
*4:ããããã
*5:ãªã®ã§ãæ¥æ¬ã§ä¸è¬çãªãããã¼ã·ã§ãã«ãã©ã³ããæ´»ç¨ããAAã¨ã¯æ ¹æ¬çã«æ§è³ªãç°ãªãã¾ãããã£ã¡ã¯æ¬å½ã«ã¢ã¼ãã
*6:ãã¢ã¹ãã¯ãæ¯ãããã¦ããã大ä¸å¤«ãï¼ãã大ä¸å¤«ã ãåé¡ãªãã
*7:ã¿ã¼ããã«ã§ã¯å¤§ãããã¦ä½ãä½ã ããããã¾ããã
*8:1300byteå¼±ããã
*9:ã¤ã¾ãé»ã¨å¤å®ã§ããé åã®å ããå²åã大ãã
*10:æèã«ã¼ãã³çµã¿è¾¼ã¿ã¨ãã¯ãªã¹ãã¹ã½ã³ã°æ¼å¥æ©è½çµã¿è¾¼ã¿ã¨ããããããããã¨æã£ãçºæ³ãå«ãã¦ã
*11:1300byteå¼±ãã1000byteå¼·ããã
è²æ°ã®ããã¿ã¼ããã«ãã¤ããã
ä»ã¾ã§ã¿ã¼ããã«ç°å¢ã®ã«ã¹ã¿ãã¤ãºã«ãã¾ãèå³ãåãã¦ããªãã£ãç§ã§ããããããã«æè¿ãç½èæ¯ã«é»æåãã®å³æ°ãªãç»é¢ã«ç©è¶³ããªããæããããã«ãªã£ã¦ãã¾ããã
ã ãããä¸ã®ç»åã¿ãããªãããã§ããã»ã¼ããã©ã«ãé è²ã®Poderosaã«ãåããããã©ã«ãé è²ã®Vimã
æ°åããä½æ¥ããã«ã¯ãããå°ãè²æ°ã欲ããããªãâ¦ã£ã¦ãã¨ã§ãè²ã å ¥ãæ¿ãã¦ã¿ã¾ããããã£ãããªã®ã§ããã®ã¡ã¢ãæ®ãã¦ãããã¨æãã¾ãã
ãªããã¯ã©ã¤ã¢ã³ãOSã¯Windows 7 Professional 64bitããµã¼ãOSã¯CentOS 5.5 64bitã¨ãªã£ã¦ãã¾ãã
è²æ°ã®ããç»é¢ã¨ã¯
ã¾ãã¯ãã©ã®è¾ºã®è¦ç´ ãæºãããã¦ããã°ãè²æ°ã®ããç»é¢ãã¨è¨ããã®ããèãã¦ã¿ããã¨æãã¾ãã
å®å ¨ã«å人çãªæè¦ã§ããããã£ã¨æ¬¡ã®ãããªã¨ããã§ããããã
- 綺éºãªãã©ã³ã
- åºæ¬ã§ãããå人çã«ã¯è§å¼µã£ããã®ããæãããªå°è±¡ãä¸ãããã®ã®ã»ãã好ã¿ã§ãã
- 256è²è¡¨ç¤º
- ãããæ¬ ãããªãã§ããããè²ãå¤ãã¨ããã ãã§ãªãã¨ãªãè½ã¡çãã¾ãã
- ã½ãããªé è²
- ã½ãããªé è²ãããããã¯ã£ããããé è²ããããã¯å¥½ã¿ã®åé¡ã§ãããããç§ã¯ãã¾ãã³ã³ãã©ã¹ãã®é«ããªãé è²ã好ãã§ãã
- èæ¯ç»å
- å®ç¨æ§ã¯çç¡ã§ããããã£ã±ãèæ¯ã«èãç»åã表示ããã¦ããã»ãããããã£ã½ããã§ãããï¼å´ã£ã¦æåãè¦é£ãã¨ãè¨ããªãã
- ãã¤ã³åå²
- ãããããã«ã¼ã£ã½ãã¦ç´ æµãªè¦ç´ ã§ããï¼ãã ããã¡ãã¯å®ç¨æ§ãå ¼ãåãã¦ããã¨æãã¾ãã
ããããæºããç°å¢ãä½ã£ã¦ããã¾ãã
端æ«ã¨ãã¥ã¬ã¼ã¿é¸ã³
ãªã«ã¯ã¨ããã端æ«ã¨ãã¥ã¬ã¼ã¿ã
é·ããã¨Poderosaã«ãä¸è©±ã«ãªã£ã¦ãã¾ããããããã¯256è²è¡¨ç¤ºã«å¯¾å¿ãã¦ããªãã®ã§ãæ®å¿µãªãããããªããããã¨ã«ãªãã¾ããã
ä»ã«ããè¤æ°ã¿ãã§sshã»ãã·ã§ã³ãç¡é ä½ã«ç«ã¡ä¸ãã¾ããæ¹å¼ãããæå°éã®ã»ãã·ã§ã³å ã§ä»®æ³ç»é¢ã管çãããããªããã£ã¨ã¹ãã¼ããªä½¿ãæ¹ã«ç§»è¡ãããã£ãâ¦ã¨ããç®çãããã¾ãã
ããããããã§ã端æ«ã¨ãã¥ã¬ã¼ã¿ã«ã¯PuTTYãæ¡ç¨ãPoderosaã使ãå§ããåã«ä¸ææ使ã£ã¦ãããã¨ãããã¾ãã®ã§ãåºæ»ãã¨ããå½¢ã«ãªãã¾ããï½
PuTTYã®ããªã¨ã¼ã·ã§ã³é¸æ
PuTTYèªä½ã«ãè²ã ã¨ããªã¨ã¼ã·ã§ã³ãããã¾ãã¦ã
PuTTY本家ãごった煮版ã«ã¯ãxterm風ééãããããããå£ç´ãè¨å®ããå ´åã«ããã«ããã¤ãæåã®èæ¯ãæ£å¸¸ã«ééããªããªã©ãããã¤ãã®ç´°ããªåé¡ãããã¾ãã
æ®éã«ä½¿ã£ã¦ããåã«ã¯åé¡ã«ãªããªãã®ã§ãããè²æ°ã®ããç»é¢ãç®æã以ä¸ã¯ãããã¯å¦¥åã§ããªãã ããâ¦ï¼ã¨ãããã¨ã§ããã®ãããã解決ããã¦ããæ´¾ççãããã¤ãæ¢ãã¦ã¿ã¾ããã
- PuTTY for Win32 background image patch @ 7bit
- PuTTY ごった煮版で壁紙がうまく表示されないバグを直してみた - mknkのLinux系技術ぶろぐ
- PuTTY PRIVATE PATCHES : iceiv+putty
- D2D/DW PuTTY : iceiv+putty
ä»åã¯ããããããç»åã«ããèæ¯æå®ã§ã¯ãªããxterm風ééã使ã£ã¦ãã¹ã¯ãããã®å£ç´ã表示ãããã¨æãã¾ããä¸2ã¤ã¯ããããããç»åã®èæ¯è¡¨ç¤ºã«ç¹åãããããã®ããã§ããã®ã§ãICE IVããã®ã«ã¹ã¿ãã¤ãºçï¼ä¸ãã2çªç®ï¼ã使ããã¦ããã ããã¨ã«ãã¾ããã
ICE IV+PuTTYã«ã¯ä»ã«ãè²ã 便å©ãªæ©è½ã追å ããã¦ããä¸ã«ãä»ãç²¾åçã«ã¢ãããã¼ããéãããã¦ããããã§ãã®ã§ãä»ã®æ¹ã«ã¨ã£ã¦ãããªãæåãªé¸æè¢ã«ãªãã®ã§ã¯ãªããã¨æãã¾ãããã¼ã¹ã¨ãªã£ã¦ãããªãªã¸ãã«ã®ã½ã¼ã¹ã³ã¼ããä»ã®ã«ã¹ã¿ãã¤ãºçããæ°ããã¨ããç¹ãç´ æµã
ICE IV+PuTTYã«ã¯ã¬ã³ããªã³ã°ã¨ã³ã¸ã³ãDirect2D/DirectWriteã«å¤æ´ããæ´ãªãã«ã¹ã¿ãã¤ãºçï¼ä¸çªä¸ï¼ããããç´°ãããªããã¹ãã®ã¬ã³ããªã³ã°æå®ãªã©ãé åçãªæ©è½ãå¤ãã£ãã®ã§ãããã¾ã éçºéä¸ã¨ãããã¨ããããå®å®åº¦ã®é¢ã§GDIçãé¸æãã¾ãããD2D/DWçãå®å®ãã¦ãããåä¹ãæ¿ããæ¤è¨ãã¦ã¿ããã¨æãã¾ãã
ICE IV+PuTTYã®ã¤ã³ã¹ãã¼ã«
zipã¢ã¼ã«ã¤ãã§é å¸ããã¦ãã¾ãã®ã§ãサイトに書かれているとおりã«å¿ è¦ãªãã¡ã¤ã«ãã³ãã¼ãã¦å®äºã§ããOSã64bitãªã®ã§ããã£ããã§ãã64bitçã使ã£ã¦ã¿ããã¨ã«ãã¾ãããè¨å®ã¯ã¬ã¸ã¹ããªã§ã¯ãªãiniãã¡ã¤ã«ã«ä¿åããããã«ã
ãã®PuTTYã«å¯¾ããè¨å®ãä¸å¿ã«ãããã¤ãã«ã¹ã¿ãã¤ãºãè¡ã£ã¦ããã¾ãã
ãã©ã³ãã®è¨å®
ããã°ã©ãã³ã°ã«é©ãããã©ã³ãã«ã¤ãã¦ã¯ãè²ããªã¨ããã§ç´ æµãªãã©ã³ãã®æ å ±ãè¦ããããã¨ãã§ãã¾ãã
ããã¤ãåå³ããä¸ã§ãä¸è¨ã®ãµã¤ãã§ç¥ã£ããInconsolata + Takaoã´ã·ãã¯ãã®çµã¿åãããå人çã«æ°ã«å ¥ãã¾ãããä»åã¯ãããæ¡ç¨ãããã¨ã«ãã¾ãã
ä¸è¨ãµã¤ãã«ã¯ãInconsolataã¯otfãã¡ã¤ã«ã¨ttfãã¡ã¤ã«ã¸ã®2種é¡ã®ãªã³ã¯ãããã¾ãããOpenTypeãªãã©ã³ãã¯å¾è¿°ããFontLinkã使ããªãããã§ãã®ã§*1ãttfãã¡ã¤ã«ããã¦ã³ãã¼ããã¦ã¤ã³ã¹ãã¼ã«ãã¾ããTakaoãã©ã³ããåæ§ã«ã¤ã³ã¹ãã¼ã«ã
FontLink
ãã¦ããããã®ãã¡ã¤ã«ãPuTTYã§ä½¿ããã©ã³ãã¨ãã¦è¨å®ãããã®ã§ãããããã«ãPuTTYã¯è±æãã©ã³ãã¨æ¥æ¬èªãã©ã³ããå¥ã ã«æå®ãããã¨ãã§ãã¾ããã*2
ãã®ã¾ã¾ãã©ã³ãã«Inconsolataãæå®ããã¨ãæ¥æ¬èªé¨åã«MSã´ã·ãã¯ã使ããããããã¡ãã£ã¨æ®å¿µãªè¦ãç®ã«ãªãã¾ãã
ããã解決ããã«ã¯ã以ä¸ã®ãµã¤ãã§è§£èª¬ããã¦ãã FontLink ã¨ããæ©è½ãå©ç¨ãã¾ãã
ç°¡åã«ããã¨ãããã®ãã©ã³ãã«å«ã¾ãã¦ããªãæåãå¼ã³åºãããã¨ãã«ããããã«ã©ã®ãã©ã³ãã使ããããæå®ã§ããæ©è½ã§ããFontLinkã§Inconsolataã¨Takaoã´ã·ãã¯ãçµã¿åãããã°ãASCIIæåã¯Inconsolataããã«ããã¤ãæåã¯Takaoã´ã·ãã¯ã§è¡¨ç¤ºããããã¨ãã§ãã¾ãã
è¨å®æ¹æ³ã¯ãã¬ã¸ã¹ããªã®ãHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontLink\SystemLinkãã«ã
åå | ç¨®é¡ | ãã¼ã¿ |
---|---|---|
Inconsolata | REG_MULTI_SZ | TakaoGothic.ttf*3 |
ã¨ãããã¼ã¿ã追å ããã ãã§ããã¨ã¯ããã¬ã¸ã¹ããªã®ç·¨éãªã®ã§ãèªå·±è²¬ä»»ã«ããã¦æ éã«ã
ãã¨ã¯Windowsãåèµ·åããã°ãä¸è¨ã®è¨å®ãæå¹ã«ãªãã¾ãã
PuTTYã«ãã©ã³ããè¨å®
ãã®InconsolataãPuTTYã®ãã©ã³ãã¨ãã¦æå®ãããããã§ãããä½æ ãGUIã®ãã©ã³ãé¸æç»é¢ã«è¡¨ç¤ºãããªã*4ãããputty.ini ãç´æ¥ç·¨éãã¦æå®ãã¾ãã
ç§ã®ç°å¢ã§ã¯ãã©ã³ããµã¤ãºã13ã«æå®ããã¨ãæ¥æ¬èªæåã綺éºã«ã¬ã³ããªã³ã°ããã¦è¦ãããã£ãã®ã§ããããã¤ãã§ã«æå®ãã¦ããã¾ãã
Font="Inconsolata" FontHeight=13
åããPuTTYã®è¨å®ã§ããã¦ã£ã³ã㦠> å¤è¦³ > ãã©ã³ãã®å質ãããã¯ãªã¢ã¿ã¤ãããããã«ãã¦ããã¾ããããã¨ããã¦ã£ã³ã㦠> å¤æ > Remote character setãããUTF-8 (CJK)ãã«å¤æ´ããããä¸ã®ãCJK ç¨ã®æåå¹ ã使ç¨ãããã«ãã§ãã¯ãå ¥ãã¦ããã¾ãããããã¯GUIã§è¨å®ãã¦å¤§ä¸å¤«ã
ããã§ãã©ã³ãã®è¨å®ã¯å®äºã§ãã
ã«ã©ã¼ã®è¨å®
PuTTYèªä½ã®è²è¨å®
PuTTYèªä½ã®è²è¨å®ã¯ãGoogleå çã«ã伺ãããã¦ãçµæã以ä¸ã®ãµã¤ãã§é å¸ããã¦ããé è²ãæ°ã«å ¥ã£ãããã使ããã¦ããã ããã¨ã«ãã¾ããã
ãã ããèªåã®ç°å¢ã§ã¯PuTTYã®è¨å®ãã¬ã¸ã¹ããªã§ã¯ãªãiniãã¡ã¤ã«ã«ä¿åãã¦ãããããä¸è¨ãµã¤ãã§ãã¦ã³ãã¼ãã§ããregãã¡ã¤ã«ã¯ä½¿ãã¾ããã
ãããã« putty.ini ã以ä¸ã®ããã«ç·¨éãã¾ãã
Colour0="212,212,212" Colour1="255,255,255" Colour2="45,45,45" Colour3="63,63,63" Colour4="0,0,0" Colour5="162,223,169" Colour6="45,45,45" Colour7="0,0,0" Colour8="231,126,126" Colour9="231,126,126" Colour10="231,225,154" Colour11="255,255,128" Colour12="128,128,255" Colour13="70,70,255" Colour14="102,185,217" Colour15="141,203,226" Colour16="222,116,146" Colour17="0,166,166" Colour18="131,224,135" Colour19="114,216,132" Colour20="212,212,212" Colour21="255,255,255"
Colour22ã¨23ã¯ç¹ã«å¤æ´ãã¦ãã¾ããã
å ãã¦ããã¦ã£ã³ã㦠> è² > 太åã®ããã¹ãã¯å¥ã®è²ã«ãããã®ãã§ãã¯ãå¤ãã¦ããã¾ãããxterm 256 è²ã¢ã¼ãã使ããã¨ã許å¯ãããã¯æåãããã§ãã¯ãå ¥ã£ã¦ããã¨æãã¾ãã
ã·ã§ã«ã®è¨å®
CentOSãªãããã©ã«ãã§é©åãªè¨å®ãããã¦ãã¾ãã®ã§ãç¹ã«ãããã¨ã¯ããã¾ããã
Vimçã§ã®è¡¨ç¤ºç¨ã«ãTERM ç°å¢å¤æ°ãè¨å®ããå¿ è¦ã¯ããããããã¾ãããBashã使ã£ã¦ããå ´å㯠.bashrc ã«
export TERM=xterm-256color
ã追å ãã¦ããã¾ãã
256è²è¡¨ç¤ºã®ç¢ºèª
以ä¸ã®ãµã¤ããã256colors2.plãè½ã¨ãã¦ãã¾ãã
å®è¡ãã¦ä»¥ä¸ã®ããã«ç¶ºéºã«256è²è¡¨ç¤ºãããã°OKã§ãã
Vimã®ã«ã©ã¼ã¹ãã¼ãã®è¨å®
ç§ã¯ã¨ãã£ã¿ã«Vimã使ã£ã¦ãã¾ãã
Vimã®ã«ã©ã¼ã¹ãã¼ãã¯ãããããç®ç§»ãããã»ã©å¤ãã®é¸æè¢ãããããã§ãããæ©ãã çµæãzenburnã使ããã¨ã«ãã¾ããã
以ä¸ã®ãã¼ã¸ããææ°ã® zenburn.vim ãè½ã¨ãã¦ã㦠~/.vim/colors ã«è¨ç½®ãã¾ãã
ãã®ã¾ã¾ä½¿ãã¨ãVimãç«ã¡ä¸ãã¦ããéã¯å ¨é¢ãzenburnã«ãã£ã¦æå®ãããèæ¯è²ã«ãã£ã¦å¡ãã¤ã¶ãããèæ¯ãééããªããªã£ã¦ãã¾ãã¾ãã®ã§ã以ä¸ã®ããã«èæ¯è²ã®æå®ãåé¤ãã¦ããã¾ãã
240c240 < hi Normal ctermfg=188 ctermbg=237 --- > hi Normal ctermfg=188
ãã¨ã¯ .vimrc ã«ä»¥ä¸ã®è¡ã追å ãã¦Vimã®è¨å®ã¯å®äºã
colorscheme zenburn
èæ¯ã®è¨å®
èæ¯ã¯åè¿°ããéããããããããç»åã«ããæå®ã§ã¯ãªããxterm風ééã使ãã¾ãã
xterm風ééãé¸ãã ã®ã¯ãWindowsã®ãã¼ãè¨å®ã§ãã¹ã¯ãããèæ¯ã«æ°ååä½ã§è¤æ°ã®ç»åãåãæ¿ããã¹ã©ã¤ãã·ã§ã¼ãé©ç¨ãã¦ããããããã¡ããééããã»ãã飽ããããªãã ãããã¨ããçç±ããã§ãã
ICE IV+PuTTYã§ã¯ä»ã«Aero Glassã«ããééã¨ãã§ã¯ãã¨ããç´ æ´ãããé¸æè¢ãããã®ã§ãããå人çã«ã¯å¾ãã®ã¦ã£ã³ãã¦ãéãã¦ãã¦ããã¾ãå¬ãããªãã®ã§ããã¡ãã¯ãã¹ãã¾ããã
PuTTYã®è¨å®ç»é¢ã§ãã¦ã£ã³ã㦠> å£ç´ > èæ¯ééã¢ã¼ããã«ãxterm風ééããæå®ããããä¸ã®ãèæ¯ç»åã®ã¢ã«ãã¡å¤ããã64ããããã«ãã¦ããã¾ãããã®è¾ºã¯å¥½ã¿ã§èª¿æ´ãããã¨ã«ãªããã¨æãã¾ãã
å ç¨zenburnã®èæ¯è²æå®ãæ¶ãã¦ããã¾ããã®ã§ãããã§å¸¸ã«èæ¯ã«ãã¹ã¯ãããã®å£ç´ãéé表示ãããããã«ãªãã¾ãã
ãã ãæ®å¿µãªãã¨ã«ãééããèæ¯ç»åã®æ´æ°ã¯PuTTYã移åããã¨ãããªãµã¤ãºããã¨ãã«ã®ã¿è¡ãããããã§ããã¹ã¯ãããã®ã¹ã©ã¤ãã·ã§ã¼ã«ããåãæ¿ãããªã¢ã«ã¿ã¤ã ã«åæ ããããã¯ããªãããã§ãããããã§ããã¨ããç´ æ´ãããã®ã§ããâ¦ã
tmuxã®ã¤ã³ã¹ãã¼ã«
æå¾ã«æ®ã£ãã®ã¯ãã¤ã³åå²ã§ããPuTTYèªä½ã«è¡¨ç¤ºãã¤ã³ã®åå²æ©è½ã¯ããã¾ããã®ã§ã端æ«å ã§ä»®æ³ç»é¢ã管çãã screen çãªã½ããã¦ã§ã¢ãå©ç¨ãã¾ãã
ãã®ã¾ã¾ç´ ç´ã«screenã使ã£ã¦ãè¯ãã£ãã®ã§ãããtmux ã¨ãã代æ¿ã½ãããããããã§ãã
ç»é¢ã®ç¸¦åå²ãããã¯ãscreenã§ãææ°ã®éçºçã§ã¯å®ç¾ããã¦ãã¾ãã®ã§ãæ£ç´ã©ã¡ãã§ãè¯ãã£ãã®ã§ãããããã©ã«ãã®æåããã好ã¿ã ã£ãã¨ããçç±ã§ãä»åã¯tmuxã使ã£ã¦ã¿ããã¨ã«ãã¾ããã
ã½ã¼ã¹ããã¤ã³ã¹ãã¼ã«ããæ¹æ³ãããã¾ãããRPMforgeã«2010å¹´9æ2æ¥æç¹ã®ææ°çã§ãããã¼ã¸ã§ã³1.3ã®RPMãããã¾ããã®ã§ããã¡ãã§ã¤ã³ã¹ãã¼ã«ãã¾ããã
tmuxã®è¨å®
tmuxã®è©³ããæä½æ¹æ³ãè¨å®æ¹æ³ã¯ãã¾ã ç§ã使ãããªãã¦ããªããããæ¥ãæ¹ãã¦èª¿æ»ãã¦ã¿ããã¨æãã¾ãã
ä¸è¨ã®ãµã¤ãã«å ãã以ä¸ã®ãµã¤ããåèã«ãªãã¾ãã
- 端末の中で仮想端末を管理するtmux(GNU screenの代替)について(概要・実行・操作) - 試験運用中なLinux備忘録 åã³ãã®é¢é£è¨äº
- Manpage of TMUX
ã¨ããããæä½éã以ä¸ã®è¨å®ã ~/.tmux.conf ã«ãã¦ããã°ãå人çã«éåæãªã使ãã¾ããã
set-option -g prefix C-z set-window-option -g mode-keys vi
ããã©ã«ãã§Prefix+ã«ã¼ã½ã«ãã¼ã§ãã¤ã³ã®ãã©ã¼ã«ã¹åãæ¿ããã§ããã®ãç´ æµã
PuTTYã®ãµã¤ãºè¨å®
tmuxã«ãã£ã¦åä¸ç»é¢å ã«è¤æ°ãã¤ã³ã表示ãã¾ãã®ã§ãPuTTYã®ç»é¢ãµã¤ãºã¯å¤§ããæ¹ãè¯ãã§ãã
ãã«ã¹ã¯ãªã¼ã³ã«ãã¦ãããã®ã§ãããTwitterã¯ã©ã¤ã¢ã³ããªã©ãåæã«è¡¨ç¤ºãã¦ãããããã®ãä»ã«ããã¤ããã£ããããåã«å¤§ããªã¦ã£ã³ãã¦ãµã¤ãºãæå®ããã ãã«ã¨ã©ãã¦ããã¾ããã
PuTTYã®è¨å®ç»é¢ã®ãã¦ã£ã³ã㦠> ã¦ã£ã³ãã¦ã®ãµã¤ãºã®æå®ãã§æ¡ã180ãè¡ã60ãããããããããããã¨ãå·¦å³ã«ãã¤ã³åå²ãã¦ãã£ã¦ãããããã80æ¡ä»¥ä¸è¡¨ç¤ºã§ããã®ã§è¯ãã§ãã
ãã ãInconsolata+Takaoã´ã·ãã¯ã®ãã©ã³ããµã¤ãº13ã§ãã®ãµã¤ãºæå®ã«ããã¨ãWUXGAæªæºã®è§£å度ã®ã¢ãã¿ã ã¨ã¹ãã¼ã¹çã«å³ããããããã¾ããã
ãã®ä»ã®è¨å®
ãã®ä»ãè¦ãç®ã«é¢ãããã®ã§ã¯ããã¾ããããå人çãªå¥½ã¿ã¨ãã¦ãPuTTYã«å¯¾ãã¦ä»¥ä¸ã®è¨å®ããã¦ããã¾ããã
- ãç«¯æ« > ãã« > ãã«ã®é³´ããããããããªããã«ãã
- ãã¦ã£ã³ã㦠> åä½ > ALT-Space ã§ã·ã¹ãã ã¡ãã¥ã¼ã表示ãããããã§ãã¯ãã
- ãã¦ã£ã³ã㦠> åä½ > Alt-Enter ã§ãã«ã¹ã¯ãªã¼ã³ã«ãããããã§ãã¯ãã
- ãã¦ã£ã³ã㦠> åä½ > Ctrl + TABã§PuTTYã®ã¦ã£ã³ãã¦ãåãæ¿ãããããã§ãã¯ãã
- ãæ¥ç¶ > SSH > èªè¨¼ > Attempt GSSAPI auth (SSH-2)ãã®ãã§ãã¯ãå¤ã
ã¾ã¨ã
ã ãã ãã¨æ¸ãã¦ãããéåã¨é·ããªãã¾ããããæçµçã«ä»¥ä¸ã®ãããªç»é¢ã«ãªãã¾ããã
ã¡ãã£ã¨ã¯ãè²æ°ã®ããç»é¢ãã«ãªã£ãããªâ¦ï¼*5
ãã¨ã¯tmuxãã¬ã³ã¬ã³ä½¿ãè¾¼ãã§ããæãã§ããä¸ã®ä¸ã«ã¯こんな風にscreenを使いこなしている方ãããã£ãããããã§ããâ¦ã
ãããã«ããã¾ã§ã¨ã¯ããã¾ããããã¼ã¡ã¼ã¡ã«ã¹ã¿ãã¤ãºãã¦ããããã¨æãã¾ãã
*1:é¢åãªã®ã§å®éã«ç¢ºèªã¯ãã¦ãã¾ããã
*2:åè¿°ã®ICE IV+PuTTY D2D/DWçãªãå¥ã ã«æå®ã§ãã¾ããã§ãããªããæ¥æ¬èªãã©ã³ãã常ã«ã¡ã¤ãªãªã«ãªã£ã¦ãã¾ãâ¦ã
*3:ç§ã®ç°å¢ã§ã¯ãä½åº¦ããã©ã³ããã¤ã³ã¹ãã¼ã«ãç´ããããã¦ãããããããã©ã³ãåã"TakaoGothic_1.ttf"ã«ãªã£ã¦ãã¾ããã
*4:ç§ã¯è©¦ãã¦ãã¾ããããåèã¾ã§ã«ï¼Windows 7 で任意のフォントが使えない場合: 世の中は不思議なことだらけ
*5:ã¡ãªã¿ã«ãæ®æ®µã¯ãããªã¯ã¼ã«ã£ã½ãå£ç´ã«ã¯ãã¦ãã¾ãããåºæ¬çã«æå°å¥³ã°ããã®å¼¾å¹ç³»STGãã£ã©ç100%ã§ããã¡ãã£ã¨æ¥åãã¾ãããããããªããã
ãã³ãã³å¤§ç¾ç§ã¨ãã¯ããã£ã¢ã§ç¸äºã«ãªã³ã¯ãã¯ãGreasemonkeyã¹ã¯ãªãã
ニコニコ大百科ã¨ピクペディアã£ã¦ãæ©è½èªä½ã¯ã»ã¼åä¸ã§ãããè¨äºã®å 容ã«ã¯ãã¯ãããããã®ç¹è²ããã£ãããªãã£ãããã¾ãããããã¾ãããï¼ããªãããããã¾ããã
ãããªãã¨ãèãã¤ã¤ãç°¡åãªã°ãªã¢ã³ãæ¸ãã¦ã¿ã¾ããã
ã¤ã³ã¹ãã¼ã«æ¹æ³
以ä¸ã®ãªã³ã¯ããã¤ã³ã¹ãã¼ã«ãã¦ãã ãããå½ç¶ãªããGreasemonkeyãã¤ã³ã¹ãã¼ã«ããã¦ããå¿ è¦ãããã¾ãã
ãã¨ãSelectors APIã使ã£ã¦ããã®ã§ãFirefox 3.1以éãããªãã¨åããªãã¨æãã¾ãã
æ©è½
æ©è½ã¯ä»¥ä¸ã®4ã¤ã®ã¿ã§ãã
ãã³ãã³åç»è¦è´ãã¼ã¸ã®åã¿ã°æ¨ªã«ããã¯ããã£ã¢ã®è©²å½è¨äºã¸ã®ãªã³ã¯ãã¯ãã¾ãã
ãã³ãã³å¤§ç¾ç§ã®è¨äºã¿ã¤ãã«æ¨ªã«ããã¯ããã£ã¢ã®è©²å½è¨äºã¸ã®ãªã³ã¯ãã¯ãã¾ãã
Pixivã¤ã©ã¹ãé²è¦§ãã¼ã¸ã®åã¿ã°æ¨ªã«ããã³ãã³å¤§ç¾ç§ã®è©²å½è¨äºã¸ã®ãªã³ã¯ãã¯ãã¾ãã
ãã¯ããã£ã¢ã®è¨äºã¿ã¤ãã«æ¨ªã«ããã³ãã³å¤§ç¾ç§ã®è©²å½è¨äºã¸ã®ãªã³ã¯ãã¯ãã¾ãã
注æç¹
- ãã³ãã³åç»ãPixivå´ã®ãã¼ã¸ã§ã³ã¢ããã«ãããåä½ããªããªãå¯è½æ§ãããã¾ãã
- ãã³ãã³å¤§ç¾ç§ã¯è¨äºã®åå¨ç¢ºèªã«ãã³åæ¬ä½ã使ã£ã¦ãããã®ã¨åãAPIãå©ç¨ãã¦ããã®ã§å¤å大ä¸å¤«ãããªããã¨æãã¾ããããã¯ããã£ã¢ã¯ãããããã®ããªããããªã®ã§ãæ¯åè¨äºã®ãã¼ã¸ã«ã¢ã¯ã»ã¹ãã¦ãã¾ããããããããæãããããã
ã½ã¼ã¹
ãã®ä»
ãã°ã¨ãçºè¦ãããæ¹ã¯æ¯éæãã¦ãã ããã
Sequelã®Tipsã®ãããªãã®
Rubyã«ããã軽éãªãã¼ã¿ãã¼ã¹ãã¼ã«ãããã¨ãã¦ããªããªããæ軽ãªSequelã§ãããå®éã«ä½¿ãã«ããã£ã¦ããã¤ãæ©ãã ãã¤ã³ãããã£ãã®ã§ãåå¿é²ã¨ãã¦ãã®è§£æ±ºæ³ãã¡ã¢ãã¦ããã¾ãã
ãªãããã®è¨äºã¯Ruby 1.9.1p378ã¨Sequel 3.8.0ã®çµã¿åããã対象ã¨ãã¦æ¸ãã¦ãã¾ãã
ã¢ãã«ã®å®ç¾©åã«DBæ¥ç¶ãããããªã
Sequelã«ãActiveRecordãã¿ã¼ã³ã«åºã¥ããã¢ãã«ã®ä»çµã¿ãç¨æããã¦ãã¾ããããã¢ãã«ãå®ç¾©ããæç¹ã§ãã¼ã¿ãã¼ã¹ã¸ã®æ¥ç¶ãåå¨ãã¦ããªããã°ãªããªããã¨ããå¶ç´ãããã¾ãã
ã¤ã¾ãã
require 'sequel' Sequel.connect('sqlite://test.db') class User < Sequel::Model; end p User.all
ã¯åãã¾ããã
require 'sequel' class User < Sequel::Model; end # Sequel::Error Sequel.connect('sqlite://test.db') p User.all
ã¯åãã¾ããã"No database associated with Sequel::Model"ã¨ãã£ã¦æããã¾ãã
ãã®å¶ç´ãã©ãããã¨ãã«ä¸ä¾¿ãã¨ããã¨ãä¾ãã°
require 'sequel' class App def self.connect_database(option) Sequel.connect(option) end class User < Sequel::Model; end # Sequel::Error end App.connect_database('sqlite://test.db') p App::User.all
ã®ããã«ããã¼ã¿ãã¼ã¹é¢é£ã®å®ç¾©ãã¯ã©ã¹ãã¢ã¸ã¥ã¼ã«ã®ä¸ã«æ¼ãè¾¼ãããã¨ããã¨ããã¡ãã£ã¨ç¶ºéºã«æ¸ããªããªã£ã¦ãã¾ãã¾ãã
ããã¯module_evalã使ããã¨ã§è§£æ±ºã§ãã¾ãã
require 'sequel' class App class << self def connect_database(option) Sequel.connect(option) define_models end def define_models module_eval %{ class User < Sequel::Model; end } end end end App.connect_database('sqlite://test.db') p App::User.all
å®éã«ã¯ã¢ãã«å®ç¾©ã®ã¿ã¤ãã³ã°ãé ããã¦ããã ããªã®ã§ãããã¨ãããããããã£ã½ãæ¸ããããã¨ããç®çã¯éæã§ããããªãã¨ã
ãªããSequel::Modelãç¶æ¿ããã¯ã©ã¹ã¯ãæ¾ã£ã¦ããã¨åæã«ãããã¾ã§ã«æ¥ç¶ããä¸çªæåã®ãã¼ã¿ãã¼ã¹ãã¨é¢é£ä»ãããã¦ãã¾ãã¾ããä¾ãã°è¤æ°ã®ã¯ã©ã¹ã§ããããå¥ã®ãã¼ã¿ãã¼ã¹ãåç §ããããå ´åã¯ã以ä¸ã®ããã«ã¢ãã«ã¯ã©ã¹ã®ç¶æ¿æã«ãã¼ã¿ãã¼ã¹ã®ã¤ã³ã¹ã¿ã³ã¹ã渡ãã¦ããã°OKã§ãã
require 'sequel' module App def connect_database(option) db = Sequel.connect(option) define_models(db) end def define_models(db) module_eval %{ class User < Sequel::Model(db); end } end end class AppA extend App end class AppB extend App end AppA.connect_database('sqlite://testa.db') AppB.connect_database('sqlite://testb.db') p AppA::User.all p AppB::User.all
ãã¾ãããããã±ã¼ã¹ããããã©ããã¯ãããã¾ãããâ¦ã
æåååã®ãã¼ã¿ãforce_encodingããã
ããã©ã«ãã§ã¯ãåå¾ããæåååãã¼ã¿ã®ã¨ã³ã³ã¼ãã£ã³ã°ã¯ASCII-8BITã«ãªã£ã¦ãã¾ãã
require 'sequel' Sequel.connect('sqlite://test.db') class User < Sequel::Model; end p User.first.name.encoding # => #<Encoding:ASCII-8BIT>
éä¸String#force_encodingãããã¦ãããã®ã§ãããé¢åãªå ´åã¯ForceEncodingãã©ã°ã¤ã³ã使ããã¨ã§ãå ¨ã¦ã®æåååã«ã©ã ã®ã¨ã³ã³ã¼ãã£ã³ã°ãå¼·å¶çã«æå®ã§ãã¾ãã
require 'sequel' Sequel.connect('sqlite://test.db') class User < Sequel::Model plugin :force_encoding, 'UTF-8' end p User.first.name.encoding # => #<Encoding:UTF-8>
ã¡ãªã¿ã«ãã¢ãã«ã§ã¯ãªããã¼ã¿ã»ããçµç±ã§æä½ããå ´åã¯ããã®ãããªå ¨ä½çã«ã¨ã³ã³ã¼ãã£ã³ã°ã®æå®ãããæ¹æ³ã¯ãªããããããã«force_encodingãããããããªãããã§ãã
require 'sequel' db = Sequel.connect('sqlite://test.db') p db[:users].first[:name] # => "\xE5\xA4\xAA\xE9\x83\x8E" p db[:users].first[:name].force_encoding('UTF-8') # => "太é"
ãã©ã¤ããªãã¼ãæå®ããã
Sequelã®ã¢ãã«ã¯ãããã©ã«ãã§ã¯ãã©ã¤ããªãã¼ã¯Restrictedãªå¤ã¨ãã¦ãæ示çãªæå®ã許å¯ããã¦ããªãç¶æ ã«ãªã£ã¦ãã¾ãã
require 'sequel' db = Sequel.connect('sqlite://test.db') # ãã¼ã¿ã»ããçµç±ã®å ´åã¯é¢ä¿ãªã db[:users].insert(:id => 123, :name => 'John', :age => 18) # ok class User < Sequel::Model; end User.create(:id => 456, :name => 'Bob', :age => 17) # Sequel::Error # => ...method id= doesn't exist or access is restricted to it...
ã¢ãã«å®ç¾©æã«unrestrict_primary_keyã宣è¨ãããã¨ã§ããã©ã¤ããªãã¼ã®æ示çãªæå®ãå¯è½ã¨ãªãã¾ãã
require 'sequel' Sequel.connect('sqlite://test.db') class User < Sequel::Model unrestrict_primary_key end User.create(:id => 456, :name => 'Bob', :age => 17) # ok
ååã®ã«ã©ã ãåå¨ãããã¼ãã«å士ãJOINããã
ä¾ãã°usersã¨postsã¨ãããã¼ãã«ããããåæ¹ãcreated_atã¨ããååã§ã¬ã³ã¼ãã®çææ¥æãè¨é²ãã¦ããã¨ãã¾ãããã®ã¨ãã
require 'sequel' Sequel.connect('sqlite://test.db') class User < Sequel::Model one_to_many :posts end class Post < Sequel::Model many_to_one :users end p Post.join(User, :id => :user_id).first.created_at # => User's created_at
ã®ããã«åç´ã«JOINããã¨ãå¾ãããã¬ã³ã¼ãã®created_atã¯Userã®ããã¨ãªãã¾ãã
ããããã±ã¼ã¹ã§ã¯graphã¡ã½ããã使ããã¨ã§ã«ã©ã åã®è¡çªãé²ããã¨ãã§ãã¾ããgraphã¡ã½ããã¯ããã¼ãã«æ¯ã«åå¥ã®ã¬ã³ã¼ããæ ¼ç´ããããã·ã¥ã¨ãã¦çµæãè¿ãã¾ãã
require 'sequel' Sequel.connect('sqlite://test.db') class User < Sequel::Model one_to_many :posts end class Post < Sequel::Model many_to_one :users end record = Post.graph(User, :id => :user_id).first p record[:posts].created_at # => Post's created_at p record[:users].created_at # => User's created_at
3ã¤ä»¥ä¸ã®ãã¼ãã«ãJOINããã
Sequelã¯ã¡ã½ãããã§ã¤ã³ã§ããããSQLãçæã§ããã®ã便å©ãªã®ã§ããããã¾ã«ãããããããã¤ã³ãã«ãªããã¨ãããã¾ãã
ä¾ãã°ä»èª¬æããgraphã¡ã½ãããããã¯JOINã®å·¦å´ã®ãã¼ãã«ã¨ãã¦ããç´åã¾ã§ã«çæããããã¼ã¿ã»ããã®ãã¡ãæå¾ã«JOINããããã¼ãã«ãã使ç¨ãã¾ãã
ã¤ã¾ãã以ä¸ã®ãããªã³ã¼ããå®è¡ããã¨ã
require 'sequel' Sequel.connect('sqlite://test.db') class User < Sequel::Model one_to_many :posts end class Category < Sequel::Model one_to_many :posts end class Post < Sequel::Model many_to_one :users many_to_one :categories end p Post.graph(User, :id => :user_id) .graph(Category, :id => :category_id) .first # Sequel::DatabaseError
categoriesãã¼ãã«ãJOINãã段éã§*1"no such column: users.category_id"ã¨æããã¾ããpostsã¨categoriesãJOINãã¦æ¬²ããã®ã«ãusersã¨categoriesãJOINãããã¨ãã¦ãã¾ã£ã¦ããããã§ãã
ãã®ãããªã±ã¼ã¹ã§ã¯ã:implicit_qualifierãªãã·ã§ã³ã«ãã£ã¦JOINã®å·¦è¾ºãæå®ãã¦ããã¾ãã
require 'sequel' Sequel.connect('sqlite://test.db') class User < Sequel::Model one_to_many :posts end class Category < Sequel::Model one_to_many :posts end class Post < Sequel::Model many_to_one :users many_to_one :categories end p Post.graph(User, :id => :user_id) .graph(Category, { :id => :category_id }, :implicit_qualifier => :posts) .first # ok
{}ã«ãã£ã¦ç¬¬2å¼æ°ã®JOINæ¡ä»¶ã¨ç¬¬3å¼æ°ã®ãªãã·ã§ã³ãæ示çã«åºå¥ãããã¨ãå¿ããã«ã
æ°ãä»ãããSequelã®ã¯ã»
ãã®ä»ãå ´åã«ãã£ã¦ã¯æ©ã¿ãã¤ã³ãã¨ãªããããããªããã¡ãã£ã¨å¤ãã£ãSequelã®ã¯ã»ã«ã¤ãã¦ãã¡ã¢ãæ®ãã¦ããã¾ãã
Sequel::DATABASESã®åå¨
Sequelã§ã¯ãçæãããã¼ã¿ãã¼ã¹ãå ¨ã¦Sequel::DATABASESã¨ããé åã«æ ¼ç´ãã¦ä¿æãã¦ãã¾ãã
注æãããã®ã¯ããããã¯å ã§ãã¼ã¿ãã¼ã¹ãæ±ãå ´åã¯ããããã¯ãæããã¿ã¤ãã³ã°ã§Sequel::DATABASESããã¤ã³ã¹ã¿ã³ã¹ãåé¤ãã¦ãããã®ã«ããããã¯ã使ããã«disconnectã¡ã½ããã§æ¥ç¶ãåã£ãå ´åã¯ãSequel::DATABASESããã¤ã³ã¹ã¿ã³ã¹ãåé¤ãã¦ããããæ®ã£ãã¾ã¾ã«ãªãâ¦ã¨ããç¹ã§ãã
require 'sequel' puts Sequel::DATABASES.length # => 0 Sequel.connect('sqlite://test.db') do |db| puts Sequel::DATABASES.length # => 1 end puts Sequel::DATABASES.length # => 0 db = Sequel.connect('sqlite://test.db') puts Sequel::DATABASES.length # => 1 db.disconnect puts Sequel::DATABASES.length # => 1 Sequel::DATABASES.delete(db) puts Sequel::DATABASES.length # => 0
ãã®å ´åãå½ç¶åç §ãæ®ã£ãã¾ã¾ã«ãªãã®ã§GCã®å¯¾è±¡ã«ãªãã¾ããããã¾ãåè¿°ã®ããã«ãããã©ã«ãã§ã¯ã¢ãã«ã¯æåã«æ¥ç¶ãããã¼ã¿ãã¼ã¹*2ã¨é¢é£ä»ããããããããæãã¬ã¨ããã§å¤ãªæåãããå±éºæ§ãããã¾ãã*3
å¿ è¦ã§ããã°ãä¸ã®ã³ã¼ãã®æå¾ã®ããã«èªåã§Sequel::DATABASESããã¤ã³ã¹ã¿ã³ã¹ãåãé¤ãã¦ããã¨è¯ããã¨æãã¾ãã
ã¢ãã«ã«å®ç¾©ãããã¢ã¯ã»ãµã¡ã½ãã
åè¿°ã®ããã«ãSequelã®ã¢ãã«ã¯å®ç¾©æã«ãã¼ã¿ãã¼ã¹ã«æ¥ç¶æ¸ã¿ã§ããå¿ è¦ãããã¾ãã
ä½æ ãã¨ããã¨ãã¢ãã«ã®å®ç¾©æã«ãã¼ãã«ã«åå¨ããã«ã©ã ãåå¾ããåã«ã©ã ã«å¯¾å¿ããã¢ã¯ã»ãµã¡ã½ãããå®ç¾©ãã¦ããããã§ãã
次ã®ãããªã³ã¼ããå®è¡ãã¦ã¿ãã¨ããããããã§ãã
require 'sequel' require 'logger' db = Sequel.connect('sqlite://test.db') db.loggers << Logger.new($stderr) class User < Sequel::Model; end # ãã®æç¹ã§SQLãçºè¡ãã¦ãã # SQLiteã®å ´å㯠PRAGMA table_info('users')
ãã®å ´åã«ä½ã«æ³¨æãããè¯ããã¨ããã¨ããã¢ãã«ã®å®ç¾©ä»¥éã«è¿½å ã»å¤æ´ãããã«ã©ã ã¯ã¢ã¯ã»ãµã¡ã½ããã«ããã¢ã¯ã»ã¹ãã§ããªããã¨ããç¹ã§ãã
require 'sequel' db = Sequel.connect('sqlite://test.db') class User < Sequel::Model; end puts User.instance_methods.include?(:name) # => true puts User.first.name # ok db.alter_table(:users) do add_column :country, :string, :default => 'jp' end # ããã·ã¥ã«ããã¢ã¯ã»ã¹ã¯ãã¤ã§ãå¯è½ puts User.first[:country] # => jp puts User.instance_methods.include?(:country) # => false puts User.first.country # NoMethodError
ããããã¾ãåé¡ã«ãªãã±ã¼ã¹ã¯ç¡ããããªæ°ããã¾ãããä¸ä¸ãããåé¡ã«ãªãå ´åã¯ãalter_tableå¾ã«å度ã¢ãã«å®ç¾©ããã¦ããã°OKã§ãããã®éã¯remove_constã§ä¸åº¦ã¢ãã«ã¯ã©ã¹ãåé¤ãããã¨ãå¿ããã«ã
*1:å®éã«ä¾å¤ãçºçãã¦ããã®ã¯çæããSQLãå®è¡ããæã§ãã
*2:ã¤ã¾ãSequel::DATABASES.first
*3:ç¹ã«åä½ãã¹ããªã©ã§è¦æ³¨æã
Twitterã«ããããã³ãã³åç»ã®äººæ°åº¦ãã©ã³ãã³ã°ãããµã¼ãã¹ãä½ã£ã¦ã¿ã
ã¾ã αçã§ãããã¨ããããè¦ãããã¬ãã«ã«ã¯ãªã£ãã®ã§å ¬éãã¦ã¿ã¾ãã
Twitterã®å ¬éãã¤ã¼ãã®ä¸ããããã³ãã³åç»ã®URLãå«ããã®ãæ¢ãåºãããã¤ã¼ãæ°ãå¤ãé ã«åç»ãã©ã³ãã³ã°ãããµã¼ãã¹ã§ãã
ãã³ãã³åç»æ¬å®¶ã®ã©ã³ãã³ã°ã¨ã¯ã ãã¶éãçµæã«ãªããããªã®ã§ãè¦ã人ãè¦ãã°ãããªãã«æ¥½ããã®ã§ã¯ãªããã¨â¦å¤åã
ãã¤ã¼ãæ°èªä½ããã»ã©å¤ãããã¾ãããããã®åã©ã³ãã³ã°ã®å ¥ãæ¿ããã¯é »ç¹ã«èµ·ããããã§ãã
æ©è½é¢ããã¶ã¤ã³é¢ã¨ãã«ã¾ã ã¾ã ä½ããã¦ã¨ãã£ãã¨ããã§ãããã¨ããããä»çµã¿ã®ç°¡åãªèª¬æãæ¸ãã¦ãããã¨æãã¾ãã
æè¡çã«ãããã話ã¯ããã¾ããã®ã§ãæ¥è¨çãªæè¦ã§æãã¦ããã ããã°å¹¸ãã§ãã
éçºè¨èªãªã©
Rubyã§ãããã¼ã¿ãã¼ã¹æä½ã«Sequelããã³ãã¬ã¼ãã¨ã³ã¸ã³ã«Hamlãmemcachedæä½ã«memcache-clientã®gemã使ç¨ãã¦ãã¾ããå¾ã¯ç´°ã ãããã®ãè²ã ã
ãã¤ã¼ãã®åéæ¹æ³
Twitterã®Streaming APIã使ã£ã¦ãã¾ãã
結構前にStreaming APIの使い方について記事を書いたã®ã§ãããããããæ£å¼çã¨ãã¦ãªãªã¼ã¹ãããã«ããããç´°é¨ãããããå¤æ´ããã¦ãã¾ããæ£å¼çStreaming APIã®ä½¿ãæ¹ã«ã¤ãã¦ã¯ãã¾ãæ©ä¼ãããã°è¨äºã«ã¾ã¨ãã¦ã¿ããã¨æã£ã¦ãã¾ãã
ä»åã¯"statuses/filter"ã使ããtrackãã¼ã¯ã¼ãã¨ãã¦"nico"ãæå®ãã¦ãã¾ããããã¯ãã³ãã³åç»èªä½ã®ãã¡ã¤ã³="www.nicovideo.jp"ã¨ããã³ãã³åç»å°ç¨ã®URLç縮ãµã¼ãã¹"nico.ms"ã®ä¸¡æ¹ãå¼ã£æãããã£ãããã§ãã
[2010å¹´2æ10æ¥ä¿®æ£] trackãã¼ã¯ã¼ãã«ããæ¤ç´¢ã¯ï¼åèªåä½ã§ã®ï¼å®å
¨ä¸è´ã§è¡ããã¾ãã®ã§ãä¸ã®æå®ã ã¨"nico.ms"ã®URLããå¼ã£æããã¾ããã"www.nicovideo.jp"ãå¼ã£æããããã«ã¯ã"nicovideo,nico"ã¨ããããã«æå®ããå¿
è¦ãããã¾ãã
å½ç¶é¢ä¿ãªããã¤ã¼ããããªãç´ãè¾¼ãã§ãã¾ãã®ã§ããããªæãã®æ£è¦è¡¨ç¾ã§ããã«ãã£ã«ã¿ãªã³ã°ãã¦ãã¾ãã
PATTERN = %r{https?://.*(?:nicovideo\.jp|nico\.ms).*/sm(\d+)}
ããã«ãããããã°ã$1ã«åç»IDãå ¥ãã¾ãã®ã§ããããå¾ã è²ã ã¨ä½¿ãã¾ããã¾ãã
ã¨ã£ã¦ãããã¤ã¼ãã¯å¿ è¦ãªæ å ±ã ãåãåºãã¦ãã¨ããããMySQLã«ã¶ã¡è¾¼ãã§ãã¾ããã©ã³ãã³ã°çæãªã©ãå ¨é¨SQLã¯ã¨ãªã§è¡ãã¾ãã®ã§ããã®è¾ºã¯ãã¯ããªã¬ã¼ã·ã§ãã«ãã¼ã¿ãã¼ã¹ãé©ãã¦ãã¾ãã
ã©ã³ãã³ã°ã®çææ¹æ³
ä¸è¿°ã®éãSQLã¯ã¨ãªã§å®ç¾ãã¦ãã¾ããSequelã§æ¸ãã¨ãããªæãããã¼ãã«åãã«ã©ã åã¨ãã®èª¬æã¯é¢åãªã®ã§çããã¦ãã ããã
@statuses.filter { |o| o.created_at > Time.now - @target_period } .group_and_count(:video_id.as(:video_id)) .order(:count.desc, :video_id.desc) .limit(@max_video_count)
"group_and_count"ã¡ã½ããã便å©ã§ãããå人çã«çµæ§ããããããæ¸ããã®ã§ãæ°ã«å ¥ãã§ããSequelã
ååç»ã«ã¤ããæè¿ã®ãã¤ã¼ãã¯æ¬¡ã®ãããªæãã§åãåºãã¦ãã¾ãã
@statuses.graph(:users, :id => :user_id) .filter { |o| o.created_at > Time.now - @target_period } .where(:video_id => video_id) .order(:created_at.desc) .limit(@max_tweet_count)
JOINããåæ¹ã®ãã¼ãã«ã«ååã®ã«ã©ã ãããå ´åã"join"ã¡ã½ããã§ã¯ãªã"graph"ã¡ã½ããã使ãã¨ãçµæããã¼ãã«æ¯ã®ããã·ã¥ã¨ãã¦è¿ã£ã¦ãã¾ãã®ã§ãã«ã©ã åã®éè¤ãåé¿ãããã¨ãã§ãã¾ãã
åç»æ å ±ã®åå¾
ã©ã³ãã³ã°ã¨ãã¦è¡¨ç¤ºããããã«ã¯ãåç»ã®ååããµã ãã¤ã«ãªã©ãè²ã ãªæ å ±ãå¿ è¦ã«ãªã£ã¦ãã¾ãã
ãã®è¾ºã¯ニコニコ動画APIã¨ãã¦ãã¡ãã¨ç¨æããã¦ãã¾ãã®ã§ãããã使ããã¦ãããã¾ãã
ã¨ãããã"getthumbinfo" APIã使ã£ã¦ããã°ãéå¸¸å¿ è¦ã¨ãªãæ å ±ã¯å ¨é¨åå¾ã§ãã¾ãã
ä»ã®å®è£ ã§ã¯ãããããã¼ã¸ã®ãææ°ã®ãã¤ã¼ãããä¸åãã¨ã«æ´æ°ãã¦ãã¾ãã®ã§ããã®ã¾ã¾ã ã¨ããªãé »ç¹ã«APIã¸ã¢ã¯ã»ã¹ãããã¨ã«ãªã£ã¦ãã¾ãã¾ãã
ããã§ãåã£ã¦ããæ å ±ã¯memcachedã«ãä¿åãã¦ãããmemcachedã«æ å ±ãããå ´åã¯APIã¸ã¯ã¢ã¯ã»ã¹ããªãããã«ãã¦ãã¾ãã
ãããããã¨ããããå ¥ãã¦ããã ãããªãã¼ã¿ã«ã¯ãªã¬ã¼ã·ã§ãã«ãã¼ã¿ãã¼ã¹ã¯å¤§ããã«ãªã£ã¦ãã¾ãã¾ãã®ã§ããã®è¾ºã®key/valueå¼ã®ãã¼ã¿ã¹ãã¢ãéå®ãã¾ãã
ã¡ãªã¿ã«ãåç»æ å ±ã«ã¯ããç¨åº¦ã®æ°é®®ããæããã¦ããããã®ã§ãmemcachedã«å ¥ãããã¼ã¿ã30åçµã£ããæ¨ã¦ãããã«ãã¦ãã¾ãã
ã¢ã¸ã¥ã¼ã«ã®å¯åå ´æ
ãµã¼ãã¹ã®URLã¯さくらのレンタルサーバã§ãããããã«ã¯éçãªHTMLã¨å種ãªã½ã¼ã¹ããç½®ãã¦ããã¾ãããä¸ã§èª¬æãããããªã¹ã¯ãªããã¯å ¨ã¦èªå® ã§åããã¦ãã¾ãã
ãããã®ã¬ã³ã¿ã«ãµã¼ãã§ã¯Streaming APIã§ä½¿ããããªé·å¯¿å½ã®ããã»ã¹ã¯è¨±å¯ããã¦ãã¾ãããããã¨ãã£ã¦èªå® ã§åºå®IPãã¨ã£ã¦ãµã¼ãã¹ãå ¬éããã®ãã¡ãã£ã¨åå«ã§ããâ¦ã¨ãããã¨ã§ããããªæ§æã«ãªãã¾ããã
èªå® ãµã¼ãã§ã¯Streaming APIã«ãããã©ããã³ã°ã®ä»ã«ãcronã§å®æçã«ã©ã³ãã³ã°HTMLçæããã»ã¹ãåããã¦ãããããã¤ãããããµã¼ãä¸ã«ã¢ãããã¼ãããããã«ãªã£ã¦ãã¾ãã
ã¡ãã£ã¨é¢åãªæ§æã§ã¯ããã¾ãããããããµã¼ãå´ã®è² è·ãæ¸ãã¾ãããã¾ããããªã«æªãããªãã®ããªâ¦ãªãã¦æã£ã¦ãã¾ãã
ãããªããã§ãèªå® ãµã¼ãã®è½åã¯ãã«ã«ä½¿ãã¾ãã®ã§ãæ¬å½ã¯ãããã¨æãã°1åæ¯ã«æ¯æã©ã³ãã³ã°ãæ´æ°ãããã¨ãã£ããã¨ãã§ããã®ã§ãããããã¯æããã¦âæ¯æã©ã³ãã³ã°âãªã®ãï¼ã¨ããæãããããä»ã®ãããª1æéæ¯ã®æ´æ°ã¨ãã¦ãã¾ãã
ãã®è¾ºãä»ã®æ¹ã®ãæè¦ã伺ãããã¨ããã§ãã
ãã³ãã¬ã¼ã
åè¿°ã®éããã³ãã¬ã¼ãã¨ã³ã¸ã³ã¯Hamlã使ã£ã¦ãã¾ããããã©ã¼ãããã¯HTML5ã§æ¸ãã¦ãã¾ãã
ã¨ãã£ã¦ãæ°ããAPIã¨ãã¨ä½¿ã£ã¦ããããã§ã¯ãªããã¿ã°ãHTML5çãªã ãã§ããããã®ãããã§IEã§ã¯JavaScriptãç¡å¹ã«ãã¦ããã¨ã¬ã¤ã¢ã¦ããã¬ã¿ã¬ã¿ã«ãªãã¾ãã
ãããW3Cのバリデータã«éãã¨ã¨ã©ã¼ã«ãªãã¾ããã©ããHTML5ã§ã¯metaã¿ã°ã®http-equivå±æ§ã«"pragma"ã"cache-control"ãªã©ã使ããªã*1ãããã®ã§ãããããããµã¼ãã§ã¯.htaccessã§ã®ãã£ãã·ã¥ã³ã³ããã¼ã«ã¯ã§ãã¾ããããä»æ¹ãªãã¨ã©ã¼ã¨ãªããã¨ãæ¿ç¥ã§ãã®ã¾ã¾ã«ãã¦ããã¾ãã
ãã¨ã¯CSS3ã®border-radiusã¨ãgradientã¨ããã¡ãã£ã¨ä½¿ã£ã¦ã¿ãããFirefox, Safari, Chromeãããã§ããåæ ããã¾ãããããã®è¾ºã®ãã©ã¦ã¶ã§è¦ãã¨ã¡ããã£ã¨è¦ãç®ãå¤ããã¾ããå ã ã®ãã¶ã¤ã³ãå³æ°ãªãã®ã§ãããããéãã¯ããã¾ãããã
ä»å¾ã«ã¤ãã¦
Twitterã§è»½ã確èªãã¦ã¿ã¾ããããã©ãããä»ã®æç¹ã§ã¯è¢«ã£ã¦ãããµã¼ãã¹ã¯ãªããããªã®ã§*2ãããå°ãçºå±ããã¦ã¿ãããã¨æã£ã¦ãã¾ãã
ãã£ããStreaming APIã使ã£ã¦ãªã¢ã«ã¿ã¤ã ã«ãã¤ã¼ããåãã¦ããã®ã§ãããããããæ´»ãããæ©è½ã欲ããã¨ããã§ãã
ãã³å風ã®UIã§ãåç»ã®ãµã ããããã¯ã«ãåã£ã¦ãããã¤ã¼ãããªã¢ã«ã¿ã¤ã ã§*3æµãâ¦ã¿ãããªãã®ãèããã®ã§ããããããªã®ãã¾ãè¦ãªãæ°ããã¦ãã©ãã§ãããããã©ã¡ããã¨ããã¨ãã³ç風ã£ã¦ãã¨ã«ãªãã®ã§ããããã
bit.lyãªã©ãä»ã®URLç縮ãµã¼ãã¹ã«ã対å¿ã§ããªããã¨èãã¾ããããããæ¡ãæµ®ãã°ãªãã®ã§å®ç¾ã§ãã¦ãã¾ãããè¯ãçããåãã®æ¹ãããã£ãããã¾ããããæ示ãé¡ãè´ãã¾ãã
ãã¨ã¯ã©ã³ãã³ã°ã®æ´æ°ééã¨ããåç»ããã¤ã¼ãã®è¡¨ç¤ºæ°ã¨ããç´°ããé¨åãããã®ã§ããããªãã¨ãã£ã¦ãã¾ããªãã¨ããããã®ã¯ãã¶ã¤ã³ã§ãã
èªåãã¶ã¤ã³ã»ã³ã¹ã¯æ¬å½ã«ç¡ããã®ã§â¦ãããã¡ãã£ã¨è¦æ ãã®è¯ããã¶ã¤ã³ã«ããããªãã
ãããªæãã§ãè²ã è¿·ã£ã¦ããã¨ããã§ãã®ã§ããæè¦ãè¦æãªã©ããã¾ãããæ¯é@shibasonã¾ã§ãé£çµ¡ãã ããããããããé¡ãè´ãã¾ãã
ãããã¨ãååãåéãã¦ãã¾ãï¼
D510MOã§VMware ESXi 4.0ãã¤ã³ã¹ãã¼ã«ããã«ã¯
èªå® ã®ãããµã¼ãã®ãã¶ã¼ãã¼ããD945GCLF2ããD510MOã«æè£ ãã¾ããã
ãã®ã¾ã¾æ¢åã®CentOS + VMware Serveræ§æã§éç¨ãç¶ãã¦ãè¯ãã£ãã®ã§ããããã£ãããªã®ã§åããæ°ã«ãªã£ã¦ããVMware ESXiãå ¥ãã¦ã¿ããã¨ã«ãã¾ããã
ãã ããVMware ESXiã¯D510MOã«æè¼ããã¦ããRealtek製ã®NICã«å¯¾å¿ãã¦ãã¾ããã®ã§ãã¤ã³ã¹ãã¼ã«ã«ããã£ã¦ã¡ãã£ã¨ããä½æ¥ãå¿ è¦ã«ãªãã¾ãã
ãã®è¾ºã«é¢ãã¦ã¯ãããããäºã«Webä¸ã«å¤ãã®æ å ±ãããã¾ãããããã¤ãã®æ¹æ³ãããããã§ããã®ã§ãåå¿é²ã¨ãã¦ç§ãã¨ã£ãæé ãæ¸ãã¨ãã¦ãããã¨æãã¾ãã
ä»åã¯
- D510MOãã·ã³ã«ã¯å å¦ãã©ã¤ããã¤ãã¦ããªã
- 使ãã¡ãã£ã¢ã¯USBã¡ã¢ãªã ãã§æ¸ã¾ããã
- ãã ãUSBãã¼ãã§ã¯ãªãHDDãã¼ãã«ããã
- æ¢åã®Linuxç°å¢ã¯ãªã*1
ã¨ããåæã§ä½æ¥ãè¡ãã¾ããã
ãªãã以ä¸ã®æé ã¯VMware ESXi 4.0 Update 1ã対象ã¨ãã¦ãã¾ãã
ã¤ã³ã¹ãã¼ã«æé
USBã¡ã¢ãªãç¨æãã
FAT32ã§ãã©ã¼ããããããã容é1GB以ä¸ã®USBã¡ã¢ãªãä¸æ¬ããã°OKã§ããã¯ã©ã¤ã¢ã³ãPCã«æ¿ãã¦ããã¾ãã
UNetbootinããã¦ã³ãã¼ããã
UNetbootinã¯ISOã¤ã¡ã¼ã¸ããç°¡åã«ãã¼ã¿ãã«USBã¡ã¢ãªãä½æã§ãã便å©ã½ããã§ããããããã¼ã¸ä¸é¨ã«ãã¦ã³ãã¼ããã¿ã³ãããã¾ãã®ã§ãWindowsç¨ãè½ã¨ãã¦ãã¾ãã
ç¹ã«ã¤ã³ã¹ãã¼ã«ã®å¿ è¦ã¯ãªããè½ã¨ããå®è¡ãã¡ã¤ã«ããã®ã¾ã¾èµ·åãã¾ãã®ã§ãé©å½ãªå ´æã«ç½®ãã¦ããã¾ãã
ESXiã®ã¤ã³ã¹ãã¼ã©ãã«ISOã¤ã¡ã¼ã¸ããã¦ã³ãã¼ããã
VMwareのサイトãããã¦ã³ãã¼ããã¦ãã¾ããç¡æã§ãããã¦ã¼ã¶ç»é²ãå¿ è¦ã§ãã
ã¤ã³ã¹ãã¼ã©USBã¡ã¢ãªãä½æãã
å ã»ã©è½ã¨ãã¦ããUNetbootinãèµ·åãã
- Diskimage > ISO > (ISOã¤ã¡ã¼ã¸ãã¡ã¤ã«)
- Type > USB Drive
- Drive > (USBã¡ã¢ãªã®ãã©ã¤ã)
ãé¸æãã¦OKãã¯ãªãã¯ãã¾ããå®äºããã¨åèµ·åãããåããã¾ãããåèµ·åããã«éãã¾ãã
ã¤ã³ã¹ãã¼ã©USBã¡ã¢ãªã«oem.tgzã追å ãã
ããã§ããUSBã¡ã¢ãªããã¤ã³ã¹ãã¼ã©ãèµ·åã§ãã¾ããããã®ã¾ã¾ã ã¨èµ·åéä¸ã«"No compatible network adapter found."ã¨è¨ããã¦æ¢ã¾ã£ã¦ãã¾ãã¾ãã
æå¿ã®æ¹ã ã®æã«ãã£ã¦ESXiç¨ã®å種ããã¤ã¹ãã©ã¤ããä½æããã¦ãã¾ãã®ã§ãããã使ããã¨ã§ESXiã«NICãèªèããããã¨ãã§ãã¾ãã
ã¾ããä¸è¨ã®ãã¼ã¸ãã"RTL8111_8168_P55_integr_SATA_Ctrl.(AHCI).oem.tgz"ããã¦ã³ãã¼ããã¾ãã
ãã®ãã¡ã¤ã«ãUSBã¡ã¢ãªã®ã«ã¼ããã©ã«ã*2ã«ã³ãã¼ãã"oem.tgz"ã«ãªãã¼ã ãã¾ãã
æå¾ã«åããã©ã«ãã«ãã"syslinux.cfg"ãã¨ãã£ã¿ã§éãã
append initrd=/ubninit vmkboot.gz --- vmkernel.gz --- sys.vgz --- cim.vgz --- ienviron.tgz --- image.tgz --- install.tgz
ã®è¡ã®æå¾ã«" --- oem.tgz"ãä»ãå ãã¦ä¿åãã¾ãã
append initrd=/ubninit vmkboot.gz --- vmkernel.gz --- sys.vgz --- cim.vgz --- ienviron.tgz --- image.tgz --- install.tgz --- oem.tgz
åãè¡ã2è¡ããã¾ãã®ã§ã2è¡ã¨ãå¤æ´ãã¦ããã¾ãã
ESXiãã¤ã³ã¹ãã¼ã«ãã
ããã§ã¤ã³ã¹ãã¼ã©ã¯å®æã§ãã®ã§ãã¯ã©ã¤ã¢ã³ãPCããUSBã¡ã¢ãªãæããD510MOãã·ã³ã«æ¿ãã¦èµ·åãã¾ããBIOSã®ãã¼ãã¡ãã¥ã¼ã§USBã¡ã¢ãªããã®ãã¼ããé¸æããã®ãå¿ããã«ã
ãã¼ããã¼ãã¼ã®ç»é¢ã§"ESXi Installer"ãé¸æããã¨ã¤ã³ã¹ãã¼ã©ãèµ·åãã¾ããããæéããããã¾ããããã°ããå¾ ã£ã¦ããã¨å ¥åå¾ ã¡ã®ç»é¢ãåºã¦ãã¾ãã®ã§ããã¨ã¯ç»é¢ã®è¡¨ç¤ºéãã«ã¤ã³ã¹ãã¼ã«ãé²ãã¾ãã
注æç¹ã¨ãã¦ãã¤ã³ã¹ãã¼ã©ãPS/2æ¥ç¶ã®ãã¼ãã¼ããèªèãã¦ããã¾ããã§ããã®ã§ãUSBæ¥ç¶ã®ãã¼ãã¼ãã使ãå¿ è¦ãããã¾ãã
åèµ·åãä¿ãç»é¢ãåºã¦ããã°ããã§ããã¤ã³ã¹ãã¼ã«å®äºâ¦ã¨ã¯ããããããå°ãä½æ¥ãå¿ è¦ã«ãªãã¾ããåèµ·åãã¦ãä¾ã«ãã£ã¦"No compatible network adapter found."ã§æ¢ã¾ãã¾ãã®ã§ãUSBã¡ã¢ãªãæãããã°ãããã®ã¾ã¾ç½®ãã¦ããã¾ãã
USBãã¼ãã®CentOSãä½æãã
å®ã¯å ã»ã©è¿½å ãã"oem.tgz"ã¯ããã¾ã§ããã¤ã³ã¹ãã¼ã©ãèªã¿è¾¼ãç¨ããªã®ã§ãä»ã¤ã³ã¹ãã¼ã«ããESXiã¯ä¾ç¶ã¨ãã¦Realtekã®NICãèªèãã¦ãããªãç¶æ ã«ãªã£ã¦ãã¾ããESXiæ¬ä½ã«å度oem.tgzã®è¿½å ãå¿ è¦ã«ãªãã¾ãã
ãã®ããã«ãã¤ã³ã¹ãã¼ã©USBã¡ã¢ãªãä»åº¦ã¯CentOSåãã¦ãD510MOãã·ã³ä¸ã§CentOSãUSBãã¼ããã¦ä½æ¥ãè¡ããã¨ã«ãã¾ãã*3 *4
USBã¡ã¢ãªãå度ãã©ã¼ãããããããCentOSのサイトããLiveCDçã®ISOãã¡ã¤ã«ããã¦ã³ãã¼ãããå ã»ã©ã¨åãããã«UNetbootinã使ã£ã¦USBã¡ã¢ãªã«ã¤ã³ã¹ãã¼ã«ãã¾ãã
ã¤ã³ã¹ãã¼ã«ãå®äºããããUSBã¡ã¢ãªã®ã«ã¼ããã©ã«ãã«"RTL8111_8168_P55_integr_SATA_Ctrl.(AHCI).oem.tgz"ãã³ãã¼ãã¦ãã¯ã©ã¤ã¢ã³ãPCããæãã¾ãã
ESXiã«oem.tgzã追å ãã
åèµ·åå¾ ã¡ã®D510MOãã·ã³ã«USBã¡ã¢ãªãæ¿ãã¦åèµ·åããUSBãã¼ãã§CentOSãèµ·åãã¾ãã
CentOSãèµ·åããããESXiãã¤ã³ã¹ãã¼ã«ããHDDã®ãã¼ãã£ã·ã§ã³ããã¦ã³ãããã¦ãããã¨ã確èªãã¾ããé常ã¯èªåã§ãã¦ã³ãããã¦ãã¾ãããããã¦ããªããã°fdiskã§ããã¤ã¹åã確èªãã¦ãã¦ã³ããã¾ãã
# mount -l ...(çç¥)... /dev/sda4 on /mnt/disc/sda4 type vfat (ro,uid=500) [Hypervisor0] /dev/sda5 on /mnt/disc/sda5 type vfat (ro,uid=500) [Hypervisor1] /dev/sda6 on /mnt/disc/sda6 type vfat (ro,uid=500) [Hypervisor2] /dev/sda8 on /mnt/disc/sda8 type vfat (ro,uid=500) [Hypervisor3] ...(çç¥)...
ã¿ã¼ã²ããã¯"Hypervisor1"ã®ããªã¥ã¼ã ã©ãã«ãã¤ãã¦ãããã¼ãã£ã·ã§ã³ã§ããç§ã®å ´åã¯/dev/sda5ã§ãæ¢ã«/mnt/disc/sda5ã«ãã¦ã³ãããã¦ãã¾ãããéãããã¤ã¹åã ã£ãå ´åã¯é©å®èªã¿æ¿ãã¦ãã ããã
ãã®ä¸ã«"oem.tgz"ãå ¥ã£ã¦ããã¨æãã¾ãã
# ls /mnt/disc/sda5 boot.cfg cim.vgz mod.tgz pkgdb.tgz vmkboot.gz cimstg.tgz license.tgz oem.tgz sys.vgz vmk.gz
ä¸èº«ãè¦ãã°åããã¾ããããã ã®ç©ºtgzãã¡ã¤ã«ãªã®ã§ããããå ã»ã©USBã¡ã¢ãªã«ã³ãã¼ãã"RTL8111_8168_P55_integr_SATA_Ctrl.(AHCI).oem.tgz"ã«ç½®ãæãã¾ãã
èªã¿åãå°ç¨ã§ãã¦ã³ãããã¦ãã¾ãã®ã§ãèªã¿æ¸ãã¢ã¼ãã§ãã¦ã³ããç´ãããã¨ããã¡ã¤ã«ãã³ãã¼ãã¾ãããªããç§ã®ç°å¢ã§ã¯ã³ãã¼å ã®USBã¡ã¢ãªã¯/mnt/disc/sdb1ã¨ãã¦ãã¦ã³ãããã¦ãã¾ãããããã¡ããé©å®èªã¿æ¿ãã¦ãã ããã
# umount /mnt/disc/sda5 # mount /dev/sda5 /mnt/disc/sda5 # cp -p /mnt/disc/sdb1/RTL8111_8168_P55_integr_SATA_Ctrl.\(AHCI\).oem.tgz /mnt/disc/sda5/oem.tgz
ããã§CentOSã§ã®ä½æ¥ã¯çµããã§ããåèµ·åãããã¦USBã¡ã¢ãªãåãå¤ãã¾ãã
ã¤ã³ã¹ãã¼ã«å®äº
åèµ·åå¾ãé常éãHDDãããã¼ãããã°ãç¡äºESXiãç«ã¡ä¸ããã¨æãã¾ãããã§ãããã§ããã
ESXièªä½ã®è¨å®ã使ãæ¹ã«ã¤ãã¦ã¯ã以ä¸ã®åèãµã¤ãã®ä¸3ã¤ãªã©ãã©ããã
åèãµã¤ã
*1:D945GCLF2æ代ã«ä½¿ã£ã¦ããCentOSç°å¢ã¯æ¢ã«æ½°ãã¦ãã¾ã£ã¦ãã¾ããã
*2:image.tgzãªã©ããããã©ã«ãã
*3:æ¬å½ã¯Ubuntuã使ãã¤ããã ã£ãã®ã§ãããD510MOã§Ubuntuãèµ·åããã«ã¯BIOSã®ã¢ãããã¼ããå¿ è¦ã«ãªããããªã®ã§ãæé ã®çç¥ã®ããã«CentOSãé¸æãã¾ãããåèï¼Intel 新 Atom MB (D510MO) で Ubuntu 9.10 を使うには - metastable blog
*4:ã¤ã³ã¹ãã¼ã©ã«å«ã¾ããDDã¤ã¡ã¼ã¸ãç´æ¥ç·¨éãããã¨ãã§ãã¾ãããã®å ´åã¯ã¤ã³ã¹ãã¼ã«ç´å¾ããESXiã使ããã¨ãã§ãã¾ããåèï¼Updating the VMWare ESXi Disk Dump File | Grid.org