Skip to content

Instantly share code, notes, and snippets.

import Ember from 'ember';
export default Ember.Controller.extend({
needs: ['cart', 'cart-item'],
cartItemCount: Ember.computed.alias('controllers.cart-item.length')
});
`import DS from 'ember-data'`
ApplicationAdapter = DS.FixtureAdapter.extend()
`export default ApplicationAdapter`
# make sure to install blessings first (pip install blessings)
from blessings import Terminal
t = Terminal()
fg_colors = [t.color(i) for i in range(0, 15)]
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
(def playlist
[{:title "Elephant", :artist "The White Stripes", :year 2003}
{:title "Helioself", :artist "Papas Fritas", :year 1997}
{:title "Stories from the City, Stories from the Sea",
:artist "PJ Harvey", :year 2000}
{:title "Buildings and Grounds", :artist "Papas Fritas", :year 2000}
{:title "Zen Rodeo", :artist "Mardi Gras BB", :year 2002}])
; (group-by :artist playlist) returns:
(filter (comp (partial <= 25) :age) [{:age 21 :name "David"}
{:gender :f :name "Suzanne" :age 20}
{:name "Sara" :location "NYC" :age 34}])
@losingkeys
losingkeys / question-set.js
Created November 5, 2012 01:42
question set backbone.js model
// Generated by CoffeeScript 1.4.0
(function() {
var QuestionSet;
window.app || (window.app = {});
QuestionSet = Backbone.Model.extend({
defaults: {
operation: 'addition',
group: '0'
@losingkeys
losingkeys / question-set.coffee
Created November 5, 2012 01:25
Backbone model
window.app or= {}
QuestionSet = Backbone.Model.extend
defaults:
operation: 'addition'
group: '0'
currentOperand: null
questionsPerSet: 10
@losingkeys
losingkeys / ProblemView.coffee
Created November 4, 2012 22:16
Backbone.js view
window.app or= {}
ProblemView = Backbone.View.extend
el: '#problemContainer'
initilize: (operation='addition', group='0') ->
otherOperand = Math.floor Math.random()*10
# the result cannot be negative, order matters (put the larger number first)
if operation is 'subtraction'
@losingkeys
losingkeys / rfc
Created October 16, 2012 22:25
display an rfc with `less`
#!/bin/sh
# display an rfc in `less`
# NOTE: this script depends on the following 'rfc' package: http://www.archlinux.org/packages/community/any/rfc/
# install with `pacman -S rfc`
RFC_LOCATION="/usr/share/doc/rfc/txt/"
if [ $# -lt 1 ]; then