Skip to content

Instantly share code, notes, and snippets.

View khanghoang's full-sized avatar
😬

Khang Hoang khanghoang

😬
  • Dropbox
  • San Jose, CA
  • 22:48 (UTC -06:00)
  • X @khanght
View GitHub Profile
@khanghoang
khanghoang / Account.js
Last active August 29, 2015 14:10 — forked from anhnt/Account.js
// api/models/Account.js
module.exports = {
attributes: {
acct_id: {
type: 'int',
primaryKey: true
},
loginName: {
type: 'string',
@khanghoang
khanghoang / Get _sails variable in policy
Created December 6, 2014 19:12
Get _sails variable in policy
module.exports = function forbidden (data, options) {
var req = this.req;
var res = this.res;
var sails = req._sails;
}
@khanghoang
khanghoang / .vimrc
Created February 28, 2015 14:12
Remove the '<template> is not recognized!' with YADR https://github.com/skwp/dotfiles
" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
" TODO: this may not be in the correct place. It is intended to allow overriding <Leader>.
" source ~/.vimrc.before if it exists.
if filereadable(expand("~/.vimrc.before"))
source ~/.vimrc.before
endif
@khanghoang
khanghoang / polo.startup.meteor.plist
Created March 3, 2015 17:54
POLO launchd script to run meteor server at startup
# /Library/LaunchDaemon
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<false/>
<key>EnvironmentVariables</key>
<dict>
<key>HOME</key>
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l
"Quick Esc
imap jj <Esc>
imap jk <Esc>
imap Jj <Esc>
imap jK <Esc>

Auto-deploying built products to gh-pages with Travis

This is a set up for projects which want to check in only their source files, but have their gh-pages branch automatically updated with some compiled output every time they push.

Create a compile script

You want a script that does a local compile to e.g. an out/ directory. Let's call this compile.sh for our purposes, but for your project it might be npm build or gulp make-docs or anything similar.

The out/ directory should contain everything you want deployed to gh-pages. That almost always includes an index.html.

#import "FacebookLoginManager.h"
#import "FBSDKCoreKit/FBSDKCoreKit.h"
#import "FBSDKLoginKit/FBSDKLoginKit.h"
@implementation FacebookLoginManager
- (void)newSession:(RCTResponseSenderBlock)callback {
RCT_EXPORT();
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
@khanghoang
khanghoang / SampleListView-Page.js
Created April 1, 2015 16:04
React Native - animation when new cell is visible (in the UIExplorer example)
componentDidMount: function() {
console.info(this.props.rowData)
var rowIndex = parseInt(this.props.rowData.slice(-1));
setTimeout(() => {
LayoutAnimation.configureNext(animations.layout.easeInEaseOut);
this.setState({y: 0})
},1000 + 100*rowIndex);
},
@khanghoang
khanghoang / flightplan-deploy.md
Last active August 29, 2015 14:27 — forked from learncodeacademy/flightplan-deploy.md
Deploy Node.js Apps with Flightplan

##Setup your server (this would ideally be done with automated provisioning)

  • add a deploy user with password-less ssh see this gist
  • install forever npm install -g forever

##Install flightplan

  • npm install -g flightplan
  • in your project folder npm install flightplan --save-dev
  • create a flightplan.js file
@khanghoang
khanghoang / node-deploy-as-upstart-service.md
Last active August 29, 2015 14:27 — forked from learncodeacademy/node-deploy-as-upstart-service.md
Deploy Node.js app on Ubuntu as Upstart Service - instead of using Forever

Deploying a node app with Forever is great...until your server restarts unexpectedly. Then your app stops running and you have to re-deploy.

To get around this, we're going to run our node app as an Upstart service. Upstart services are great, because, once started, the system auto-restarts them if they fail, or if the server restarts.

###Step 1: Create a service for your node app

  • ssh in as root ssh root@youripaddress
  • Create a node-app.conf file in /etc/init
    IMPORTANT: whatever filename you pick is what you will use to start|stop|restart your service i.e. service node-app start