Skip to content

Instantly share code, notes, and snippets.

@William-Yeh
William-Yeh / vagrant.py
Created October 24, 2015 13:17 — forked from majidaldo/vagrant.py
returns vagrant hosts for ansible inventory
#!/usr/bin/env python
# Adapted from Mark Mandel's implementation
# https://github.com/ansible/ansible/blob/devel/plugins/inventory/vagrant.py
import argparse
import json
import paramiko
import subprocess
import sys
@William-Yeh
William-Yeh / Dockerfile
Created May 19, 2015 08:06
nodejs + docker example for Alice Chuang
FROM node:0.10.36-slim
WORKDIR /opt
COPY . /opt
EXPOSE 8080
CMD [ "node", "hello.js" ]
@William-Yeh
William-Yeh / Vagrantfile
Last active August 29, 2015 14:16
Node.js mcrypt example in CentOS 6.6
Vagrant.configure(2) do |config|
config.vm.box = "chef/centos-6.6"
config.vm.provision "shell", inline: <<-SHELL
rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
yum -y install libmcrypt-devel nodejs npm
npm install mcrypt
# vagrant ssh ; cd /vagrant
# node example.js
SHELL
@William-Yeh
William-Yeh / DOCKER.pl
Last active August 29, 2015 14:13
Simple Docker CLI wrapper to "pull" public registry images from private registry.
#!/usr/bin/env perl
#
# Simple Docker CLI wrapper:
# - let "docker pull" to pull public registry images
# from private registry.
# - let other "docker" commands to act as before.
#
# Will use environment variable PRIVATE_DOCKER_REGISTRY
# to pull images.
#
@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 {
@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 / 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 / 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 / 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 / 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]"