Skip to content

Instantly share code, notes, and snippets.

@superlou
superlou / accountInfo.json
Last active January 1, 2016 04:19
Resolving into ember from jQuery
{
"referral_link":"https://db.tt/2iEFmHsw",
"display_name":"Louis Simons",
"uid":23040725,
"country":"US",
"quota_info":{
"datastores":0,
"shared":31745173,
"quota":5100273664,
"normal":438654772
@superlou
superlou / SessionController.js
Last active January 1, 2016 03:38
Inject currentUser
OurMemories.SessionController = Ember.Object.extend({
currentUser: null,
init: function() {
currentUserMeta = $('meta[name=current_user]').attr('content');
currentUserId = $.parseJSON(currentUserMeta).id;
currentUser = this.store.find('user', currentUserId);
this.set('currentUser', currentUser);
}
});
@superlou
superlou / dumb-store.coffee
Last active December 30, 2015 17:29
Really simple local store
DumbStore = Backbone.Model.extend
defaults: -> {
pile: []
}
add: (obj)->
this.get('pile')[obj.id] = obj
find: (id)->
this.get('pile')[id]
@superlou
superlou / GruntFile.coffee
Created December 2, 2013 01:06
Launch server and watch for file changes
module.exports = (grunt)->
grunt.initConfig
pkg: grunt.file.readJSON('package.json')
coffee:
compile:
options:
join: true
files:
'client/build/main.js': [
'common/src/utils.coffee'
@superlou
superlou / JSON Response
Created October 20, 2013 17:51
Missing belongsTo relationship
{"checkouts":[{"id":223,"status":"out","created_at":"2013-10-20T17:05:15Z","closed_at":null,"book_id":25748,"patron_id":1149},{"id":224,"status":"out","created_at":"2013-10-20T17:05:15Z","closed_at":null,"book_id":25798,"patron_id":1179},{"id":225,"status":"out","created_at":"2013-10-20T17:05:15Z","closed_at":null,"book_id":25725,"patron_id":1150},{"id":226,"status":"out","created_at":"2013-10-20T17:05:15Z","closed_at":null,"book_id":25735,"patron_id":1208},{"id":227,"status":"out","created_at":"2013-10-20T17:05:15Z","closed_at":null,"book_id":25789,"patron_id":1135},{"id":228,"status":"out","created_at":"2013-10-20T17:05:15Z","closed_at":null,"book_id":25753,"patron_id":1138},{"id":229,"status":"out","created_at":"2013-10-20T17:05:16Z","closed_at":null,"book_id":25788,"patron_id":1197},{"id":230,"status":"out","created_at":"2013-10-20T17:05:16Z","closed_at":null,"book_id":25814,"patron_id":1154},{"id":231,"status":"out","created_at":"2013-10-20T17:05:16Z","closed_at":null,"book_id":25802,"patron_id":1185},{"
@superlou
superlou / writer.py
Created October 15, 2013 12:37
Doxygen to .docx via python-docx
from lxml import etree as ET
import python_docx.docx as docx # requires LXML and PIL
def is_boring(text):
phrases = [
"data set forth herein",
"this file was created by texas instruments",
"ti checkin date",
"contents:"
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://AutodeskDM/Services/ItemService/1/20/2011/" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" name="ItemService" targetNamespace="http://AutodeskDM/Services/ItemService/1/20/2011/">
<wsdl:types>
<xs:schema xmlns:xs="
@superlou
superlou / book.js.coffee
Last active December 22, 2015 12:18
Getting attributes before they're resolved
attr = Ember.attr
hasMany = Ember.hasMany
Library.Book = Ember.Model.extend
id: attr(Number)
code: attr()
volume: attr()
stock: attr(Number)
title: attr()
adult: attr()
Library.Router.map ()->
@resource 'books', ->
@route 'new'
@resource 'books.book', {path: ':book_id'}
@route 'edit', {path: ':book_id/edit'}
@superlou
superlou / Params
Created August 23, 2013 00:13
Unpermitted parameters: book, patron
{"id"=>nil, "status"=>"out", "closed_at"=>nil, "created_at"=>nil, "book"=>{"id"=>1, "code"=>"123", "volume"=>2, "stock"=>1, "title"=>"A Road Ago", "adult"=>true, "notes"=>nil, "checkout_ids"=>[22]}, "patron"=>{"id"=>1, "code"=>"1", "name"=>"Chen Kenichi", "gender"=>nil, "email"=>nil}, "checkout"=>{"book"=>{"id"=>1, "code"=>"123", "volume"=>2, "stock"=>1, "title"=>"A Road Ago", "adult"=>true, "notes"=>nil, "checkout_ids"=>[22]}, "patron"=>{"id"=>1, "code"=>"1", "name"=>"Chen Kenichi", "gender"=>nil, "email"=>nil}, "status"=>"out", "closed_at"=>nil, "created_at"=>nil}}