Skip to content

Instantly share code, notes, and snippets.

@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]
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
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" \
@shekibobo
shekibobo / has_many_through_with_includes_test.rb
Last active September 20, 2018 08:36
Illustrates the issue described in [#9517](https://github.com/rails/rails/issues/9517).
unless File.exists?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
gem 'sqlite3'
GEMFILE
system 'bundle'
end
@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)
@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 / double_polymorphic_any_of_test.rb
Last active August 29, 2015 13:57
double_polymorphic_any_of_test.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 / eager_load_to_sql_bug_test.rb
Created April 10, 2014 20:16
Testing failures of arel related to `eager_load` queries not generating correct `to_sql`.
unless File.exists?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
gem 'sqlite3'
gem 'pry'
gem 'pg'
GEMFILE
system 'bundle'
@shekibobo
shekibobo / formatDate.js
Last active August 29, 2015 14:00
Date formatting code used by XDSoft DateTimePicker
//http://www.xaprb.com/blog/2005/12/12/javascript-closures-for-runtime-efficiency/
/*
* Copyright (C) 2004 Baron Schwartz <baron at sequent dot org>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, version 2.1.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+requirements_osx_brew_libs_install:2> brew unlink libksba
Error: No such keg: /usr/local/Cellar/libksba
+requirements_osx_brew_libs_install:2> true
+requirements_osx_brew_libs_install:3> brew install libksba
==> Downloading ftp://ftp.gnupg.org/gcrypt/libksba/libksba-1.3.0.tar.bz2
Already downloaded: /Library/Caches/Homebrew/libksba-1.3.0.tar.bz2
==> ./configure --prefix=/usr/local/Cellar/libksba/1.3.0
==> make install
libtool: link: cannot determine absolute directory name of `@@HOMEBREW_CELLAR@@/libgpg-error/1.12/lib'
make[2]: *** [libksba.la] Error 1