Skip to content

Instantly share code, notes, and snippets.

View kagemusha's full-sized avatar

Michael kagemusha

View GitHub Profile
@kagemusha
kagemusha / gist:5708254
Created June 4, 2013 18:25
Postgres Selects with Booleans
v: 9.1.4
if have table users:
id is_admin
-- --------
1 t
2 f
3
Say you have a model set with many items. In Ember:
set.items[0] #incorrect
=>
set.get("items").objectAt(0)
@kagemusha
kagemusha / gist:5010598
Created February 22, 2013 03:57
Konacha Errors
Error: Failed to load unit/state_managers_spec.js.coffee
- could be one of the require statements file name incorrect
@kagemusha
kagemusha / gist:5008458
Last active December 14, 2015 01:48
Ember Troubleshooting
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
kagemusha / gist:4090276
Created November 16, 2012 19:46
mongodump mongorestore - base case
Ref:
http://docs.mongodb.org/manual/reference/mongodump/
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
kagemusha / gist:4068935
Created November 13, 2012 22:42
Override Devise Controllers
c. Devise 2.1.2
ref: https://github.com/plataformatec/devise/issues/1561
E.g. you may want to send back json instead of html on login, etc.
Steps:
1. Override the controller (put in the controllers dir)
class SessionsController < Devise::SessionsController
@kagemusha
kagemusha / gist:4021842
Created November 6, 2012 01:23
active_model_serializers installed but render :json not using them
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
kagemusha / gist:3859986
Created October 9, 2012 16:48
Get touch position on jquery mobile
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
kagemusha / gist:3550371
Created August 31, 2012 08:43
Jquery $(someField).val(val) - DO NOT USE
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
kagemusha / gist:3215681
Created July 31, 2012 09:57
UMongo "com.mongodb.MongoException: can't find a master" when try to connect
c. UMongo 1.2.1
In the server text field, change 'localhost' to '127.0.0.1' and it should work