Skip to content

Instantly share code, notes, and snippets.

View osulyanov's full-sized avatar
🎯
Focusing

Oleg osulyanov

🎯
Focusing
  • Passion.io
View GitHub Profile
@nbibler
nbibler / en.yml
Created December 20, 2010 12:58
An ActiveModel::EachValidator to check local attribute value against "project" value.
en:
errors:
messages:
project_effort_exceeded: 'cannot be larger than project effort'
@goofmint
goofmint / WordPress3 Authorize Algorithm for Ruby
Created November 24, 2010 12:34
wp-includes/class-phpass.phpのパスワード生成部分をRubyで再実装したもの。WordPressの認証をRubyから直接利用した時に。
require 'digest/md5'
def crypt_private(password, setting)
output = '*0'
itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
output = '*1' if setting[0..1] == output
return output if setting[0..2] != '$P$'
salt = setting[4..11]
return output if salt.length != 8
count_log2 = itoa64.index(setting[3])
@dnagir
dnagir / rspec-syntax-cheat-sheet.rb
Created November 5, 2010 09:29
RSpec 2 syntax cheat sheet by example
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")