Skip to content

Instantly share code, notes, and snippets.

View xbalaji's full-sized avatar

Balaji (xbalaji) V xbalaji

View GitHub Profile
@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 / 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 / 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 / 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 / .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 / 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 / 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 / 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 / oneliners-ansible.sh
Last active February 24, 2021 04:28
ansible-adhoc-facts
# get facts from a remote 'myhost.com' with ssh user root, password on prompt
ansible all -i 'myhost.com,' -m setup -u root -k
# Ansible playbook structure - create directories first, so you can run a single touch command
mkdir -p group_vars host_vars library filter_plugin roles/common/{tasks,handlers,templates,files,vars,defaults,meta}
touch ansible.cfg hosts.ini site.yml staging.ini production.ini roles/common/{tasks,handlers,templates,files,vars,defaults,meta}/main.yml
@xbalaji
xbalaji / ubuntu-minimal-desktop.sh
Created March 7, 2018 04:06
ubuntu minimal desktop
# https://askubuntu.com/questions/53822/how-do-you-run-ubuntu-server-with-a-gui
sudo apt -y update
sudo apt install -y xorg
sudo apt install -y --no-install-recommends lightdm-gtk-greeter
sudo apt install -y --no-install-recommends lightdm
sudo apt install -y --no-install-recommends ubuntu-gnome-desktop