Skip to content

Instantly share code, notes, and snippets.

View zhenghao1's full-sized avatar

Mark Huang zhenghao1

View GitHub Profile
" Git rebase helper for:
" git rebase --interactive
"
" L - view commit log
" p - pick
" e - edit
" s - squash
" r - reword
" D - delete
"
@jehiah
jehiah / simple_args_parsing.sh
Created March 4, 2011 16:56
a simple way to parse shell script arguments
#!/bin/sh
#
# a simple way to parse shell script arguments
#
# please edit and use to your hearts content
#
ENVIRONMENT="dev"
@benvanstaveren
benvanstaveren / DisqusBridge.pl
Created April 22, 2011 01:05
A little example for using Mojolicious::Lite, Mojolicious::Plugin::Disqus and Net::Disqus
#!/usr/bin/env perl
use Mojolicious::Lite;
use Try::Tiny;
plugin 'disqus', { 'api_secret' => 'getyourownsecretplease', pass_api_errors => 1 };
# This, of course, is total and utter overkill for something like this,
# but I figured if I'm going to write demonstration code, might as well
# go the whole hog.
plugin 'mongodb', { 'database' => 'disqusbridge' };
@db
db / jquery.ajax.progress.js
Created May 11, 2011 12:43
add XHR2 progress events to jQuery.ajax
(function addXhrProgressEvent($) {
var originalXhr = $.ajaxSettings.xhr;
$.ajaxSetup({
progress: function() { console.log("standard progress callback"); },
xhr: function() {
var req = originalXhr(), that = this;
if (req) {
if (typeof req.addEventListener == "function") {
req.addEventListener("progress", function(evt) {
that.progress(evt);
@fwielstra
fwielstra / api.js
Created June 14, 2011 14:46
An example NodeJS / Mongoose / Express application based on their respective tutorials
/* The API controller
Exports 3 methods:
* post - Creates a new thread
* list - Returns a list of threads
* show - Displays a thread and its posts
*/
var Thread = require('../models/thread.js');
var Post = require('../models/post.js');
@necolas
necolas / README.md
Last active March 28, 2024 20:34
Experimenting with component-based HTML/CSS naming and patterns

NOTE I now use the conventions detailed in the SUIT framework

Template Components

Used to provide structural templates.

Pattern

t-template-name
@chalmerj
chalmerj / gist:1492154
Created December 18, 2011 02:26
Init Script for Graphite/Gunicorn
#! /bin/sh
### BEGIN INIT INFO
# Provides: gunicorn-graphite
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Should-Start: $nginx
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: gunicorn + nginx ubuntu init script
# Description: gunicorn + nginx ubuntu init script

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@nobuf
nobuf / gist:3419910
Created August 21, 2012 22:15
Supporting placeholder on IE9 with AngularJS + jQuery
angular.module('test', [])
.directive('placeholder', function($timeout){
if (!$.browser.msie || $.browser.version >= 10) {
return {};
}
return {
link: function(scope, elm, attrs){
if (attrs.type === 'password') {
return;
}
@Mithrandir0x
Mithrandir0x / gist:3639232
Created September 5, 2012 16:15
Difference between Service, Factory and Provider in AngularJS
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"