Skip to content

Instantly share code, notes, and snippets.

View skatsuta's full-sized avatar

Soshi Katsuta skatsuta

View GitHub Profile
@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 / 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 / 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 / auto_ssh.sh
Created December 19, 2014 02:21
Auto login script
#!/bin/sh
auto_ssh() {
HOST=$1
ID=$2
PASS=$3
KEY=$4
expect -c "
set timeout 10
@skatsuta
skatsuta / tomcat.sh
Last active August 29, 2015 14:07
Tomcat start & stop script
#!/bin/bash
CATALINA_HOME=/usr/local/src/apache-tomcat-8.0.14/
start() {
$CATALINA_HOME/bin/startup.sh
return 0
}
stop() {
// 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!"
@skatsuta
skatsuta / mysql_backup.sh
Last active August 29, 2015 14:04
MySQL で dump ファイルを出力し、scp で外部サーバに転送する
#!/bin/bash
dumpfile="dump.sql"
user="user"
host="XXX.XXX.XXX.XXX"
distdir="."
mysqldump -u root dbname > $dumpfile
scp $dumpfile $user@$host:$distdir
@skatsuta
skatsuta / menuwork.sh
Created July 16, 2014 06:10
カレントディレクトリにあるシェルスクリプトの一覧を表示して実行する
#!/bin/bash
counter=0
menu=(`ls *.sh`)
echo "### MENU ###"
for item in "${menu[@]}"; do
echo "$counter: $item"
counter=`expr $counter + 1`
done
@skatsuta
skatsuta / pscheck.sh
Last active August 29, 2015 14:04
プロセスの起動確認
#!/bin/bash
PROCESS=$1
PROCESS_NUM=$(ps cax | grep $PROCESS | wc -l)
# 引数チェック
if [ $# -eq 0 ]; then
echo "Usage: $0 process_name" 1>&2
exit1
fi
@skatsuta
skatsuta / build.gradle
Created July 7, 2014 00:56
Scala 用 build.gradle
apply{
plugin 'scala'
plugin 'idea'
}
ext {
scalaVersion = '2.11'
spec2Version = '2.3.12'
}