Skip to content

Instantly share code, notes, and snippets.

View yogeek's full-sized avatar

Guillaume Dupin yogeek

View GitHub Profile
@yogeek
yogeek / centos_agnoster_install.md
Last active January 9, 2018 18:29 — forked from renshuki/ubuntu_agnoster_install.md
Ubuntu 16.04 + Terminator + Oh My ZSH with Agnoster Theme
@yogeek
yogeek / Zsh & theme
Created November 2, 2017 13:10 — forked from leemour/Zsh & theme
Zsh installation and Agnoster theme settings
# Railscast
http://railscasts.com/episodes/308-oh-my-zsh
# Install Zsh
sudo apt-get update && sudo apt-get install zsh
# Install Oh-my-zsh
wget –no-check-certificate https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O – | sh
# Make ZSH default shell
@yogeek
yogeek / init_db.sh
Created November 8, 2017 14:05
PostgreSQL
# Create database owner
createuser -U postgres --createdb --createrole ${DB_OWNER};
psql --dbname ${DB_NAME} -c "ALTER USER '${DB_OWNER}' WITH PASSWORD '${DB_OWNER_PASSWORD}';"
# Create database
createdb -U ${DB_OWNER} ${DB_NAME};
# List databases
psql -U ${DB_OWNER} --list
@yogeek
yogeek / find-dependent-images.sh
Created November 16, 2017 09:19
Docker : Find dependent child images
# In case "docker rmi" displaying the following message :
# Error response from daemon: conflict: unable to delete 599a1a74e98d (cannot be forced) - image has dependent child images
IMAGE_ID=xxxx
for i in $(docker images -q)
do
docker history $i | grep -q $IMAGE_ID && echo $i
done | sort -u
# Then "docker rmi" the resulted images
@yogeek
yogeek / Test jinja template
Last active April 15, 2019 13:11
Ansible comands
./ansible.sh -i inventories/dev -c local -m template -a "src=file.j2 dest=file.txt" 127.0.0.1
# Online tool
https://cryptic-cliffs-32040.herokuapp.com/
# https://stackoverflow.com/questions/35407822/how-can-i-test-jinja2-templates-in-ansible
# Script to switch between HTTP and SSH git remote URL
gitswitch () {
if [[ "$(git remote -v)" == "" ]]
then
echo "No remote configured. Use 'git remote add' to set one"
return
fi
remoteRoot=$(git remote -v | head -1 | grep root)
# Adapted from <https://superuser.com/questions/332252/creating-and-formating-a-partition-using-a-bash-script>
(
echo d # Delete sda2 partition table
echo 2 # Default = sda2
echo n # Add a new sda2 partition
echo p # Primary partition
echo 2 # Partition number
echo # First sector (Accept default: 2099200)
echo # Last sector (Accept default: varies, e.g 104857599)
@yogeek
yogeek / docker-compose.yml
Created January 5, 2018 18:34
docker-compose generic readiness condition
# Example : waiting for DB and Elasticsearch to be ready before launching a service
# The svc docker image must contain the start-when-ready.sh script
services:
svc:
image: svc
environment:
READINESS_CONDITION: '[ $$(curl --write-out %{http_code} --silent --output /dev/null http://elasticsearch:9200/_cat/health?h=st) = 200 ] && nc -w 1 -z $$DB_HOST $$DB_PORT 2>/dev/null'
READINESS_SLEEP: 5
@yogeek
yogeek / docker-machine-playbook.yml
Created January 5, 2018 19:20
Docker-Machine playbook
---
- hosts: localhost
vars:
docker_machine_version: v0.14.0
tasks:
- name: Install Docker Machine
get_url:
url: "https://github.com/docker/machine/releases/download/{{ docker_machine_version }}/docker-machine-linux-x86_64"
@yogeek
yogeek / Process
Created January 6, 2018 19:39
System commands
# List of top processes ordered by RAM and CPU use in descendant form
ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head