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
[UUID.random_create.raw].pack('m').tr('+/', '-_').chop |
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
class A | |
def initialize(a, &block) | |
a.instance_variables.each do |var| | |
instance_variable_set(var, a.instance_variable_get(var)) | |
end | |
instance_eval(&block) | |
end | |
def aaa | |
p :aaa |
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 'rubygems' | |
require 'not_naughty' | |
NotNaughty::Validation.load 'presence', 'length' | |
Person = Struct.new(:name) do | |
extend NotNaughty | |
validates(:name) { presence and length :minimum => 4 } | |
end |
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 'uri' | |
require 'time' | |
require 'openssl' | |
require 'rubygems' | |
require 'typhoeus' | |
require 'nokogiri' | |
class JAWS | |
include Typhoeus |
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 'rubygems' | |
require 'typhoeus' | |
class Remote | |
include Typhoeus | |
end | |
# http://groups.google.co.jp/group/typhoeus/browse_thread/thread/f890713ec5d275f1?hl=ja | |
# | |
# following get does't fire. |
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 'rubygems' | |
require 'block-html' | |
class BlockHTML | |
class Form < BlockHTML | |
attr_reader :values | |
def initialize(env_instance=nil, &block) | |
@values = {} | |
super |
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 'rubygems' | |
require 'typhoeus' | |
require 'sinatra' | |
class ReCAPTCHA | |
include Typhoeus | |
BASE_URI = 'http://api-verify.recaptcha.net/verify' | |
def self.verify(params) | |
r = self.post(BASE_URI, :params => params) |
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 'rubygems' | |
require 'raws' | |
module RAWS::SDB::Model | |
module ClassMethods | |
def generate_id | |
[ | |
UUIDTools::UUID.random_create.raw | |
].pack('m').tr('+/', '-_').chop.gsub('=', '') | |
end |
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
HTTP library for Ruby. | |
Basic idea of HT2P library. | |
I want to manage huge data via HTTP. | |
require 'rubygems' | |
require 'ht2p' |
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
import itertools | |
from google.appengine.ext.db.djangoforms import * | |
class ModelForm(djangoforms.ModelForm): | |
def save(self, commit=True, parent=None, key_name=None, **kw): | |
"""Save this form's cleaned data into a model instance. | |
Args: | |
commit: optional bool, default True; if true, the model instance | |
is also saved to the datastore. |
OlderNewer