Skip to content

Instantly share code, notes, and snippets.

@dakatsuka
dakatsuka / gist:201528
Created October 4, 2009 18:07
error_message_onカスタマイズ版
class ActionView::Base
@@field_error_proc = Proc.new{ |html_tag, instance| "<span class=\"fieldWithErrors\">#{html_tag}</span>" }
end
ActionView::Helpers::ActiveRecordHelper.module_eval do
def error_message_on(object, method, *args)
options = args.extract_options!
unless args.empty?
ActiveSupport::Deprecation.warn('error_message_on takes an option hash instead of separate ' +
'prepend_text, append_text, and css_class arguments', caller)
@dakatsuka
dakatsuka / gist:556157
Created August 29, 2010 09:48
RequestMethodOverride (RackMiddleware)
class RequestMethodOverrider
HTTP_METHODS = %w(GET HEAD PUT POST DELETE OPTIONS)
HTTP_METHOD_OVERRIDE_KEY = "__method".freeze
def initialize(app)
@app = app
end
def call(env)
begin
require File.expand_path('../.bundle/environment', __FILE__)
rescue LoadError
require 'rubygems'
require 'bundler'
Bundler.setup
Bundler.require
end
--- config.mk.old 2010-10-17 19:35:43.000000000 +0900
+++ config.mk 2010-10-17 18:56:26.000000000 +0900
@@ -8,10 +8,10 @@
HAS_XLINK=n
# Support Wpa_Supplicant
-HAS_WPA_SUPPLICANT=n
+HAS_WPA_SUPPLICANT=y
# Support Native WpaSupplicant for Network Maganger
--- rtusb_dev_id.c.old 2010-10-17 19:51:34.000000000 +0900
+++ rtusb_dev_id.c 2010-10-17 19:53:46.000000000 +0900
@@ -60,6 +60,7 @@
{USB_DEVICE(0x14B2,0x3C06)}, /* Conceptronic */
{USB_DEVICE(0x14B2,0x3C28)}, /* Conceptronic */
{USB_DEVICE(0x2019,0xED06)}, /* Planex Communications, Inc. */
+ {USB_DEVICE(0x2019,0xAB24)}, /* Planex GW-US300MiniS */
{USB_DEVICE(0x07D1,0x3C09)}, /* D-Link */
{USB_DEVICE(0x07D1,0x3C11)}, /* D-Link */
{USB_DEVICE(0x14B2,0x3C07)}, /* AL */
--- rt_linux.h.old 2010-10-17 19:55:36.000000000 +0900
+++ rt_linux.h 2010-10-17 18:58:08.000000000 +0900
@@ -1074,8 +1074,8 @@
#define RT28XX_PUT_DEVICE usb_put_dev
#define RTUSB_ALLOC_URB(iso) usb_alloc_urb(iso, GFP_ATOMIC)
#define RTUSB_SUBMIT_URB(pUrb) usb_submit_urb(pUrb, GFP_ATOMIC)
-#define RTUSB_URB_ALLOC_BUFFER(pUsb_Dev, BufSize, pDma_addr) usb_buffer_alloc(pUsb_Dev, BufSize, GFP_ATOMIC, pDma_addr)
-#define RTUSB_URB_FREE_BUFFER(pUsb_Dev, BufSize, pTransferBuf, Dma_addr) usb_buffer_free(pUsb_Dev, BufSize, pTransferBuf, Dma_addr)
+#define RTUSB_URB_ALLOC_BUFFER(pUsb_Dev, BufSize, pDma_addr) usb_alloc_coherent(pUsb_Dev, BufSize, GFP_ATOMIC, pDma_addr)
+#define RTUSB_URB_FREE_BUFFER(pUsb_Dev, BufSize, pTransferBuf, Dma_addr) usb_free_coherent(pUsb_Dev, BufSize, pTransferBuf, Dma_addr)
@dakatsuka
dakatsuka / streaming.rb
Created October 31, 2010 10:18
Twitter Streaming API to MongoDB.
# coding: utf-8
# This program is free software. It comes without any warranty, to
# the extent permitted by applicable law. You can redistribute it
# and/or modify it under the terms of the Do What The Fuck You Want
# To Public License, Version 2, as published by Sam Hocevar. See
# http://sam.zoy.org/wtfpl/COPYING for more details.
require 'rubygems'
require 'net/https'
@dakatsuka
dakatsuka / env.rb
Created November 1, 2010 10:15
features/support/env.rb
Before do
require 'factory_girl'
require 'faker'
Dir.glob(File.join(File.dirname(__FILE__), '../../spec/factories/*.rb')).each {|f| require f}
end
@dakatsuka
dakatsuka / mobile.rb
Created November 1, 2010 10:18
features/step_definitions/mobile.rb
前提 /^携帯でアクセスしている$/ do
header('user_agent', 'DoCoMo/2.0 P906i(c100;TB;W24H15)')
header('x_dcmguid', 'subscriber')
end
@dakatsuka
dakatsuka / cipher.rb
Created November 15, 2010 09:37
暗号化・復号化
# coding: utf-8
require 'openssl'
def encrypt(str, secret)
enc = OpenSSL::Cipher::Cipher.new("AES-256-CBC")
enc.encrypt
enc.pkcs5_keyivgen(secret)
return (enc.update(str) + enc.final).unpack("H*").first.to_s
end