This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def A(o) | |
p "A "+o.s | |
end | |
class Happy | |
def initialize(s) | |
@s=s | |
end | |
def s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fs = require 'fs' | |
{print} = require 'util' | |
{spawn} = require 'child_process' | |
build = (callback) -> | |
coffee = spawn 'coffee', ['-c', '-o', 'lib', 'src'] | |
coffee.stderr.on 'data', (data) -> | |
process.stderr.write data.toString() | |
coffee.stdout.on 'data', (data) -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
前提: | |
必要なパッケージ | |
npm install -g coffee-script | |
npm install -g jasmine-node | |
ディレクトリ構成 | |
/src #*.coffee | |
/lib #*.js | |
/spec #*.spec.coffee | |
### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe 'tree', -> | |
describe 'キーにコロンを含まないとき', -> | |
it 'そのままのオブジェクトが返ってくること', -> | |
expect({'a': 1}).toEqual {a: 1} | |
expect({'a': 1,'b': 2}).toEqual {a:1, b:2} | |
describe 'キーがコロンでセパレートされているとき', -> | |
it '階層化されて返ってくること', -> | |
expect( tree {'a:b':1, 'c:d':2} ).toEqual {a:{b:1},c:{d:2}} | |
expect( tree {'a:b:c':1, 'a:b:d':2} ).toEqual {a:{b:{c:1, d:2}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name nico-rank-resort | |
// @namespace nico-rank-resort | |
// @include http://www.nicovideo.jp/ranking/fav/hourly/all | |
// @author fukayatsu | |
// @description resort ranking of nico nico douga | |
// ==/UserScript== | |
// a function that loads jQuery and calls a callback function when jQuery has finished loading | |
function addJQuery(callback) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main.java; | |
import java.util.ArrayList; | |
import org.jruby.Ruby; | |
import org.jruby.RubyRuntimeAdapter; | |
import org.jruby.javasupport.JavaEmbedUtils; | |
import org.jruby.runtime.builtin.IRubyObject; | |
public class Calc { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main.java; | |
import javax.script.ScriptEngine; | |
import javax.script.ScriptEngineManager; | |
import javax.script.ScriptException; | |
public class Calc { | |
public static void main(String[] args) throws ScriptException { | |
if (args.length == 1) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'mysql' | |
db = Mysql.connect('localhost', 'root', '', 'ca') | |
while(true) do | |
print "name(empty to exit) > "; name = gets.chomp | |
break if name == '' | |
print "password > "; password = gets.chomp | |
#prepared Statement |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//String sql = "SELECT * FROM user where name = '?'"; //エラー | |
String sql = "SELECT * FROM user where name = ?"; //OK | |
PreparedStatement ps = conn.prepareStatement(sql); | |
ps.setString(1, userName); | |
ResultSet rs = ps.executeQuery(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
redis = require 'redis' | |
rc = redis.createClient() | |
rc.on 'error', (err)-> | |
console.log 'Error: ' + err | |
rc.set 'hoge', 'piyo', redis.print | |
rc.get 'hoge', redis.print |
OlderNewer