Skip to content

Instantly share code, notes, and snippets.

View DBA's full-sized avatar

Diogo Almeida DBA

  • Apple, Inc.
View GitHub Profile
@DBA
DBA / gist:858192
Created March 7, 2011 07:34
rspec undefined method get
require 'spec_helper'
describe ArticlesController, :type => :controller do
describe "GET index" do
get :index
response.should be_successful
end
end
# encoding: utf-8
require 'active_support/all'
Time.zone = Time.zone_default = "UTC"
t = "2008-04-01".to_time
p t.zone, t.to_time.zone #=> "UTC" and "WEST". Question is, why not "UTC" and "UTC"?
# encoding: utf-8
DOTIW_LIB_PATH = File.join(File.dirname(__FILE__), '..', 'lib')
$:.unshift DOTIW_LIB_PATH unless $:.include? DOTIW_LIB_PATH
$:.unshift File.dirname(__FILE__)
require 'active_support'
require 'active_support/core_ext/time/zones'
require 'ruby-debug'
@DBA
DBA / gist:745868
Created December 17, 2010 23:02
RSA with no padding
# encoding: UTF-8
require 'ruby-debug'
require 'openssl'
def crypt(value, padding = OpenSSL::PKey::RSA::NO_PADDING)
public_key = get_rsa_key 'public.pem'
public_key.public_encrypt value, padding
end
require 'openssl'
class MyEncryptor
KEY = "\xE9v\f\xC3\xBD\x8EH\xBD.G\x17\x84\xD5K\xDB\xE5\r\x8D0\xEC\xBF9\xA2\xAF\x9Bp\xFEd\xAA\x8DH\x99"
IV = "\x94\x19\xB7\x96\xC7\xFC\x92:_4\xB4\xF6\xCE\xED\xB9\xD0"
def self.encrypt(text)
self.aes_wrapper(:encrypt, text)
end
export PATH=/opt/local/bin:/opt/local/sbin:/usr/local/mysql/bin:$PATH
export DISPLAY=:0.0
export EDITOR='mate -w'
#########
# Alias #
#########
# File system
alias lsl='ls -lah'
require 'spec_helper'
context Post do
subject { Factory.build(:post) }
describe "accessible attributes" do
it "defines the attributes that are mass assignable" do
Post._accessible_attributes.to_a == ["user_id", "title", "body"]
module Arel
module SqlCompiler
class GenericCompiler
def select_sql
projections = @relation.projections
@engine = engine
module ActiveRecordAttributesEquality
def self.included(klass)
klass.class_eval do
def ==(other)
return false unless other.is_a? self.class
if self.new_record? && other.new_record?
self.attributes == other.attributes
else
@DBA
DBA / gist:465562
Created July 6, 2010 15:58
Rails.configuration
(rdb:4) pp Rails.configuration
#<Rails::Application::Configuration:0x00000100920e90
@allow_concurrency=false,
@cache_classes=false,
@cache_store=
[:file_store,
"/Users/dba/work/gnomeslab.com/programming/oauth2-ruby-server-rails-example/tmp/cache/"],
@consider_all_requests_local=true,
@dependency_loading=true,
@encoding="utf-8",