Skip to content

Instantly share code, notes, and snippets.

View skatsuta's full-sized avatar

Soshi Katsuta skatsuta

View GitHub Profile
@skatsuta
skatsuta / zipdir.sh
Last active May 5, 2016 09:58
Zip each directory inside a given directory.
#!/usr/bin/env bash
# Show help
if [[ $1 = '--help' || $1 = '-h' ]]; then
echo "Usage: $0 [TARGET_DIR]"
echo "Zip each directory inside TARGET_DIR. If no argument is given, the current directory is regarded as TARGET_DIR."
exit 1
fi
# Zip each directory inside the given directory
@skatsuta
skatsuta / mhdd.sh
Last active August 29, 2015 14:14
Script that manages to mount and unmount external HFS+ USB drive on Linux
#!/usr/bin/env bash
CMD=`basename $0`
usage() {
echo "Usage: ${CMD} on|off"
}
if [[ $# -eq 0 ]]; then
usage
@skatsuta
skatsuta / brew-update-all.sh
Last active May 5, 2016 06:34
Update all Homebrew and Homebrew Cask packages in one command.
#!/bin/bash
set -eu
set -x
brew update
brew upgrade --all
set +x
brew cask update
for c in `brew cask list`; do
@skatsuta
skatsuta / mysqldump.sh
Last active May 5, 2016 06:32
mysqldump command
#!/bin/bash
DATABASE="$1"
TABLE="$2"
mysqldump
--user=username \
--password=password \
--complete-insert \
--quick \
@skatsuta
skatsuta / wercker_cache.sh
Last active August 29, 2015 14:22
Script for storing / restoring cache in Java / Scala project on wercker
#!/bin/bash
#=========================================
# Script for storing and restoring cache
# in Java / Scala project on werkcer
#=========================================
# cache directories
CACHES=( "ivy2" "sbt" )
CMD="$1"
@skatsuta
skatsuta / docker-machine.sh
Last active January 5, 2021 15:59
Tired of running `eval "$(docker-machine env host)"` every time? Just paste this in .bashrc / .zshrc. This script automatically sets environment variables for one of running host machines in Docker Machine.
# check if `docker-machine` command exists
if command -v docker-machine > /dev/null; then
# fetch the first running machine name
local machine=$(docker-machine ls | grep "Running" | head -n 1 | awk '{ print $1 }')
if [ "$machine" != "" ]; then
eval "$(docker-machine env $machine)"
fi
fi
@skatsuta
skatsuta / coolio_1.2.4_build_error.log
Last active September 29, 2015 18:38
cool.io v1.2.4 build error
/Users/soshi/.rbenv/versions/2.1.5/bin/ruby extconf.rb
checking for rb_thread_blocking_region()... yes
checking for rb_thread_call_without_gvl()... yes
checking for rb_thread_alone()... yes
checking for rb_str_set_len()... yes
checking for clock_gettime() in -lrt... no
checking for sys/select.h... yes
checking for poll.h... yes
checking for sys/epoll.h... no
checking for sys/event.h... yes
@skatsuta
skatsuta / Dockerfile-private-repo
Last active October 23, 2015 10:36
Sample Dockerfile that uses a private repository to build
FROM google/golang
RUN apt-get update -y && \
apt-get install -y ca-certificates git-core ssh
ADD id_rsa /root/.ssh/id_rsa
RUN chmod 400 /root/.ssh/id_rsa
RUN echo "Host github.com\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config
RUN git config --global url.ssh://git@github.com/.insteadOf https://github.com/
@skatsuta
skatsuta / race_map.go
Last active November 12, 2015 17:14
Race condition demo of a map in Go. Try `go run race_map.go` many times.
package main
import (
"sync"
"github.com/k0kubun/pp"
)
func main() {
m := map[int]string{}
@skatsuta
skatsuta / .envrc
Last active January 9, 2016 08:15
.envrc for setting environment variables of Docker Machine
local machine=dev
local state=`docker-machine ls | grep $machine | awk '{ print $4 }'`
# Start machine if not running
if [[ "$state" != "Running" ]]; then
echo "Machine \"$machine\" is not running. Starting..."
docker-machine start $machine
docker-compose up -d
fi