ブログを移転しました。
以下のアドレスにブログを移転することにしました。このブログはもう更新されません。以下の新しいブログを購読してください。
■はてなブログはじめました。
はてなブログはじめました。
haml
.hoges-new-page #hogehoge
coffeescript
hoge_function = () -> ... $ -> if $('.hoges-new-page').is(':visible') hoge_function()
class Animal price :5 sell: (customer) -> animal = new Animal animal.sell(new Customer)
object1 = {one: 1, two: 2} object2 = one: 1, two: 2 object3 = one: 1 two: 2
javascript
var sys = require('sys'); var http = require('http'); var server = http.createServer( function (request, response) { response.writeHead(200, {'Content-Type': 'text/plain'}); response.write('Hello World!!\n'); response.end(); } ).listen(3000); sys.log('Server running at http://127.0.0.1:3000/');
ruby
class Fib @@ary = [] def self.[](i) return @@ary[i] if @@ary[i] case i when 0 @@ary[i] = 0 when 1 @@ary[i] = 1 else @@ary[i] = self[i-1]+self[i-2] end end def self.method_missing(name,*args) @@ary.__send__(name,*args) end def self.inspect @@ary.inspect end end if __FILE__ == $0 p Fib 10.times do |i| p Fib[i] end p Fib Fib[100] p Fib end
c
#include <stdio.h> int main() { int i; for(i=0;i <= 100;i++) { if((i % 3) == 0) { printf("Fizz"); } if((i % 5) == 0) { printf("Buzz"); } if((i % 5) != 0 && (i % 3) != 0) { printf("%d",i); } printf("\n"); } return 0; }
erlang
-module(fibonacci). -export([f/1]). f(E,F,X) ->( Y = E+F if X <= 0 -> io:put_chars(Y+"\n");f(F,Y,X+1); ).
haskell
module Main where import System main = do args <- getArgs mapM_ (putStrLn) args
python
def calc_fibonacci(): yield 1 yield 1 n = 1 m = 1 while True: yield n + m o = n + m n = m m = o import time for f in calc_fibonacci(): print(f) time.sleep(0.1)
actionscript
package { import flash.display.*; import flash.text.*; [SWF(width=240,height=240, backgroundColor=0xFFFFFF)] public class Hello extends Sprite { public function Hello(){ var label:TextField = new TextField(); label.text = "String sample" label.x = 10; label.y = 10; label.autoSize = TextFieldAutoSize.LEFT; label.selectable = false; var format:TextFormat = new TextFormat(); format.color = 0xFF0000; format.font = "_sans"; format.size = 24; label.setTextFormat(format); addChild(label); } } }
なんで JavaScript だけ色付いてるの。