Skip to content

Instantly share code, notes, and snippets.

View locnguyen's full-sized avatar

Loc Nguyen locnguyen

  • Southern California
  • 11:55 (UTC -07:00)
View GitHub Profile
@locnguyen
locnguyen / gist:7998611
Last active December 31, 2015 14:09
This is how I enable CORS in a Rails 4 application. The app is a JSON API consumed by an AngularJS front-end. Still a work in progress...
# Add a preflight check method and a set headers methond in ApplicationController
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :null_session
before_filter :set_cors_headers
before_filter :cors_preflight_check
@locnguyen
locnguyen / gitSearchMessages.js
Last active February 1, 2018 05:15
Search release branches by git commit messaage
const childProcess = require('child_process');
const { exec } = childProcess;
exec(`git log --oneline --all --grep "${process.argv[2]}"`, (err, stdout, stderr) => {
if (err) {
console.error(err);
return;
}
const logResults = stdout.split('\n').filter(out => out.length).map(out => ({
sha: out.slice(0, 8),