Skip to content

Instantly share code, notes, and snippets.


Michael kagemusha

View GitHub Profile
kagemusha / gist:5708254
Created Jun 4, 2013
Postgres Selects with Booleans
View gist:5708254
v: 9.1.4
if have table users:
id is_admin
-- --------
1 t
2 f
View Emberisms
Say you have a model set with many items. In Ember:
set.items[0] #incorrect
View gist:5010598
Error: Failed to load unit/
- could be one of the require statements file name incorrect
kagemusha / gist:5008458
Last active Dec 14, 2015
Ember Troubleshooting
View gist:5008458
Uncaught Error: assertion failed: Cannot call get with 'id' on an undefined object. (em1.0.rc1)
- make sure link is properly defined
e.g. {{#linkTo item}} will cause problems: should be {{#linkTo item item}}
Uncaught TypeError: Object <(generated set controller):ember417> has no method 'addArrayObserver' (em1.0.rc1)
- can happen when controller is Em.ArrayController but should be Em.ObjectController (perhaps no array defined)
kagemusha / gist:4090276
Created Nov 16, 2012
mongodump mongorestore - base case
View gist:4090276
mongorestore --collection people --db accounts dump/accounts/
Say you want to transfer your local mongo dbs to another machine. One way using dump and restore is:
1. run mongodump on old machine
- this will put all your mongo dbs in a directory called dump in the current dir
- for instance if you have one db called mydb, will have a dir dumb/mydb with your data
kagemusha / gist:4068935
Created Nov 13, 2012
Override Devise Controllers
View gist:4068935
c. Devise 2.1.2
E.g. you may want to send back json instead of html on login, etc.
1. Override the controller (put in the controllers dir)
class SessionsController < Devise::SessionsController
kagemusha / gist:4021842
Created Nov 6, 2012
active_model_serializers installed but render :json not using them
View gist:4021842
c. 0.5.2
Make sure not doing .to_json
This will not work!!!
render :json=>songs.to_json
This works:
render :json=>songs
kagemusha / gist:3859986
Created Oct 9, 2012
Get touch position on jquery mobile
View gist:3859986
c. jqm 1.2
$(document).on "tap", someSelector, (event) ->
log "evX", event.clientX
log "evY", event.clientY
seems to work with tap, vmouse, etc.
kagemusha / gist:3550371
Created Aug 31, 2012
Jquery $(someField).val(val) - DO NOT USE
View gist:3550371
c. JQuery 1.8
for some reason this only works about half the time. rather than waste time on mindless and costly debugging instead always use:
$(someField).attr "value", val
kagemusha / gist:3215681
Created Jul 31, 2012
UMongo "com.mongodb.MongoException: can't find a master" when try to connect
View gist:3215681
c. UMongo 1.2.1
In the server text field, change 'localhost' to '' and it should work
You can’t perform that action at this time.