Skip to content

Instantly share code, notes, and snippets.

View kagemusha's full-sized avatar

Michael kagemusha

View GitHub Profile
kagemusha / go get with private github repo
Created June 13, 2018 16:28
go get with private github repo
1. If you are trying to `go get` a private repo, you need to be able to enter your `username` and `password` from the prompt.
To get the prompt you need to enable the git terminal prompt.
env GIT_TERMINAL_PROMPT=1 go get ''
2. Because of 2FA you cannot use your password. You need to generate an access token and enter that in the password field
instead (you will want to copy at the clipboard on the token generation page, b/c it will be long). To generate the token, go
to []( Or from the Github UI,
` Setting - Developer Settings - Personal access tokens`
kagemusha / gist:1569836
Created January 6, 2012 09:20
Dump Heroku Postgres DB and load locally
Get the Heroku db as detailed here:
1. heroku pgbackups:capture
2. heroku pgbackups:url <backup_num> #=>backup_url
- get backup_num with cmd "heroku pgbackups"
3. curl -o latest.dump <backup_url>
Then locally do:
$ pg_restore --verbose --clean --no-acl --no-owner -h localhost -U myuser -d mydb latest.dump
kagemusha / gist:1542498
Created December 31, 2011 02:14
Rails include related Model in JSON Response
Tested on: Rails 3.1
In this example, you want to return as json a group of Items and the name of the Company which makes them.
Models are as follows:
class Company < ActiveRecord::Base
has_many :items
class Item < ActiveRecord::Base
kagemusha / gist:5866759
Created June 26, 2013 11:37
Using Debugger with Grunt
version: grunt-cli v0.1.8
1. Install node-inspector globally (-g)
npm install -g node-inspector
2. Add debugger statements to your code
3. Run your grunt task in debug mode
kagemusha / gist:1660712
Created January 23, 2012 04:50
JQuery Datatables warning: Requested unknow parameter...
Versions: Datatables 1.8.x
If get error such as:
DataTables warning (table id = 'myTable'): Requested unknown parameter '2'
from the data source for row 0
Means num of columns in table heading and in data as specified in
aoColumns do not match. Making sure are same number should fix this.
kagemusha / gist:b7f57be9becb4a054d780d8c95af22bc
Last active November 10, 2018 19:00
sample osx/linux aliases
echo "redoing aliases"
# alias to reload aliases in your current window
alias real=". ~/kagemusha/aliases/aliases"
# specific things i'm currently working on
alias rspet="rspec spec/controllers/api/canvas/email_templates_controller_spec.rb"
alias rspes="rspec spec/controllers/api/canvas/email_sections_controller_spec.rb"
alias dlvw="dlv debug -- --workers 1 --models ./sample_models"
alias 58="lsof -i tcp:5858"
kagemusha / gist:2781562
Created May 24, 2012 13:31
TypeError: Cannot visit...(Rails)
Version: Rails 3.2.1
TypeError: Cannot visit Videoset
Happens when specify class for id in validations (perhaps other places), e.g.:
validates_uniqueness_of :song_num, :scope=>[:videoset]
validates_uniqueness_of :song_num, :scope=>[:videoset_id]
kagemusha / gist:b97db366ccec0fe11995c77755319295
Created June 19, 2018 17:08
Create postgres table with auto-incrementing primary key
// id SERIAL primary key
CREATE TABLE public.user_events
id serial primary key,
campaign_id bigint NOT NULL,
user_uuid bigint NOT NULL,
reward integer NOT NULL
kagemusha / gist:1504625
Created December 21, 2011 04:43
Invalidate Session when SessionRestoreError in Rails 3.x
Tested on: Rails 3.1
If have error:
ActionDispatch::Session::SessionRestoreError (Session contains objects whose class definition isn't available.
Remember to require the classes for all objects kept in the session.
can fix by changing a char in secret token in initializers/secret_token.rb
kagemusha / gist:1504633
Created December 21, 2011 04:47
Migrate from Mongo to Postgres in Rails 3.1
Tested on: Rails 3.1, Mongoid 2.0.1, pg 0.12.0 gem
Migrate from Mongo to PG
1. remove mongoid gem
2. add pg gem
3. in application.rb re-add ActiveRecord
4. for all models
- inherit from ActiveRecord::Base
- get rid of Mongoid:Document line
- make migrations and put fields there