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 story.rb
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
View fake_active_record_model.rb
module FakeActiveRecord
class Errors < Hash
alias_method :count, :size
def full_messages
map do |key, message|
"#{message}"
end
end
end
end
View wp_comments_to_disqus.rb
#!/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'
View to_binary.clj
(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))))
)
View rm_trailing_whitespace.rb
#!/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
View counting_code_lines.rb
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)
View transitive_dependencies.rb
require 'test/unit'
class Dependencies
def initialize
@deps = Hash.new([])
end
def add_direct(klass, dep_klasses)
@deps[klass] = dep_klasses
View factory_girl.rb
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'
View update_user.feature
Feature: Edit user settings
In order to save a ton of time
As a Teambox admin
I want users to edit their own settings
View production.rb
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
You can’t perform that action at this time.