Skip to content

Instantly share code, notes, and snippets.

@jesugmz
jesugmz / recursive-chmod-directories-and-files.sh
Last active September 5, 2016 23:21
Recursive chmod for directories and files
#!/bin/bash
#
# Recursive chmod for directories and files.
#
# all directories within the current path to 755 (-rwxr-xr-x)
find . -type d -exec chmod 755 {} \;
# all files within the current path to 644 (-rw-r--r--)
@jesugmz
jesugmz / extract-unique-values-using-bash.md
Last active February 25, 2019 00:22
Extract unique values using Bash

Extract unique values using Bash

awk

Usage

[command with duplicate output |] awk '!a[$0]++' [filename with duplicate values]
@jesugmz
jesugmz / flush-docker-data.sh
Last active May 20, 2020 19:48
Delete the whole Docker data created by the user. TAKE CARE!!!
#!/bin/bash
#
# Delete the whole data created by the user. TAKE CARE!!!
#
# kill all running containers
docker kill $(docker ps -q)
# delete all containers
@jesugmz
jesugmz / find-files-containing-string.sh
Last active February 18, 2017 23:00
Find files containing a string
#!/bin/bash
#
# Find files containing a string
#
grep -rnw /path/to/search/ -e "<PATTERN>"
@jesugmz
jesugmz / kill-all.sh
Last active May 13, 2021 13:01
An alternative to killall command
#!/bin/bash
#
# An alternative to killall command
#
kill -9 $(pgrep <PROCESS_NAME>)
@jesugmz
jesugmz / custom-dns-docker.md
Last active August 18, 2018 04:07
Resolve domains locally with docker engine DNS

Custom DNS docker engine level

Depend of the init system of the OS:

Systems using Upstart and SysVinit

  • Add in /etc/default/docker DOCKER_OPTS="--dns <DNS_IP_1> --dns <DNS_IP_2>"
  • $ sudo service docker restart

Systems using SystemD

  • Add in /etc/docker/daemon.json
@jesugmz
jesugmz / get-interactive-bash-docker-container.txt
Last active February 18, 2017 23:01
Get an interactive bash in Docker containers
# get CONTAINER_ID with 'docker ps'
docker exec -it <CONTAINER_ID> bash
# or with docker-compose
docker-compose exec <CONTAINER_NAME> bash
@jesugmz
jesugmz / 60-jetbrains.conf
Last active April 24, 2023 17:32
Avoid the message 'External file changes sync may be slow: The current inotify(7) watch limit is too low.' from JetBrains products
#
# Avoid the message 'External file changes sync may be slow: The current inotify(7) watch limit is too low.' from JetBrains products.
#
# 1. Create the file /etc/sysctl.d/60-jetbrains.conf and paste this code
# 2. Restart the sysctl service: sudo sysctl -p --system
# 3. Restart the IDE
#
# More info:
# https://confluence.jetbrains.com/display/IDEADEV/Inotify+Watches+Limit
@jesugmz
jesugmz / git-spreadsheet .md
Last active February 2, 2022 09:38
git spreadsheet

git spreadsheet

Apply commit from another branch

git cherry-pick <COMMIT_HASH_FROM_ANY_BRANCH>

Apply changes of a file from another branch

@jesugmz
jesugmz / run.sh
Created February 22, 2017 09:03
Example bash script to deploy Docker containers
#!/bin/bash
process() {
if [ $# -eq 1 ] && ([ "$1" = "-h" ] || [ "$1" = "--help" ]); then
show_help
else
launch_containers
while true; do
case $1 in