Taken from Zach Holman's "Git and Github Secrets".
t - quickly jump through files (similar to cmd+T in VI or Text Mate)
w - quickly switch branches
s - search
| /* Exercise: Loops and Functions #43 */ | |
| package main | |
| import ( | |
| "fmt" | |
| "math" | |
| ) | |
| func Sqrt(x float64) float64 { | |
| z := float64(2.) |
Taken from Zach Holman's "Git and Github Secrets".
t - quickly jump through files (similar to cmd+T in VI or Text Mate)
w - quickly switch branches
s - search
| function errexit() { | |
| local err=$? | |
| set +o xtrace | |
| local code="${1:-1}" | |
| echo "Error in ${BASH_SOURCE[1]}:${BASH_LINENO[0]}. '${BASH_COMMAND}' exited with status $err" | |
| # Print out the stack trace described by $function_stack | |
| if [ ${#FUNCNAME[@]} -gt 2 ] | |
| then | |
| echo "Call tree:" | |
| for ((i=1;i<${#FUNCNAME[@]}-1;i++)) |
| #!/bin/bash | |
| foo=${1:-hoge} | |
| echo $foo #$1がなかったらhogeをデフォルト値としてfooに代入する | |
| #var自身にデフォルト値としてhogeを代入としたいので以下のように書きたい | |
| ${var:=hoge} #このままでは、hogeが展開されてしまって、hogeなんてコマンドはないとシェル怒られる | |
| echo "1:$var" | |
| var= |
| ### Add trailing slash if needed | |
| STR="/i/am/a/path" | |
| length=${#STR} | |
| last_char=${STR:length-1:1} | |
| [[ $last_char != "/" ]] && STR="$STR/"; : | |
| echo "$STR" # => /i/am/a/path/ |
| var EPSILON float64 = 0.00000001 | |
| func floatEquals(a, b float64) bool { | |
| if ((a - b) < EPSILON && (b - a) < EPSILON) { | |
| return true | |
| } | |
| return false | |
| } |
| # http://askubuntu.com/questions/505446/how-to-install-ubuntu-14-04-with-raid-1-using-desktop-installer | |
| # http://askubuntu.com/questions/660023/how-to-install-ubuntu-14-04-64-bit-with-a-dual-boot-raid-1-partition-on-an-uefi%5D | |
| sudo -s | |
| apt-get -y install mdadm | |
| apt-get -y install grub-efi-amd64 | |
| sgdisk -z /dev/sda | |
| sgdisk -z /dev/sdb | |
| sgdisk -n 1:0:+100M -t 1:ef00 -c 1:"EFI System" /dev/sda | |
| sgdisk -n 2:0:+8G -t 2:fd00 -c 2:"Linux RAID" /dev/sda |
| # Backup | |
| docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql | |
| # Restore | |
| cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE | |
Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...
// see: https://github.com/chadoe/docker-cleanup-volumes
$ docker volume rm $(docker volume ls -qf dangling=true)
$ docker volume ls -qf dangling=true | xargs -r docker volume rm
| gitlab: | |
| image: gitlab/gitlab-ce | |
| volumes: | |
| - /srv/docker/gitlab/data:/var/opt/gitlab | |
| - /srv/docker/gitlab/config:/etc/gitlab | |
| - /srv/docker/gitlab/logs:/var/log/gitlab | |
| ports: | |
| - "10080:10080" | |
| - "10443:443" | |
| - "10022:22" |