Skip to content

Instantly share code, notes, and snippets.

@roothybrid7
roothybrid7 / windows.rb
Created May 13, 2011 19:23
config/initializers/windows.rb(rails3 windows console)
if Bundler::WINDOWS
require 'nkf'
class << $stdout
def write_with_conversion(str)
write_without_conversion NKF.nkf('-sxm0', str.to_s)
end
alias_method_chain :write, :conversion
end
end
@roothybrid7
roothybrid7 / NSDate+RoundToTime.h
Created September 4, 2011 02:17
NSDate Round (off|up|down) time Extension
//
// NSDate+RoundToTime.h
// Rh7Kit
//
// Created by 大木 聡 on 11/09/02.
// Copyright 2011 rh7. All rights reserved.
//
#import <Foundation/Foundation.h>
@roothybrid7
roothybrid7 / DataHandler.java
Created September 4, 2011 03:29
Slim3 GlobalTransaction Memo
package jp.rh7.utils;
public interface DataHandler {
// Transactionで実行する処理をここに書く
public abstract void execute();
// モデルを取り出す
public abstract Object[] getModels();
}
@roothybrid7
roothybrid7 / Address.java
Created September 4, 2011 03:42
Slim3 GlobalTransaction(gist: 1192196)を使う実行サンプル(Model: Person, Address)
package jp.rh7.model;
import java.io.Serializable;
import java.util.Date;
import com.google.appengine.api.datastore.Key;
import org.slim3.datastore.Attribute;
import org.slim3.datastore.CreationDate;
import org.slim3.datastore.Model;
@roothybrid7
roothybrid7 / mmm_ddns_agent.conf
Created September 4, 2011 11:42
MMM DDNS Agentの設定ファイルサンプル
# mmm_ddns_agent.conf
[nameserver_agent]
port = 9994 # mmm_ddns_agentを起動するポート
dns_server = 10.1.2.3 # レコードを登録するDDNSサーバ
dns_port = 53 # DDNSサーバのポート
ttl = 10 # Master DBのDNSレコードTTL
type = A # Aレコードのみ(MMMがddns_agentに送りつけてくるのかI/FのIPアドレスなので)
zone = example.com # Master DBを登録するDNSゾーン
# TSIGキー認証の場合は下記を追加
tsig_key_name = example.com.
@roothybrid7
roothybrid7 / execxhrfactory.js
Created October 1, 2011 01:12
XHR Object Pool pattern
// You would use this object as follows:
var xhr = XHRFactory.getInstance();
var url = "http://www.xyz.com/someresource/....";
// do the operation
xhr.open("GET", url, true);
xhr.onreadystatechange = function() {
if (xhr.readyState==4) {
// if "OK"
if (xhr.status==200) {
@roothybrid7
roothybrid7 / rs_array_load.rb
Created October 1, 2011 02:43
dot access and refering to subscript of attributes
#!/usr/bin/env ruby
# coding: utf-8
require 'rubygems'
require 'right_resource'
# Server Array Response data sample
xml = '<server-array>
<active type="boolean">false</active>
<array-type>queue</array-type>
@roothybrid7
roothybrid7 / crack_to_params.rb
Created October 1, 2011 07:58
fixed gem dependency of rightresource.
#!/usr/bin/env ruby
# coding: utf-8
require 'rubygems'
gem 'crack', '~>0.1.0'
require 'crack'
#gem 'rightresource', '=0.4.5' # with crack 0.1.8
#require 'right_resource'
# Core extensions of Hash
@roothybrid7
roothybrid7 / xhrioextbinary.js
Created October 14, 2011 12:32
XMLHttpRequestを拡張してFirefoxのsendAsBinaryを使う&Google closure libraryでsendAsBinaryを使う
/**
* xhrioextbinary.js - goog.net.XhrIo Extension for sendAsBinary
*
* @license Copyright 2011 The xhrdavclient library authors. All rights reserved.
*/
goog.provide('xhrdav.lib.XhrIoExtBinary');
goog.require('xhrdav.lib.Config');
goog.require('goog.net.XhrIo');
@roothybrid7
roothybrid7 / v0.1.0_change.js
Created October 17, 2011 01:45
xhrdavclient v0.1.0変更点
goog.require('xhrdav.DavFs');
goog.require('xhrdav.HttpStatus');
# 変更前
xhrdav.lib.DavFs.getInstance().upload(path, file. handler, null, null, callback_context, onComplete);
# 変更後(namespaceからlibを消して、getRequest()をよんでからAPIを呼ぶ)
xhrdav.DavFs.getInstance().getRequest().upload(path, file, handler, null, null, callback_context, opt_helper, onComplete);