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 MyModel < ActiveRecord::Base | |
belongs_to :owner, polymorphic: true | |
ransacker :owner_name, formatter: proc { |value| | |
# To use this, you have to know what all of the possible owner types can be. | |
# For this example, the #owner_type could be either Group or Advertiser. | |
# The fields we want to search on are: | |
# Group#name | |
# Advertiser#contact_name | |
# |
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
Replace Harvest.app/Resources/m-h-stop.png with this image |
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
# try requiring and including awesome_print | |
# if gem is not installed, will simply pass over this. | |
require "awesome_print" | |
AwesomePrint.pry! if defined?(AwesomePrint) | |
# | |
# output becomes: | |
# | |
# [1] app_folder_name development(main)> def something | |
# 1 > "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
install_package "openssl-1.0.1e" "https://www.openssl.org/source/openssl-1.0.1e.tar.gz#66bf6f10f060d561929de96f9dfe5b8c" mac_openssl --if has_broken_mac_openssl | |
install_package "ruby-2.0.0-p247" "http://www.mirrorservice.org/sites/ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p247.tar.gz" standard verify_openssl |
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
# :enddoc: | |
require 'test/unit/testcase' | |
if defined?(ActionController) | |
require 'shoulda/matchers/action_controller' | |
class ActionController::TestCase | |
include Shoulda::Matchers::ActionController | |
extend Shoulda::Matchers::ActionController |
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
# Audited initializer to globally disable audits except when needed. | |
# https://gist.github.com/4392334 | |
# | |
# Hacked from idea originally provided in issue: | |
# https://github.com/collectiveidea/audited/issues/18 | |
# by Frost (github.com/Frost) | |
# | |
# Modified by Doug Clark (github.com/dougc84) | |
# | |
# Add this in an initializer (audited.rb) |
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 HomeController < ApplicationController | |
layout 'login' | |
before_filter :actions_if_signed_in | |
def index | |
end | |
def blocked | |
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
#!/bin/bash | |
sudo killall -HUP mDNSResponder |
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
#!/usr/bin/env ruby | |
require 'benchmark' | |
require 'active_support/core_ext/array' # required for Array.wrap. | |
# by the way, did you know there is a "my_array.fourty_two()" method? | |
Benchmark.bm do |b| | |
language = [] | |
100.times do | |
language << "8foanin" |
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
Find HTML Entities | |
&[^\s]*; |
NewerOlder