Skip to content

Instantly share code, notes, and snippets.

module BackgroundIndexer
extend ActiveSupport::Concern
included do
after_save { IndexerJob.perform_later('index', self.class.index_name, self.class.name.downcase, self) }
after_destroy { IndexerJob.perform_later('delete', self.class.index_name, self.class.name.downcase, self.id) }
end
end
// Block Grid
// Technique adapted from Foundation 5 for Bootstrap 3.
// https://github.com/zurb/foundation/blob/f755d8704123f86c281ede0b171881e2672f150d/scss/foundation/components/_block-grid.scss
// Original LESS Version by Christopher Mitchell (https://gist.github.com/ChrisTM)
// Converted to SCSS by Rasmus Jürs (https://github.com/Jursdotme)
[class*="block-grid-"] {
display: block;
margin: -($grid-gutter-width/2);
padding: 0;
class Gift::FilterParams
NESTED_PARAMS = %i(send_at sent_at redeemed_at shipped_at created_at updated_at)
attr_reader :originals
def initialize(params)
@originals = if params.is_a?(Gift::FilterParams)
params.originals.dup
elsif params.present?
params.with_indifferent_access
else
module Stubs
module S3
def s3_succeeds_to_get_fixture(fixture)
WebMock.stub_request(:get, /https:\/\/s3\.amazonaws\.com\/test\.loopandtie\.com\/csv_imports\/.*#{fixture}/).
with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>''}).
to_return(:status => 200, :body => fixture_url(fixture), :headers => {})
end
def s3_succeeds_to_check_files
WebMock.stub_request(:head, /https:\/\/s3\.amazonaws\.com\/test\.loopandtie\.com\/.*/).
@dimroc
dimroc / DDLogHelper.swift
Last active July 28, 2017 10:46
Wrapper around the Objective C DDLog found in CocoaLumberjack 2.x
import Foundation
public let defaultDebugLevel = DDLogLevel.Debug
public let defaultTag = NSString(format: "ManhattanForum")
class DDLogHelper {
class func SwiftLogMacro(async: Bool, level: DDLogLevel, flag flg: DDLogFlag, context: Int = 0, file: String = __FILE__, function: String = __FUNCTION__, line: UWord = __LINE__, tag: AnyObject? = defaultTag, format: String, args: CVaListPointer) {
let string = NSString(format: format, arguments: args) as String
SwiftLogMacro(async, level: level, flag: flg, context: context, file: file, function: function, line: line, tag: tag, string: string)
}
# Could not call this DatepickerInput because it leads to
# the setting of css classes that cause chaos in the javascript/css
# side of things.
class BetterDateInput < SimpleForm::Inputs::StringInput
def input(wrapper_options = nil)
input_html_classes.unshift(:datepicker)
input_html_options[:autocomplete] = 'off'
value = @builder.object.send(attribute_name)
input_html_options[:value] = case value
class Datafixes::AddSupplierIdToGifts < Datafix
def self.up
execute(<<-SQL)
UPDATE gifts SET supplier_id = products.selected_supplier
FROM (SELECT gifts.id as gift_id, products.supplier_id as selected_supplier FROM gifts JOIN products
ON gifts.selected_product_id = products.id
WHERE stage = 'redeemed') as products
WHERE gifts.id = products.gift_id
SQL
end
class FastlyAssetsProvider
include Roadie::AssetProvider
def find_stylesheet(name)
Rails.logger.info("## FastlyAssetsProvider retrieving asset named: #{name}")
asset_host = Rails.application.config.action_mailer.asset_host
return nil unless asset_host.present?
uri = URI(name)
uri.scheme = 'https'
@dimroc
dimroc / .bashrc
Last active August 29, 2015 14:22 — forked from mitio/.bashrc
minimal bashrc used for docker containers
export CLICOLOR=1
export LANG="en_US.UTF-8"
alias rm="rm -i"
alias mv="mv -i"
alias cp="cp -i"
alias ls="ls --color=auto"
alias ll="ls -alh"