Skip to content

Instantly share code, notes, and snippets.

View bschaeffer's full-sized avatar

Braden Schaeffer bschaeffer

View GitHub Profile
@bschaeffer
bschaeffer / Cacheable.md
Last active December 21, 2015 22:19
Simple, simple method caching for ActiveRecord models

Cacheable

Simple, simple method caching for ActiveRecord models.

Example

class User < ActiveRecord::Base
  include Cacheable

def related_events

@bschaeffer
bschaeffer / route_controller.js
Last active January 3, 2016 12:39
Example of per-model controllers in routes for @Skofo
VerifyRoute = Ember.Route.extend({
renderTemplate: function(controller, model) {
var verifyType = verify.get('type'),
controller = 'verify' + verifyType.capitalize();
this.render('verify/' + type, {controller: controller});
}
});
@bschaeffer
bschaeffer / model.js
Last active August 29, 2015 13:57
dates as string
var dateComputed = function(prop) {
var mProp = prop + 'Month',
yProp = prop + 'Year';
return Ember.computed(mProp, yProp, function(key, value) {
if (arguments.length == 2) {
// setter... maybe moment.js
} else {
// getter... maybe moment.js
}
17:46:20 web.1 | Started GET "/" for 127.0.0.1 at 2014-04-28 17:46:20 -0400
17:46:20 web.1 | Processing by IndexController#index as HTML
17:46:20 web.1 | User Load (25.7ms) SELECT "users".* FROM "users" WHERE "users"."id" = 6 ORDER BY "users"."id" ASC LIMIT 1
17:46:21 web.1 | Account Load (24.9ms) SELECT "accounts".* FROM "accounts" INNER JOIN "account_memberships" ON "accounts"."id" = "account_memberships"."account_id" WHERE "account_memberships"."user_id" = $1 [["user_id", 6]]
17:46:21 web.1 | AccountMembership Load (0.8ms) SELECT "account_memberships".* FROM "account_memberships" WHERE "account_memberships"."user_id" = $1 [["user_id", 6]]
17:46:21 web.1 | User Load (1.0ms) SELECT "users".* FROM "users" INNER JOIN "account_memberships" ON "users"."id" = "account_memberships"."user_id" WHERE "account_memberships"."account_id" = $1 [["account_id", 2]]
17:46:21 web.1 | CACHE (0.1ms) SELECT "accounts".* FROM "accounts" INNER JOIN "account_memberships" ON "accounts".
@bschaeffer
bschaeffer / bug.rb
Created June 10, 2014 21:53
Rails Bug
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
gem 'arel', github: 'rails/arel'
gem 'sqlite3'
GEMFILE
system 'bundle'
end
@bschaeffer
bschaeffer / bug.rb
Created June 10, 2014 22:06
Rails 4.0.3: Polymorphic Bug
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', '4.0.3'
gem 'arel'
gem 'sqlite3'
GEMFILE
system 'bundle'
end
@bschaeffer
bschaeffer / bug.rb
Created June 10, 2014 22:08
Rails Master: Polymorphic Bug
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
gem 'arel', github: 'rails/arel'
gem 'sqlite3'
GEMFILE
system 'bundle'
end
@bschaeffer
bschaeffer / features.md
Last active August 29, 2015 14:04
Big Interview Feature Attack Zones

Big Interview Feature Attack Zones

Each feature should basically be seen as one task, and we should focus on one task at a time. The sub tasks below each feature are just there to explain total work associated with it.

These are in no particular order.


@bschaeffer
bschaeffer / flash.coffee
Created September 18, 2014 15:35
Flash to Javascript Callbacks
# Embed the player
swfobject.embedSWF url, 'BIVideoPlayer', width, height, swfVersion, xiSwfUrl,
callback: 'customCallback'
playerId: 'BIVideoPlayer'
# Flash Event Handler
window.customCallback = (event, playerId, data) ->
selector = "#" + playerId
jQuery(selector).trigger(event, data)
@bschaeffer
bschaeffer / atom-crash.txt
Created November 14, 2014 14:25
Atom crash report
Process: Atom Helper [76665]
Path: /Applications/Atom.app/Contents/Frameworks/Atom Helper.app/Contents/MacOS/Atom Helper
Identifier: com.github.atom.helper
Version: 0.146.0 (0.146.0)
Code Type: X86-64 (Native)
Parent Process: Atom [73996]
Responsible: Atom [73996]
User ID: 501
Date/Time: 2014-11-13 17:06:29.571 -0500