Skip to content

Instantly share code, notes, and snippets.

View royingantaginting's full-sized avatar

Roy Inganta Ginting royingantaginting

View GitHub Profile
@royingantaginting
royingantaginting / es-scripts.sh
Last active September 26, 2016 04:05
Elasticsearch Scripts
# List all indices in ES and sort the output
curl 'localhost:9200/_cat/indices?v' 2>/dev/null | awk 'NR<2{print $0;next}{print $0| "sort -r"}'
# Turn off replication for all ES indices
curl -XPUT http://localhost:9200/_settings -d '{ "index": { "number_of_replicas": 0 } }'
@royingantaginting
royingantaginting / .vimrc
Created July 27, 2016 10:05
Vim with 4 spaces width tab
filetype plugin indent on
" show existing tab with 4 spaces width
set tabstop=4
" when indenting with '>', use 4 spaces width
set shiftwidth=4
" On pressing tab, insert 4 spaces
set expandtab
_docker_ip()
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts=$(docker ps --format "{{ .Names }}")
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
@royingantaginting
royingantaginting / docker-ip
Created July 27, 2016 07:13
Get IP address of a container
#!/bin/bash
case $# in
0)
echo "Usage: $0 (container name)"
exit 1
;;
*)
docker inspect -f '{{ .NetworkSettings.IPAddress }}' $@
;;
@royingantaginting
royingantaginting / .inputrc
Last active July 27, 2016 07:10
Autocomplete from history for Bash. To install this keyboard shortcut, put this file at ~/.input and open new terminal.
"\e[A": history-search-backward
"\e[B": history-search-forward
"\eOA": history-search-backward
"\eOB": history-search-forward
@royingantaginting
royingantaginting / git-stats.sh
Created March 1, 2016 07:13
Print git commit statistics for each users
#!/bin/bash
while read -r -u 9 date name
do
day=$(date -d $date +%A)
if [[ "$day" == "Sabtu" || "$day" == "Minggu" ]]; then
echo "$day $date $name"
echo
GIT_PAGER=cat git log --committer="$name" --since="$date 00:00:00 +0700" --until="$date 23:59:59 +0700" --format=' * [%h] %s' --date=short
echo
@royingantaginting
royingantaginting / docker-compose.yml
Created February 11, 2016 08:12
Nginx reverse proxy with automatic https certificate generation from Letsencrypt https://letsencrypt.org/.
proxy:
image: jwilder/nginx-proxy
volumes:
- ./opt/certs:/etc/nginx/certs:ro
- /etc/nginx/vhost.d
- /usr/share/nginx/html
- /var/run/docker.sock:/tmp/docker.sock:ro
ports:
- "80:80"
- "443:443"
#!/bin/bash
function delete_container_exited(){
docker rm -v $(docker ps -a -q -f status=exited)
}
function delete_container_all(){
docker rm -v $(docker ps -a -q)
}

Required Jenkins Plugins

  • GitHub Plugin
  • Plot Plugin
  • Clover PHP Plugin
  • Checkstyle Plugin
  • PMD Plugin
  • DRY Plugin
  • Green Balls
  • Analysis Collector Plugin
  • JDepend Plugin
@royingantaginting
royingantaginting / docker-compose-install.sh
Last active July 27, 2016 06:52
Oneliner script to install docker compose
# Make sure your docker engine version is at least version 1.7.1 for docker-compose version 1.5.2
# Available docker-compose can be seen at https://github.com/docker/compose/releases
# Change VERSION variable below if you need other version
VERSION=1.5.2; sudo curl -Lo /usr/local/bin/docker-compose https://github.com/docker/compose/releases/download/$VERSION/docker-compose-`uname -s`-`uname -m` && sudo chmod +x /usr/local/bin/docker-compose