Skip to content

Instantly share code, notes, and snippets.

View shunchu's full-sized avatar

Shun Chu shunchu

View GitHub Profile
@shunchu
shunchu / dotfile-zshrc
Last active December 22, 2017 21:24
dotfile zshrc
source ~/.aliases
source ~/.exports
source /usr/local/share/chruby/chruby.sh
source /usr/local/share/chruby/auto.sh
# load zgen
ZGEN_PREZTO_LOAD_DEFAULT=0
source "${HOME}/.zgen/zgen.zsh"
# if the init scipt doesn't exist
@shunchu
shunchu / macos-10.12-brewfile
Last active March 2, 2018 00:35
macos 10.12 brewfile
tap "caskroom/cask"
tap "caskroom/drivers"
tap "caskroom/fonts"
tap "homebrew/bundle"
tap "homebrew/core"
tap "homebrew/science"
tap "homebrew/services"
brew "ack"
brew "readline"
brew "autoconf"
@shunchu
shunchu / components.my-component.js
Last active December 15, 2016 18:06
New Twiddle
import Ember from 'ember';
import { task, timeout } from 'ember-concurrency';
const { inject: { service } } = Ember;
export default Ember.Component.extend({
ajax: service(),
result: null,
queryTask: task(function* (term) {
yield timeout(600);
@shunchu
shunchu / .ruby-version
Last active August 6, 2017 15:01
chruby hack for chefdk
chefdk
@shunchu
shunchu / display-ember-promise-errors.js
Last active August 4, 2017 03:26
display ember promise errors
// source: https://ianpetzer.wordpress.com/2013/07/24/dont-let-ember-js-swallow-errors-in-your-promises/
Ember.RSVP.configure('onerror', function(e) {
console.log(e.message);
console.log(e.stack);
});
@shunchu
shunchu / add associated object ids in activerecord.rb
Last active August 29, 2015 14:08
add associated object's IDs as arrays for each record in collection
# add associated object's IDs as arrays for each record in collection
Organization.joins(:users)
.select("organizations.*, '#{User.joins(:organization).pluck(:id)}' as user_ids")
.group('organizations.id')
# => { organizations: [{ id: 1, name: 'some name',... user_ids:[1,2,3] }] }
@shunchu
shunchu / add-attrs-to-jbuilder-collections
Created October 23, 2014 20:13
Add attributes to JBuilder collections
# this adds an additional `user_ids` array to each of the `organizations` collection
json.organizations do |json|
json.array! @organizations do |org|
json.merge! org.attributes
json.user_ids org.users.pluck(:id)
end
end
@shunchu
shunchu / .vimrc
Created September 2, 2014 01:18
.vimrc
" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
runtime autoload/pathogen.vim
call pathogen#infect()
call pathogen#helptags()
" EDITOR SETTINGS ========================================================
" ========================================================================
@shunchu
shunchu / go-to-git-branch-in-bitbucket-repo.sh
Created August 21, 2014 22:29
Go to git branch in Bitbucket repo
# copy/paste into ~/.bash_profile and invoke it by typing "bb" in commandline
# Opens the bitbucket page for the current git repo/branch in your browser
function bb() {
giturl=$(git config --get remote.origin.url)
if [ "$giturl" == "" ]
then
echo "Not a git repository or no remote.origin.url set"
exit 1;
@shunchu
shunchu / go-to-git-branch-on-github-repo.sh
Last active August 29, 2015 14:05
Go to git branch on Github repo
# copy/paste in ~/.bash_profile and invoke it by typing "gh" in commandline
# Opens the github page for the current git repo/branch in your browser
function gh() {
giturl=$(git config --get remote.origin.url)
if [ "$giturl" == "" ]
then
echo "Not a git repository or no remote.origin.url set"
exit 1;