Skip to content

Instantly share code, notes, and snippets.

Shun Chu shunchu

  • California
Block or report user

Report or block shunchu

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@shunchu
shunchu / dotfile-zshrc
Last active Dec 22, 2017
dotfile zshrc
View 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 Mar 2, 2018
macos 10.12 brewfile
View 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"
View components.my-component.js
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 Aug 6, 2017
chruby hack for chefdk
@shunchu
shunchu / display-ember-promise-errors.js
Last active Aug 4, 2017
display ember promise errors
View display-ember-promise-errors.js
// 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 Aug 29, 2015
add associated object's IDs as arrays for each record in collection
View add associated object ids in activerecord.rb
# 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 Oct 23, 2014
Add attributes to JBuilder collections
View add-attrs-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
View .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 Aug 21, 2014
Go to git branch in Bitbucket repo
View go-to-git-branch-in-bitbucket-repo.sh
# 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 Aug 29, 2015
Go to git branch on Github repo
View go-to-git-branch-on-github-repo.sh
# 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;
You can’t perform that action at this time.