Skip to content

Instantly share code, notes, and snippets.

@hakobera
hakobera / sample1.js
Created January 9, 2012 07:33 — forked from atsuya/gist:1581668
name conflict
var url = require('url');
var test = function(url) {
console.log(url);
// ここで url をパースして何かやりたい
var options = url.parse(url); // これは当然エラー
};
test('http://localhost');
@hakobera
hakobera / deleteImageCache.js
Created January 14, 2012 08:52
Titanium で ImageView のキャッシュを起動時に消す (for iOS only)
/**
* 指定した時間更新されていない画像キャッシュを削除する。
* iOS にのみ対応。
*
* @param {Number} expiredTime キャッシュ保持期限 (ms)
*/
module.exports = function(expiredTime) {
var cachePath = Ti.Filesystem.applicationDataDirectory + '../Library/Caches/',
cacheDir = Ti.Filesystem.getFile(cachePath),
now = new Date().getTime();
@hakobera
hakobera / DB.java
Created February 1, 2012 10:52
Play Frmework multi datasource (backport #706)
package plugins.db;
import java.io.File;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.Method;
import java.sql.*;
import java.util.*;
import javax.naming.Context;
import javax.naming.InitialContext;
@hakobera
hakobera / rails32_on_heroku_cedar.md
Created February 23, 2012 03:29
Rails 3.2 on Heroku (cedar)

Rails 3.2 on Heroku (cedar)

環境

  • ruby 1.9.2
  • rails 3.2.1

作成フロー

Sun Feb 26 2012 09:01:27 GMT+0000 (UTC) req
{ host: 'http2http-617400151.ap-northeast-1.elb.amazonaws.com',
cookie: 'AWSELB=7F9F7D850E5DE5AC7D454A24960C4C2C71147A5EB4DC117C43E4A2F5C89B5C24AAD593E5CCA84459AFE8BC2C308EDDE0300BEA67E671DB4983ABF3D34AFD0F8CD0AF3FA02E',
origin: 'http://http2http-617400151.ap-northeast-1.elb.amazonaws.com',
'sec-websocket-key': 'vAouvpkKTmV0xVQ5NVzmTA==',
'sec-websocket-version': '13',
'x-forwarded-for': '202.248.249.26',
'x-forwarded-port': '80',
'x-forwarded-proto': 'http',
connection: 'keep-alive' }
@hakobera
hakobera / ReportUtil.java
Created March 5, 2012 14:07
POIとjXLSでWorkbook間のシートコピー(Styleは無視して良い場合)
package util;
import java.io.InputStream;
import java.util.Collection;
import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;
import net.sf.jxls.util.Util;
@hakobera
hakobera / csv2yaml.rb
Created March 21, 2012 13:43 — forked from pablox-cl/csv2yaml.rb
Simple Ruby CSV to YAML converter for Play framework Fixture
#!/usr/bin/env ruby
#
# Originally written by http://redartisan.com/tags/csv
# Added and minor changes by Gavin Laking
#
# "id","name","mime_type","extensions","icon_url"
# "1","unknown","unknown/unknown","||","/images/icon/file_unknown.gif"
# "2","image/tiff","image/tiff","|tiff|tif|","/images/icon/blank.png"
#
# if you want to remove the id: "number" line from the resulting YAML file
@hakobera
hakobera / router-line-helloworld.js
Created April 25, 2012 15:24
router-line の Hello world 的コード
var Router = require('router-line').Router,
http = require('http'),
url = require('uri');
var router = new Router();
router.add('GET', '/hello', function(req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
});
@hakobera
hakobera / router-line-exercise.js
Created May 8, 2012 06:34
router-line-exercise
var http = require('http'),
url = require('url'),
Router = require('router-line').Router;
var router = new Router();
function send(res, status, contentType, body) {
res.writeHead(status, { 'Content-Type': contentType });
res.end(body);
}
@hakobera
hakobera / aws-cloudformation-template-for-nodejs-v0.6.json
Created June 3, 2012 14:19
Amazon Cloud Formation Template for Node.js v0.6
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "CloudFormation Sample Template for Node.js application. **WARNING** This template creates an Amazon EC2 instance. You will be billed for the AWS resources used if you create a stack from this template.",
"Parameters": {
"InstanceType": {
"Description": "EC2 instance type",
"Type": "String",
"Default": "t1.micro",