Skip to content

Instantly share code, notes, and snippets.

View 7rin0's full-sized avatar

SEVERINO, Luis 7rin0

  • Lyon, France
View GitHub Profile
@7rin0
7rin0 / log_commit_per_week.sh
Last active March 15, 2017 22:30
Log a commit per week
#/bin/bash
for i in {0..70}
do
TARGET_DATE=$(date -d "-$i week" +"%Y-%m-%d")
git log -1 --before=$(git log -1 --before=$TARGET_DATE | grep commit | tr -d 'commit ' | cut -c 1-6)
# Example: Checkout first commit of each week backwards and evaluate the code and metrics with phpqs
# cd $PROJECT_PATH
# COMMIT=$(git log -1 --before=$TARGET_DATE | grep commit | tr -d 'commit ' | cut -c 1-6)
@7rin0
7rin0 / github_create_repo_cli.sh
Created March 21, 2017 22:26
Create github repository from cli
# source: http://stackoverflow.com/questions/2423777/is-it-possible-to-create-a-remote-repo-on-github-from-the-cli-without-opening-br/10325316#10325316
curl -u 'USER' https://api.github.com/user/repos -d '{"name":"REPO"}'
# Remember replace USER with your username and REPO with your repository/application name!
git remote add origin git@github.com:USER/REPO.git
git push origin master
@7rin0
7rin0 / docker_ssh.sh
Created March 21, 2017 22:40
Docker SSH image
#!/bin/bash
# Pass as first and only argument the container name or id.
# This assumes the container as bash and also that you want to login as root.
# ./docker_ssh.sh container_name
docker exec -i -t -u 0 $1 /bin/bash
@7rin0
7rin0 / script_absolute_path.sh
Created March 24, 2017 09:23
Script Absolute Path
#!/bin/bash
# Useful if you are executing this script
# and including files by relative location
# or working and interacting with another scripts and folders.
SCRIPT_ABS_DIR=$(dirname $(realpath $0))
@7rin0
7rin0 / fcunix.sh
Created March 27, 2017 15:39
Find and convert files to Unix format
#/bin/bash
dos2unix $(grep -r 'bin/bash' | cut -d':' -f1)
@7rin0
7rin0 / read.sh
Last active March 28, 2017 08:55
Read
#!/bin/bash
# Say a b c
# man read
echo "===== Say 'A'"
read a
echo "===== Say 'B'"
read b
@7rin0
7rin0 / docker_rm_by_img_name.sh
Created April 26, 2017 13:22
Docker remove containers by image name
#!/bin/bash
# http://stackoverflow.com/a/32074098
docker rm $(docker stop $(docker ps -a -q --filter ancestor=<IMAGE_NAME> --format="{{.ID}}"))
#!/bin/bash
# remove exited containers:
docker ps --filter status=dead --filter status=exited -aq | xargs -r docker rm -v
# remove unused images:
docker images --no-trunc | grep '<none>' | awk '{ print $3 }' | xargs -r docker rmi
# remove unused volumes:
find '/var/lib/docker/volumes/' -mindepth 1 -maxdepth 1 -type d | grep -vFf <(
@7rin0
7rin0 / open_block_links_tidbit.js
Created April 30, 2017 10:33
Open all links inside an element using jQuery/JS
@7rin0
7rin0 / find_files_by_time.sh
Created May 1, 2017 15:07
Find files by modified time
# Move found files modified the 5 minutes before, depth level 1, to "DIR" directory ...
mv $(find ./ -maxdepth 1 -mmin -5) DIR/