Skip to content

Instantly share code, notes, and snippets.

@superlou
superlou / gist:4977824
Created February 18, 2013 14:30
Check the units of the pyplot specgram to determine if the output is in terms of the original unit or unit-squared.
"""
Check the units of the pyplot specgram to determine if the
output is in terms of the original unit or unit-squared.
"""
import numpy as np
import matplotlib.pyplot as plt
def find_nearest(array, value):
App.TagsController = Ember.ArrayController.extend {
filterOn: null
setFilterOn: (tagId)->
if this.get('filterOn') == tagId
this.set 'filterOn', null
else
this.set 'filterOn', tagId
console.log('in tagscontroller')
{{#linkTo task task}}
<div class="task-item">
{{task.name}}Test
{{#each task.tags}}
<span class='label pull-right'>{{name}}</span>
{{/each}}
</div>
{{/linkTo}}
App.TasksListController = Ember.ArrayController.extend {
needs: ['tasks']
contentBinding: 'controllers.tasks.filteredContent'
sortProperties: ['priority']
sortAscending: false
updatePrioritiesByOrder: (orderedTasks)->
orderedTasks.forEach( (item, index) ->
console.log item
)
<div class='update'>
<span class='created-at'>{{view.content.createdAt}}</span>
{{view Ember.TextArea valueBinding='view.content.details'}}
<a {{action deleteUpdate view.content}} href='#'>delete</button>
</div>
@superlou
superlou / test.py
Last active March 10, 2021 23:41
Rendering SVGs in wxPython
import wx
import rsvg
import numpy
try:
import wx.lib.wxcairo
import cairo
haveCairo = True
except ImportError:
haveCairo = False
@superlou
superlou / cario_test_2.py
Created July 9, 2013 13:06
Cairo Inkscape Rendering
import wx
import rsvg
import numpy
try:
import wx.lib.wxcairo
import cairo
haveCairo = True
except ImportError:
haveCairo = False
Library.BooksNewController = Ember.ObjectController.extend
save: (book)->
book.one 'didCreate', this, ->
@transitionToRoute('books.book', book)
console.log 'here'
@get('model').save()
LibraryAdapter = Ember.RESTAdapter.extend
didFind: (record, id, data)->
console.log 'here'
rootKey = get(record.constructor, 'rootKey')
dataToLoad = if rootKey then data[rootKey] else data
if /^code:/.test(id)
id = dataToLoad.id
record.load(id, dataToLoad)
@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}}