Skip to content

Instantly share code, notes, and snippets.

@shekibobo
shekibobo / polymorphic_any_of_spec.rb
Last active August 29, 2015 13:57
polymorphic_any_of_spec.rb
unless File.exists?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
gem 'sqlite3'
gem 'activerecord_any_of'
gem 'pry'
gem 'pg'
GEMFILE
@shekibobo
shekibobo / serialized_encoding.rake
Last active August 29, 2015 13:56
Convert serialized yaml from syck to psych
require 'yaml'
# original idea comes from http://darwinweb.net/articles/convert-syck-to-psych-yaml-format
namespace :encoding do
desc 'convert serialized Content data from syck yaml serializations to psych'
task :psych => :environment do
content_id = ENV['content_id']
if content_id
convert_data Content.find(content_id)
unless File.exists?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
gem 'sqlite3'
GEMFILE
system 'bundle'
end
Pod::Spec.new do |s|
s.name = "ReactiveCocoa"
s.version = "1.9.6"
s.summary = "A framework for composing and transforming sequences of values."
s.homepage = "https://github.com/blog/1107-reactivecocoa-is-now-open-source"
s.author = { "Josh Abernathy" => "josh@github.com" }
s.source = { :git => "https://github.com/ReactiveCocoa/ReactiveCocoa.git", :tag => "v#{s.version}" }
s.license = 'Simplified BSD License'
s.description = "ReactiveCocoa offers:\n" \
"1. The ability to compose operations on future data.\n" \
class User < ActiveRecord::Base
rolify :after_add => :event_added_mew_role #, :role_cname => 'Role'
accepts_nested_attributes_for :roles
attr_accessible :roles_attributes
# Include default devise modules. Others available are:
# :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable, :token_authenticatable,
:recoverable, :rememberable, :trackable, :validatable
@shekibobo
shekibobo / palindrome.rb
Created January 8, 2012 05:53
Testing for TheRubyGame Palindrome
#!/usr/bin/env ruby
class Palindrome
return string if string.length == 1
l = ""
string.size.times do |i|
break if string.size - i <= l.size
c = -1
while (a = string.rindex(string[i], c)) != i || a - i > l.size do
b = string[i..a]