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 / jenkins-cli-to-docker-jenkins-install.sh
Last active March 8, 2017 00:43
From Jenkins CLI Plugin export to Docker Jenkins plugin-install.sh
#!/bin/bash
# Not recommended way.
# java -jar jenkins-cli.jar -s http://localhost:8080/ list-plugins | sed 's/\s\s+*/#/g' | tr -s '#' | sed 's/#.*#/:/g' | tr -d ' ' > plugins.txt
# cat plugins.list |tr -s ' ' | sed 's/\s.*\s/:/g' | sed 's/:[^0-9].*//g'
# Export to expected format by install-plugins.sh
java -jar jenkins-cli.jar -s http://localhost:8080/ list-plugins | tr -s ' ' | sed 's/\s.*\s/:/g' | sed 's/:[^0-9].*//g' > plugins.txt
# Install from default Jenkins cli export
@7rin0
7rin0 / git_dos2unix_auto.md
Last active March 10, 2017 11:01
Git filemode, autocrl, dos2unix

Git false filemode checking

git config core.filemode false

Git auto crlf file line-ending conversion

git config --global core.autocrlf true

Git: no ssl verification

git config http.sslVerify "false"

dos2unix

apt-get install dos2unix -y yum install dos2unix -y

@7rin0
7rin0 / dir_loop_cli.sh
Created March 10, 2017 19:45
Dir crawler loop
#/bin/bash
# Usually used at cli as inline-command.
for abc in $(dir); do touch $abc/README.md; done
@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 / convert_to_shell_vars.sh
Created March 28, 2017 09:02
Convert key/value pairs to Shell Variables
#!/bin/bash
# Converting environment to bash variables
export $(cat .env | xargs)