Skip to content

Instantly share code, notes, and snippets.

View brianng's full-sized avatar

Brian Ng brianng

  • Hawai'i
  • 00:16 (UTC -10:00)
View GitHub Profile
@brianng
brianng / pre-commit
Created August 1, 2014 17:28
Simple git pre-commit hook to detect console.log statements
#!/bin/sh
git diff --cached | grep --quiet "^+.*console\.log"
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo "Error: detected console.log statement"
exit 1
fi
@brianng
brianng / gist:2000342
Created March 8, 2012 10:40
Minimal Vimeo Javascript API example
/*
* Play an embedded video and trigger a callback when finished playing (using jQuery).
*
* Vimeo JavaScript library
* http://vimeo.com/api/docs/player-js
* https://github.com/vimeo/player-api/tree/master/javascript
*/
var vimeo = $f('vimeo'); // id of iframe or iframe element
@brianng
brianng / opentok-harness.html
Created January 24, 2012 01:20
OpenTok harness
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="http://staging.tokbox.com/v0.91/js/TB.min.js"></script>
<script type="text/javascript">
function log(message) {
console.log(message);
$("#console").append("<p>" + message + "</p>");
}
@brianng
brianng / nginx
Created May 15, 2011 05:43
/etc/init.d/nginx
#!/bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
@brianng
brianng / Jetblack.xml
Created April 26, 2010 23:21
Jetblack theme for RubyMine (Library/Preferences/RubyMine25/colors/Jetblack.xml)
<?xml version="1.0" encoding="UTF-8"?>
<scheme name="Jetblack" version="1" parent_scheme="Default">
<option name="LINE_SPACING" value="1.1" />
<option name="EDITOR_FONT_SIZE" value="12" />
<option name="EDITOR_FONT_NAME" value="Monaco" />
<colors>
<option name="ADDED_LINES_COLOR" value="808080" />
<option name="ANNOTATIONS_COLOR" value="" />
<option name="ANNOTATIONS_MERGED_COLOR" value="" />
<option name="CARET_COLOR" value="" />
@brianng
brianng / .bash_aliases
Created April 9, 2010 16:33
bash aliases for Git
alias g='git'
alias gcd='git checkout dev'
alias gcm='git checkout master'
alias gd='git diff'
alias gmd='git merge dev'
alias gp='git push'
alias grm='git rebase master'
alias gsl='git stash list'
alias gsp='git stash pop'
alias gss='git stash save'
@brianng
brianng / Autowire view-specific Javascript (Erector)
Created December 4, 2009 00:38
Autowire view-specific Javascript (Erector)
class Views::Layouts::Application < Erector::Widgets::Page
# Include view-specific "onready" Javascript, if present
def head_content
super()
javascript_filename = "#{self.class.model_name.singular[/^views_(.+)/,1].gsub(/_/, '.')}.onready.js"
if File.exist? "#{ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR}/#{javascript_filename}"
javascript_include_tag javascript_filename
end
end