Skip to content

Instantly share code, notes, and snippets.

@jdjkelly
jdjkelly / gist:5279130
Last active December 15, 2015 15:09
Four attrs on a model problem
# Given a model, self, with these attributes:
# value :float
# lean_mass_value :float
# fat_mass_value :float
# fat_percentage :float
#
# User optionally inputs the last three (lean_mass, fat_mass, fat_percentage), so we can determine missing values if we have at least one of the last three in addition to the value attr.
# Is there a better way to express this?
def calculate_all_known_values
function URI(e) {
e || (e = "");
var t = /^(?:([^:\/?\#]+):)?(?:\/\/([^\/?\#]*))?([^?\#]*)(?:\?([^\#]*))?(?:\#(.*))?/,
n = e.match(t);
this.scheme = n[1] || null, this.authority = n[2] || null, this.path = n[3] || null, this.query = n[4] || null, this.fragment = n[5] || null
}(function () {
Stripe.setPublishableKey(PRELOAD.stripe_settings.public_key)
}).call(this), PRELOAD.intercom_settings && (window.intercomSettings = PRELOAD.intercom_settings, $.extend(window.intercomSettings, {
widget: {
activator: "#intercom",
$.ajaxSetup
xhrFields:
withCredentials: true
$(document).ajaxSend (event, jqxhr, settings)->
jqxhr.setRequestHeader 'X-CSRF-Token', Embed.get 'csrf-token'
jqxhr.withCredentials = true # so the browser appends session headers in CORS requests
$(document).ajaxComplete (event, jqxhr, settings)->
if jqxhr.getResponseHeader('X-CSRF-Token')?
@jdjkelly
jdjkelly / gist:6090079
Created July 26, 2013 16:05
191962531eb67bdd66847a68544238ce69073838: ember.js vs ember.prod.js
--- /Users/sycr/code/embertest/dist/ember.js Fri Jul 26 12:00:26 2013
+++ /Users/sycr/code/embertest/dist/ember.prod.js Fri Jul 26 12:00:26 2013
@@ -1,160 +1,3 @@
-// Version: v1.0.0-rc.3.1
-// Last commit: 1919625 (2013-07-25 18:13:08 -0400)
-
-
-(function() {
-/*global __fail__*/
-
var sortedCoupons = []
var coupons = Object.keys(Store.Menu.Coupons)
coupons.forEach(function(coupon, index, coupons) {
data = Store.Menu.Coupons[coupon]
sortedCoupons.push(data)
})
sortedCoupons.sort(function (a, b) {
task :scrape_blog_to => :environment do
blog_to = "http://www.blogto.com"
lists = ["/toronto/the_best_antique_stores_in_toronto/", "/toronto/the_best_art_supply_stores_in_toronto/", "/toronto/the_best_new_art_galleries_in_toronto_2008/", "/toronto/the_best_new_art_galleries_in_toronto_2009/", "/toronto/best_place_to_buy_a_suit_in_toronto/", "/toronto/the_best_baby_stores_in_toronto/", "/toronto/the_best_backyard_patios_in_toronto/", "/toronto/the_best_barber_shops_in_toronto/", "/toronto/the_best_bespoke_tailors_in_toronto/", "/toronto/the_best_bike_repair_shops_in_toronto/", "/toronto/the_best_bike_stores_in_toronto/", "/toronto/the_best_blues_bars_in_toronto/", "/toronto/the_best_bookstores_in_toronto/", "/toronto/the_best_boxing_gym_in_toronto/", "/toronto/the_best_bridal_stores_in_toronto/", "/toronto/the_best_bridesmaid_dresses_in_toronto/", "/toronto/the_best_card_paper_and_stationery_shops_in_toronto/", "/toronto/the_best_catering_companies_in_toronto/", "/toronto/the_best_comic_shops_in_toronto/"
@jdjkelly
jdjkelly / gist:6525154
Created September 11, 2013 15:20
Ember Poem
Three Bugs from views with data bound from unknown places,
Seven from broken API calls and broken test suites,
Nine from the endless objects doomed to die by GC thrashing,
One from the Application Object and its initializer,
In the Land of Ember where the bugs lie,
One controller to rule them all, one controller to find the models,
One controller to bring them all and in a renderedBuffer bind them
In the Land of Ember where the bugs lie.
@jdjkelly
jdjkelly / gist:8838705
Created February 6, 2014 05:12
011314_challenge_148_easy_combination_lock
var input = [5, 1, 2, 3],
digit_count = input.shift()
digit_count * 4 + input[0] * 2 - input[1] * 2 + input[2]
@jdjkelly
jdjkelly / gist:9906676
Created April 1, 2014 02:40
Ember App Kit Initializer Example for Injecting Current User into Controllers
import Session from 'appkit/models/session';
export default Ember.Application.initializer({
name: 'currentUser',
initialize: function(container, app) {
// Register a new container
container.register('session:current-user', Session);
// Load the current user
container.lookup('session:current-user').find();
@jdjkelly
jdjkelly / gist:613d665aec1dcc3736bd
Created May 17, 2014 19:18
Active Ember.Select Issues and PRs
https://github.com/emberjs/ember.js/issues/2386
https://github.com/emberjs/ember.js/issues/2907
https://github.com/emberjs/ember.js/issues/3173
https://github.com/emberjs/ember.js/issues/3732
https://github.com/emberjs/ember.js/issues/4150
https://github.com/emberjs/ember.js/issues/4331
https://github.com/emberjs/ember.js/issues/4422
https://github.com/emberjs/ember.js/pull/2461
https://github.com/emberjs/ember.js/pull/4226