Skip to content

Instantly share code, notes, and snippets.

View leepfrog's full-sized avatar

Andy Tran leepfrog

View GitHub Profile
test('selections should be populated as checkboxes are marked', function() {
expect(4);
var selections = Em.A();
var testData = {
models: Em.A([
Em.Object.create({ id: 1, name: "Foo", desc: "Hey"}),
Em.Object.create({ id: 2, name: "Bar", desc: "World"}),
]),
value: selections
class CsrfController < ApplicationController
def index
render json: { request_forgery_protection_token => form_authenticity_token }.to_json
end
end
NSURL *url = [NSURL URLWithString:@"file:////path_to_my.mp4"];
AVPlayer *player = [AVPlayer playerWithURL:url];
AVPlayerLayer *layer = [AVPlayerLayer playerLayerWithPlayer:player];
[[self.playerView layer] insertSublayer:layer atIndex:0];
[player play];
2013-08-28 22:19:58.119 JAMR[4798:70b] *** Assertion failure in -[NSLayoutConstraint _setSymbolicConstant:constant:], /SourceCache/Foundation_Sim/Foundation-1047.18.1/Layout.subproj/NSLayoutConstraint.m:545
2013-08-28 22:19:58.307 JAMR[4798:70b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Constant is not finite! That's illegal. constant:nan'
*** First throw call stack:
(
0 CoreFoundation 0x033596f4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x027de8b6 objc_exception_throw + 44
2 CoreFoundation 0x03359558 +[NSException raise:format:arguments:] + 136
3 Foundation 0x021b25ee -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
4 Foundation 0x0220ac49 -[NSLayoutConstraint _setSymbolicConstant:constant:] + 170
5 Foundation 0x0220d671 -[NSLayoutConstraint setConstant:] + 52
@leepfrog
leepfrog / gist:5718581
Created June 6, 2013 00:59
1. Slap this code into a file 2. Run this file, pass in a list of .coffee files that you have read/write access to 3. Profit? (all of your single line comments will be converted to block comments)
#!/usr/bin/env ruby
# Take in a file
# Read each line
# if it contains a single #, then do a regexp replace to make it ### <text> ###
#
# Each file
ARGV.each do |file_name|
# Open the file read only so we can grab it's contents
@leepfrog
leepfrog / gist:5588650
Created May 16, 2013 00:57
Google maps stuff
$(document).ready ->
if $("#contact-head").length
mochaleaf = new google.maps.LatLng(37.777901,-122.411996)
image = '/assets/ml.map.png'
mochaStyles = [
featureType: "administrative"
elementType: "geometry"
@leepfrog
leepfrog / gist:5359583
Created April 11, 2013 00:12
CacheAdapter WIP
# Aliases
get = Ember.get
App.CacheAdapter = DS.Adapter.extend
# This defines our local storage adapter where we'll hold our cache stuff
localAdapterKlass: 'App.IDBAdapter'
# This defines our network storage adapter where we'll fetch/push/etc.. updates
networkAdapterKlass: 'DS.RESTAdapter'
@leepfrog
leepfrog / gist:5352059
Created April 10, 2013 05:31
Current WIP of IndexedDB Adapter
# Aliases
get = Ember.get
indexedDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB || window.msIndexedDB
# Indexed DB Adapter
App.IDBAdapter = DS.Adapter.extend
# Name of the database store we're going to use
dbName: 'myCoolDB'
# Version of the schema
@leepfrog
leepfrog / gist:5307321
Last active December 15, 2015 18:58
IndexDB Notes / sample code
indexdb notes
dbName = 'someName'
# obtain non-vendored versions of these
# Vars used to open / work with our db instance
window.db = null
request = indexedDB.open(dbName)
it.only 'should recalculate when adding an element to the array with pushObject', ->
pipeline.get('results.length').should.equal(10)
newBook = Book.create( title: 'yolofolomolo' )
pipeline.get('content').pushObject(newBook)
pipeline.get('results.length').should.equal(11)
pipeline.get('results.lastObject').should.equal(newBook)