Skip to content

Instantly share code, notes, and snippets.

@William-Yeh
William-Yeh / load_routes.js
Last active August 29, 2015 13:58
load all Node.js (including Express) route definitions
/**
* load all Node.js (including Express) route definitions.
* in most cases you should only need to modify the app_routes[] array.
*
* inspired by the article:
* - http://stackoverflow.com/questions/5778245/expressjs-how-to-structure-an-application
*
* @author William Yeh <william.pjyeh@gmail.com>
* @date 2014-04-09
* @license MIT
@William-Yeh
William-Yeh / enable-mongodb-balancer.sh
Created April 15, 2014 09:48
Simple tool to enable MongoDB balancer.
#!/bin/bash
MONGODB_NAME=$1
MONGODB_PASS=$2
MONGODB_HOST=$3
MONGODB_PORT=${4:-27017}
if [ $# -lt 3 ]; then
echo "Simple tool to enable MongoDB balancer."
echo "Usage: enable-mongodb-balancer.sh username password host [port]"
@William-Yeh
William-Yeh / disable-mongodb-balancer.sh
Created April 15, 2014 09:49
Simple tool to disable MongoDB balancer.
#!/bin/bash
MONGODB_NAME=$1
MONGODB_PASS=$2
MONGODB_HOST=$3
MONGODB_PORT=${4:-27017}
if [ $# -lt 3 ]; then
echo "Simple tool to disable MongoDB balancer."
echo "Usage: disable-mongodb-balancer.sh username password host [port]"
@William-Yeh
William-Yeh / lock-mongodb.sh
Created April 16, 2014 04:34
Simple tool to db.fsyncLock() on MongoDB.
#!/bin/bash
MONGODB_NAME=$1
MONGODB_PASS=$2
MONGODB_HOST=$3
MONGODB_PORT=${4:-27017}
if [ $# -lt 3 ]; then
echo "Simple tool to db.fsyncLock() on MongoDB."
echo "Usage: lock-mongodb.sh username password host [port]"
@William-Yeh
William-Yeh / unlock-mongodb.sh
Created April 16, 2014 04:34
Simple tool to db.fsyncUnlock() on MongoDB.
#!/bin/bash
MONGODB_NAME=$1
MONGODB_PASS=$2
MONGODB_HOST=$3
MONGODB_PORT=${4:-27017}
if [ $# -lt 3 ]; then
echo "Simple tool to db.fsyncUnlock() on MongoDB."
echo "Usage: unlock-mongodb.sh username password host [port]"
@William-Yeh
William-Yeh / dig-gce-ip-ranges.pl
Created May 22, 2014 08:02
A simple tool to query the IP ranges for GCE zones
#!/usr/bin/env perl
=pod
SUMMARY: A simple tool to query the IP ranges for GCE zones.
REFERENCE: http://stackoverflow.com/a/19434481
LICENSE: released to public domain.
AUTHOR: William Yeh <william.pjyeh@gmail.com>
@William-Yeh
William-Yeh / Vagrantfile-coreos-docker
Created June 5, 2014 05:02
Vagrantfile template for CoreOS + selected Docker image
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
#
# provision script; pull Docker image
#
docker_image = "busybox"
$script = <<SCRIPT
@William-Yeh
William-Yeh / mmseg-units.dic
Last active August 29, 2015 14:05
fix some errors of 'units.dic' file in common mmseg packages
#
# fix some errors of 'units.dic' file in common mmseg packages
#
# URL: https://gist.github.com/William-Yeh/95f7dd1a60242f7d5b62
#
# @ref https://github.com/kuan-ming/concise-core/blob/master/src/org/sustudio/concise/core/mmseg/dictionary/units.dic
# @ref https://github.com/medcl/elasticsearch-rtf/blob/master/config/mmseg/units.dic
#
#----------
#
@William-Yeh
William-Yeh / head2tail.sh
Created September 16, 2014 04:38
Extract a range of lines from stdin and print to stdout.
#!/bin/bash
#
# Extract a range of lines from stdin and print to stdout.
#
# Usage:
#
# head2tail.sh starting-line [number-of-lines]
#
# Example:
#
@William-Yeh
William-Yeh / Build.scala
Last active August 29, 2015 14:08
modified spray-can example from https://github.com/spray/spray
import sbt._
import Keys._
import com.typesafe.sbt.osgi.SbtOsgi._
import sbtunidoc.Plugin._
import UnidocKeys._
import sbtassembly.Plugin._
import AssemblyKeys._
object Build extends Build {