Skip to content

Instantly share code, notes, and snippets.

View iwat's full-sized avatar
:octocat:
Having fun

Chaiwat S iwat

:octocat:
Having fun
  • Vancouver, BC
View GitHub Profile
@iwat
iwat / docker-clean
Created June 22, 2016 02:54
Clean unused docker images and volumes.
#!/bin/sh
docker volume ls -f dangling=true -q | xargs docker volume rm
docker rmi $(docker images | grep "^<none>" | awk '{print $3}')
@iwat
iwat / profile
Last active September 7, 2016 15:20
Auto-mount non `/Users` directory on Docker Machine (docker/machine#1826)
# This Gist contains a snippet for auto-mounting non `/Users` or `/c/Users` directory on docker-machine with VirtualBox driver.
# 1. Add more shared folder on VirtualBox e.g., D:\Code -> /d/Code (and make it permanent)
# 2. Access Docker Machine SSH `docker-machine ssh`
# 3. Append the following code after original `/var/lib/boot2docker/profile` file. (as root/sudo)
# 4. `docker-machine restart`
# Note: Change the last line to match your shared folder
try_mount_share() {
dir="$1"
name="${2:-$dir}"
@iwat
iwat / composer.json
Last active August 29, 2015 14:27
Using Thrift with PHP and Composer
{
"autoload": {
"psr-0": {
"Thrift\\": "vendor/apache/thrift/lib/"
},
"classmap": ["gen-php"]
}
}
#!/bin/sh
if [ "$1" != "" ]; then
FILE=$1
REPO=$1_repo
else
exit 1
fi
if [ ! -d "$REPO" ]; then
@iwat
iwat / commit_docx.sh
Last active August 29, 2015 14:06
Commit formatted extracted docx into GIT.
#!/bin/sh
if [ "$1" != "" ] && [ "$2" != "" ]; then
FILE=$1
REPO=$1_repo
else
echo "$0 <docx file> <comment>"
exit 1
fi
@iwat
iwat / hungarian.php
Last active August 28, 2017 10:35
PHP Port of CAT_BAXTER's Python Hungarian Algorithm O(N^3). See: http://pastebin.com/tn6v0HDr
<?php
function hungarian($matrix)
{
$h = count($matrix);
$w = count($matrix[0]);
if ($h < $w)
{
for ($i = $h; $i < $w; ++$i)
{
@iwat
iwat / MoveTemporaryFoldersToRamdisk_MacOSX.sh
Created November 24, 2012 04:40 — forked from pklaus/AlwaysMountRootFSWithNoatime_MacOSX.sh
SSD Optimizations of Mac OS X 10.6 Operating System
#!/bin/bash
# +----------------------------------------------------------------------+
# | |
# | Set up Mac OS X to store temporary files in RAM rather than on disk.|
# | |
# | By Philipp Klaus <http://blog.philippklaus.de> |
# | |
# | Originally by Ricardo Gameiro <http://blogs.nullvision.com/?p=357> |
# | Changes by Daniel Jenkins |