Skip to content

Instantly share code, notes, and snippets.

View balinterdi's full-sized avatar
👌
Enjoying life, including work.

Balint Erdi balinterdi

👌
Enjoying life, including work.
View GitHub Profile
class Story
attr_reader :forked_stories, :id
class << self
def get_id
last_id = instance_variable_get("@last_id")
next_id = last_id.nil? ? :a : last_id.to_s.succ.to_sym
instance_variable_set("@last_id", next_id)
# puts "XXX Returning #{next_id}"
next_id
module FakeActiveRecord
class Errors < Hash
alias_method :count, :size
def full_messages
map do |key, message|
"#{message}"
end
end
end
end
#!/usr/bin/env ruby
# Author: Bálint Érdi <balint.erdi@gmail.com>
# forking the work of László Bácsi <lackac@lackac.hu>
require 'rubygems'
require 'httparty'
require 'json'
require 'sequel'
(defn to-binary
([number]
(apply str (to-binary number [])))
([number digits]
(if
(or (= 0 number) (= 1 number)) (cons number digits)
(recur (quot number 2) (cons (rem number 2) digits))))
)
#!/usr/bin/env ruby -w
FILE_TYPES = ["rb", "feature", "yml", "erb", "haml"]
def rm_trailing_whitespace!(file)
trimmed = []
trimmed = File.readlines(file).map do |line|
line.gsub(/\s+$/, "")
end
open(file, "w") { |f| f.write(trimmed) }
end
require 'test/unit'
class CodeLineCounter
class << self
def comment?(line, in_multiline_comment)
line.strip!
return [true, in_multiline_comment] if line.empty?
if in_multiline_comment
if line =~ /\*\/(.*)/
comment?($1, false)
require 'test/unit'
class Dependencies
def initialize
@deps = Hash.new([])
end
def add_direct(klass, dep_klasses)
@deps[klass] = dep_klasses
Factory.define :reset_password do |reset_pw|
reset_pw.reset_code "d1b9547cb3ec99180acfe951c807ec567c8b9252"
reset_pw.association(:user)
end
Factory.define :user do |user|
user.login { Factory.next(:login) }
user.email { Factory.next(:email) }
user.first_name 'Balint'
user.last_name 'Erdi'
Feature: Edit user settings
In order to save a ton of time
As a Teambox admin
I want users to edit their own settings
set :deploy_to, "path_to_teambox_on_production_server"
set :rails_root, deploy_to + "/current"
after "deploy:update_crontab"
namespace :deploy do
desc "Update the crontab file"
task :update_crontab, :roles => :db do
run "cd #{rails_root} && whenever --update-crontab #{application}"
end