Skip to content

Instantly share code, notes, and snippets.

View bradleypriest's full-sized avatar

Bradley Priest bradleypriest

View GitHub Profile
@bradleypriest
bradleypriest / findManyInChunks.js
Last active August 29, 2015 13:57
FindManyInChunks
function flatten(arrays) {
return Array.prototype.concat.apply([], arrays)
}
findMany: function(store, type, ids) {
var chunkSize = 200;
if (ids.length > chunkSize) {
var promises = [],
index = 0,
currentIds;
!gmail.com
.gmail.com
1033edge.com
11mail.com
123.com
123box.net
123india.com
123mail.cl
123qwe.co.uk
150ml.com
{% for item in product_line_items %}
{{item.label}} {{item.quantity}} of a {{item.variant.title}} at {{item.price | money}} each.
{% endfor %}
@bradleypriest
bradleypriest / arel_scopes.rb
Created September 18, 2011 08:27
Arel Scopes
module ArelScopes
extend ActiveSupport::Concern
module ClassMethods
# Create chainable arel scopes
# Example:
# class Post
# arel_scope :published, lambda { arel_table[:published_at].gteq(Time.now) }
# arel_scope :written_by, lambda { |user| arel_table[:author_id].eq(user.id) }
@bradleypriest
bradleypriest / assets.rake
Created September 21, 2011 08:49
Monkey-Patch rake assets:precompile to get Devise to work with Heroku
Rake::Task['assets:precompile'].clear
namespace :assets do
desc "Compile all the assets named in config.assets.precompile"
task :precompile do
# We need to do this dance because RAILS_GROUPS is used
# too early in the boot process and changing here is already too late.
if ENV["RAILS_GROUPS"].to_s.empty? || ENV["RAILS_ENV"].to_s.empty?
ENV["RAILS_GROUPS"] ||= "assets"
@bradleypriest
bradleypriest / jasmine.yml
Created February 27, 2012 22:41
Using Jammit packages in Jasmine
src_files:
- public/javascripts/lib/jquery/jquery.js
# jammit_packages
#
# See jasmine_config.rb
jammit_packages:
- head
- common
@bradleypriest
bradleypriest / active_record.rb
Created March 22, 2012 20:01 — forked from jcf/active_record.rb
Backport pluck to Rails 3.0/3.1
# config/initializers/extensions/active_record.rb
module ActiveRecord
class Base
class << self
delegate :pluck, to: :scoped
end
end
class CollectionProxy
delegate :pluck, to: :scoped
require 'oauth2'
require 'foursquare2'
class FoursquareBot
BURGER_FUEL_PARNELL_ID = "4b3992a0f964a520d05d25e3"
attr_accessor :client
def initialize(token)
@client = Foursquare2::Client.new(:oauth_token => token)
end
@bradleypriest
bradleypriest / convert_hex_to_rgb.py
Created April 4, 2012 00:00
Convert Hex To RGB Sublime Plugin
# Add a key binding to your User Key Bindings and you're all good to go
# { "keys": ["super+shift+h"], "command": "convert_hex_to_rgb" }
#
import sublime, sublime_plugin
class ConvertHexToRgb(sublime_plugin.TextCommand):
def run(self, edit):
for region in self.view.sel():
if not region.empty():
App.ObjectWatcher = Ember.Object.create({
methodCounter: 0,
observeOnce: function(object, property, callback) {
var aroundCallbackName, callbackName;
callbackName = "_method" + (this.methodCounter++);
aroundCallbackName = callbackName.slice(1);
this[callbackName] = callback;
this[aroundCallbackName] = function() {
this[callbackName]();
object.removeObserver(property, this, aroundCallbackName);