Skip to content

Instantly share code, notes, and snippets.

View xbalaji's full-sized avatar

Balaji (xbalaji) V xbalaji

View GitHub Profile
@xbalaji
xbalaji / ansible-getfacts.yml
Created March 24, 2018 03:17
ansible-getfacts
---
#
# Filename : getfacts.yml
# Date : 15 Dec 2017
# Author : Balaji Venkataraman ([email protected])
# Description : get facts about hosts
#
# Usage:
# run this playbook against specific host(s) as follows:
@xbalaji
xbalaji / ansible-vault-pass.sh
Created March 24, 2018 03:19
ansible-vault-pass
use the technique described in http://docs.ansible.com/ansible/latest/config.html#default-vault-password-file
create a file: vault-pass.sh
cat > vault-pass.sh << EOF
#! /bin/bash
echo $ANSIBLE_VAULT_PASSWORD
EOF
chmod +x vault-pass.sh
@xbalaji
xbalaji / pyserver.sh
Last active August 24, 2018 22:44
python simple webserver - non blocking one liner
# from: https://recipes.readthedocs.io/en/latest/pyserv.html
screen -dmS pyserv python -m SimpleHTTPServer 80
# simple screen cheat sheet
#
# To list detached screen sessions
# screen -ls
#
@xbalaji
xbalaji / .gitignore
Created September 1, 2018 18:16
gitignore files
# ignore swap files
*.sw?
.*.un~
.*.sw~
# global git ignore, for all repos
# git config --global core.excludesfile ~/.gitignore_global
# see also: https://github.com/github/gitignore
@xbalaji
xbalaji / oneliners-generate-index-html.sh
Last active October 10, 2022 04:02
generate a quick index.html page including sub directories
# oneliners-generate-index-html.sh
# this takes care of sub directories as well, adds a table with row numbers, easy for reference
# wrote this script for generating pages in gitlab :)
find . -type f | sort | awk 'BEGIN {print "<html><body><table align=center border=1>"} {printf "<tr><td>%d<td><a href=\"%s\">%s</a>\n", FNR, $0, $0 } END {print "</table></body></html>"}' > index.html
@xbalaji
xbalaji / python_docker.sh
Last active September 3, 2018 07:21
docker-python-cheatsheet
# run a python 2.7 in a docker container, debian linux, apt works
docker run --name py27 -d -t python:2.7
# exec bash in the docker container
docker exec -i -t py27 /bin/bash
# run a container with mounting directory, mount volume should be absolute path
docker run --name py27 -d -t -v ~/all/xb-all/utils:/utils python:2.7
# stop and remove a running container
@xbalaji
xbalaji / git-config
Created September 11, 2018 02:07
git config commands
# git ignore certificates
# git -c http.sslVerify <git command>
git -c http.sslVerify=false pull
# to disable for the entire repo
git config http.sslVerify false
@xbalaji
xbalaji / clean-up-git-folder.sh
Last active September 16, 2018 19:55
clean up git folder
# see: https://stackoverflow.com/questions/5613345/how-to-shrink-the-git-folder
# good and safe command - from http://gcc.gnu.org/ml/gcc/2007-12/msg00165.html
git repack -a -d --depth=250 --window=250
# default options should be enough for most cases, see: https://git-scm.com/docs/git-repack
git repack -a -d
# agressive way
@xbalaji
xbalaji / at_cmd.sh
Created November 5, 2018 02:26
AT command
# in a single line
echo "wget http://bit.ly/xb-do-unix -q -O test02.txt" | at now + 1 minutes
# using here document
at 6:26 PM << EOF
wget http://bit.ly/xb-do-unix -q -O test02.txt
EOF
# if there is no EOF given, use CTRL+D to terminate the commands
@xbalaji
xbalaji / scroll.sh
Last active November 11, 2018 06:09
scroll code for gif
# from https://superuser.com/questions/472476/is-there-an-automatically-scrolling-time-delayed-unix-pager-command
function scroll
{
while read -r ; do echo "$REPLY" ; sleep ${1:-0.5} ; done
}
# assuming you have source code src directory
find src -type f -name "*c" -exec cat {} \; | scroll 0.2
# use the following vimpager, asciinema, asciicast2gif