Skip to content

Instantly share code, notes, and snippets.

View DBA's full-sized avatar

Diogo Almeida DBA

  • Apple, Inc.
View GitHub Profile
module Arel
module SqlCompiler
class GenericCompiler
def select_sql
projections = @relation.projections
@engine = engine
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"]
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 '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
@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
# 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'
# 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"?
@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