Skip to content

Instantly share code, notes, and snippets.

View inem's full-sized avatar
🌰
In progress

Ivan Nemytchenko inem

🌰
In progress
View GitHub Profile
@solnic
solnic / rom_mapper_and_anima.rb
Last active August 29, 2015 13:59
ROM mapper with anima model
require 'rom'
require 'anima'
class User
include Anima.new(:id, :name, :tasks)
end
class Task
include Anima.new(:title)
end
@ravicious
ravicious / parens.md
Last active August 29, 2015 14:17
Real talk about dem brackets

Real talk about dem brackets

  • Steve Losh's great post A Modern Space Cadet.
    • Shift Parentheses section.
      • You might want to skip the last <autogen> rule, as it makes typing uppercased words by holding the shift key a pretty terrible experience.
    • Control/Escape section.
    • KeyRemap4MacBook is now Karabiner.
  • Using Linux? You can get pretty much the same results with xmodmap, just google around.
  • Shif parentheses can be done in a similar way, I'll post my xmodmap config for them when I get home.
#!/usr/bin/env ruby
require 'rubygems'
require 'sinatra'
require 'active_support'
require 'haml'
require 'thin'
gem 'tmm1-amqp'
require 'mq'
require 'rubygems'
require 'haml'
require 'effigy'
require 'effigy/core_ext/hash'
template = Haml::Engine.new(%{%html
%head
%title
%body
%h1
require 'rubygems'
puts ENV["GEM_HOME"]
require 'mongoid'
require 'mongoid/version'
puts "Using Mongoid: #{Mongoid::VERSION}"
Mongoid.master = Mongo::Connection.new.db("mongoid_playground")
class Animal
@kossnocorp
kossnocorp / Gemfile
Created November 23, 2010 15:17
config/application.rb
...
group :development do
...
gem 'rails3-generators'
gem 'haml-rails'
...
end
...
@netzpirat
netzpirat / string_call.coffee
Created November 29, 2010 21:23
String.call and Namespaces in CoffeeScript tested with JasmineBDD
#
# Calls a function that is defined as a String
#
# 'ws.extranett.subdomain_for'.call('argument1', 'argument2')
#
# Will call the function subdomain_for bound on the object extranett
# with arguments 'argument1' and 'argument2'
#
String::call = (args...) ->
@nutrun
nutrun / earl.rb
Created March 3, 2011 02:49
Ruby strings that do web things
# Earl: Strings that do web things
#
#
# Examples:
#
# text = "Blah blah http://tinyurl.com/4bnjzbu blah http://tinyurl.com/4tefu9f"
#
# text.urls # => ["http://tinyurl.com/4bnjzbu", "http://tinyurl.com/4tefu9f"]
#
# text.locations # => ["http://nutrun.com/weblog/2010/11/17/supercharged-ruby-console-output.html", "http://nutrun.com"]
@route
route / gist:2489600
Created April 25, 2012 13:11
Additions to rr stubbing
# Dynamic method stubbing
# user = Factory(:user)
# callbacks = User._create_callbacks.map(&:filter)
# stub_methods("user", callbacks)
def stub_methods(name, methods)
methods.each do |method|
eval "stub(#{name}).#{method}"
end
end
@adamico
adamico / simple_form_bootstrap.rb
Created August 30, 2013 09:06
Twitter Bootstrap 3 initializer for Simple Form
# Use this setup block to configure all options available in SimpleForm.
SimpleForm.setup do |config|
# you need an updated simple_form gem for this to work, I'm referring to the git repo in my Gemfile
config.input_class = "form-control"
config.wrappers :bootstrap, tag: 'div', class: 'form-group', error_class: 'error' do |b|
b.use :html5
b.use :placeholder
b.use :label
b.use :input