Skip to content

Instantly share code, notes, and snippets.

View fabiokr's full-sized avatar

Fabio Kreusch fabiokr

View GitHub Profile
# IRB
s = Service.new
s.brand
# => nil
s.brand_id = 1
s.brand
# => #<Brand id: 1, name: "Brand 1", active: false, created_at: "2012-07-11 13:24:02", updated_at: "2012-07-11 13:24:02", franchise: false, data: nil, default_payment_gateway_id: 1, tsv: "'1':2 'brand':1", currency: "USD">
guake-helix() {
# HelixCore
guake --rename-tab="CoreSpec" --execute-command="cd /home/fabio/dev/site5/helix_core && bundle exec guard" &&
guake --new-tab=2 --rename-tab="Core" --execute-command="cd /home/fabio/dev/site5/helix_core" &&
# Helix
guake --new-tab=3 --rename-tab="HelixServer" --execute-command="cd /home/fabio/dev/site5/helix && rails s" &&
guake --new-tab=4 --rename-tab="HelixSpec" --execute-command="cd /home/fabio/dev/site5/helix && bundle exec guard" &&
guake --new-tab=5 --rename-tab="Helix" --execute-command="cd /home/fabio/dev/site5/helix";
}
@fabiokr
fabiokr / snippet_backend.rb
Created August 24, 2012 18:55 — forked from pacoguzman/snippet_backend.rb
I18n that include pluralization rules for spanish within Rails - http://www.viget.com/extend/rails-internationalization-and-tu/
module I18n
module Backend
class SnippetBackend < Simple
protected
def init_translations
load_translations(*I18n.load_path.flatten)
load_translations_from_database
@initialized = true
end
#!/usr/bin/env ruby
LOCKFILE_NAME = "Gemfile.lock"
lockfile = File.readlines(LOCKFILE_NAME)
# Finds where the gem dependency tree begins
def beginning(gem_name, lockfile)
lockfile.each_with_index do |line, index|
if line.include?("specs:") && lockfile[index+1].include?(gem_name)
#!/usr/bin/env ruby
#
# Usage: rebundle gem_name
#
# The script will remove the gem dependency tree from the lockfile and bundle.
LOCKFILE_NAME = "Gemfile.lock"
lockfile = File.readlines(LOCKFILE_NAME)
class Example
attr_accessor :var_1, :var_2
def with_self(var)
self.var_1 = var
end
def without_self(var)
var_2 = var
end
@fabiokr
fabiokr / .irbrc.rb
Last active December 11, 2015 05:58
Install Pry + AwesomePrint globally
# Requires a gem outside of Bundler.
#
# gem - the gem name
# const - only requires the gem if const is not yet defined
#
# Reference: https://gist.github.com/3894925
def unbundled_require(*gems)
if defined?(::Bundler)
gems.each do |gem|
spec_path = Dir.glob("#{Gem.dir}/specifications/#{gem}-*.gemspec").last

ruby-1.9.3-p327 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.

Keybase proof

I hereby claim:

  • I am fabiokr on github.
  • I am fabiokr (https://keybase.io/fabiokr) on keybase.
  • I have a public key whose fingerprint is 45B2 ADBB D9C9 89CC 4EC0 3B1E 71D8 FFF7 14DE 4EDF

To claim this, I am signing this object:

require 'erb'
class Ansible
class TemplateParams
attr_accessor :content, :helper
# Public: Initializes the Template Params context.
#
# content - the Ansible content
def initialize(content)