This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SimpleForm::FormBuilder.class_eval do | |
def input_with_bs_cols(attribute_name, options = {}, &block) | |
bs_cols_classes = parse_bs_cols_option(options) | |
if bs_cols_classes | |
wrapper_html_options = (options[:wrapper_html] || {}) | |
.merge_html_attributes(class: bs_cols_classes.join(' ')) | |
options[:wrapper_html] = wrapper_html_options |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hash.class_eval do | |
def recursive_map_values(&block) | |
reduce({}) do |m, (k, v)| | |
m[k] = v.is_a?(Hash) ? v.recursive_map_values(&block) : block.call(self, k, v) | |
m | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Bacon | |
class Resource | |
def initialize(name, parent, options = {}) | |
@name = name | |
@parent = parent | |
@options = options | |
@result = options[:result] || [] | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/admin/account.rb for toplevel configuration options | |
ActiveAdmin.register Account do | |
config.batch_actions = false | |
end | |
# app/admin/account/form.rb | |
ActiveAdmin.register Account do | |
form do |f| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Hash | |
def as_object | |
HashObject.new self | |
end | |
end | |
#> o = { foo: (->(this) { puts this.bar }), bar: 'hello') }.as_object | |
#> o.foo | |
# => hello |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spork' | |
require 'database_cleaner' | |
ENV["RAILS_ENV"] ||= 'test' | |
def configure_rspec | |
RSpec.configure do |config| | |
config.mock_with :rspec | |
config.use_transactional_fixtures = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'http://rubygems.org/' | |
gem 'coffee-script' | |
gem 'compass' | |
gem 'guard' | |
gem 'guard-shell' | |
gem 'haml' | |
gem 'rb-inotify' | |
gem 'kramdown' | |
gem 'nokogiri' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro << [k-or-ks f] | |
`(fn [state#] | |
(update-in state# | |
~(if (vector? k-or-ks) | |
k-or-ks | |
(vector k-or-ks)) | |
~f))) | |
(defn >>* [state form] | |
(condp = (first form) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use 'clojure.core.logic) | |
(def rvar? (comp not lvar?)) | |
(defmacro arithm [r x y op po] | |
`(fn [a#] | |
(let [r# (walk a# ~r) | |
x# (walk a# ~x) | |
y# (walk a# ~y)] | |
(cond |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class ComUtils | |
{ | |
public static object Get(object obj, string key, object[] args = null) | |
{ | |
return obj.GetType().InvokeMember( | |
key, | |
System.Reflection.BindingFlags.GetProperty, | |
null, | |
obj, | |
args); |