Skip to content

Instantly share code, notes, and snippets.

Enjoying life, including work.

Balint Erdi balinterdi

Enjoying life, including work.
Block or report user

Report or block balinterdi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:68947
describe "Sinatra::MyHelpers" do
describe "sessions" do
before do
mock_app {
set(:sessions => true)
include Sinatra::MyHelpers
get '/login' do
session[:ok] = "Ok."
View acts_as_shareable.rb
def shared_to?(object, by_user=nil)
shareable = ActiveRecord::Base.send(:class_name_of_active_record_descendant, self.class).to_s
to = ActiveRecord::Base.send(:class_name_of_active_record_descendant, object.class).to_s
if by_user
s = Share.find(:first, :conditions=>["shareable_type = ? and shareable_id = ? and shared_to_type = ? and shared_to_id = ? and user_id=?",
shareable, id, to,,])
s = Share.find(:first, :conditions=>["shareable_type = ? and shareable_id = ? and shared_to_type = ? and shared_to_id = ?",
shareable, id, to,])
View gist:73024
require "yaml"
require "forwardable"
require "pp"
require "ruby-debug"
class Hash
def has_nested_key?(key)
h = self
key.to_s.split('.').each do |segment|
return false unless h.key?(segment)
View gist:77581
Scenario: Create album
Given I am logged in as "pepito"
When I go to my profile page
Given /^the user (.*) exists$/ do |login_name|
User.find_by_login(login_name) || Factory(:user_with_password, :login => login_name)
Given /^I log in as (.*)$/ do |login_name|
View gist:83632
# cucumber.yml
# Filter which features are run with each profile by the file extension
webrat: --require features/steps/common --require features/support/webrat_env.rb --exclude selenium.feature --format progress
selenium: --require features/steps/common --require features/support/selenium_env.rb --exclude webrat.feature --format progress
# features/support/env.rb
View cucumber.yml
default: -r features/support/env.rb -r features/support/plain.rb -r features/step_definitions features/plain
selenium: -r features/support/env.rb -r features/support/enhanced.rb -r features/step_definitions features/enhanced
View mongrel_cluster.yml
-rw-r--r-- 1 deploy deploy 10011 Mar 30 19:46 README
-rw-r--r-- 1 deploy deploy 307 Mar 30 19:46 Rakefile
drwxr-xr-x 6 deploy deploy 4096 Mar 27 12:45 app
drwxr-xr-x 5 deploy deploy 4096 Apr 1 12:23 config
drwxr-xr-x 2 deploy deploy 4096 Mar 30 19:46 db
drwxr-xr-x 2 deploy deploy 4096 Mar 30 19:46 doc
drwxr-xr-x 3 deploy deploy 4096 Mar 30 19:46 lib
drwxrwxr-x 2 mongrel deploy 4096 Apr 1 11:28 log
drwxr-xr-x 5 deploy deploy 4096 Mar 27 12:52 public
drwxr-xr-x 3 deploy deploy 4096 Mar 30 19:46 script
balinterdi / gist:107361
Created May 6, 2009
Rails app template for the acts_as_trivia gem
View gist:107361
# App template for generating acts_as_trivia enable applications
# See
def ask_with_default(question, default='')
user_answer = ask(question).strip
user_answer.empty? ? default : user_answer
# generate a model class
model_name_and_attributes = ask_with_default("Define the model in Rails resource generate style. (e.g country name:string population:integer)", "country name:string population:integer")
View gist:118126
class ControllerHelper
include Singleton
include ActionView::Helpers
def url_helpers
You can’t perform that action at this time.