Skip to content

Instantly share code, notes, and snippets.

View xbalaji's full-sized avatar

Balaji (xbalaji) Venkataraman xbalaji

View GitHub Profile
(function() {
q=window.getSelection().toString().replace(/[^0-9]/g,%20'');
if (!q) {
q=prompt('Enter%20Bugid:')
}
if (q) {
window.open('https://bugs.XYZCompany.com/show_bug.cgi?id='+escape(q))
} else {
window.open('http://bugs.XYZCompany.com')
}
@xbalaji
xbalaji / youtube-download
Last active August 11, 2017 19:33
youtube download audio
Install youtube download from https://rg3.github.io/youtube-dl/download.html
Install ffmpeg on your system
youtube-dl --extract-audio --audio-format mp3 -f bestaudio <youtube-url>
sometimes file names are too long.. use
youtube-dl --extract-audio --audio-format mp3 -f bestaudio 'https://www.youtube.com/watch?v=owJojkB3MHk' -o "sivaji_sad_songs2.%(ext)s"
@xbalaji
xbalaji / ansible-training-docker
Created September 19, 2017 14:57
ansible training docker setup
# start the containers
docker run --name web1 -d -t ubuntu
docker run --name web2 -d -t ubuntu
docker run --name db1 -d -t ubuntu
# print the ip addresses of the containers
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' we b1
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' we b2
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' db
@xbalaji
xbalaji / docker+sshd
Last active October 1, 2017 22:57
sshd on docker
################## Dockerfile ###################
FROM ubuntu:16.04
RUN apt-get update && apt-get install -y openssh-server
RUN mkdir /var/run/sshd
RUN echo 'root:screencast' | chpasswd
RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
# SSH login fix. Otherwise user is kicked off after login
@xbalaji
xbalaji / docker+ubuntu+sshd+python
Last active April 15, 2018 05:02
docker+ubuntu+sshd+python - for ansible testing
#
# available at gist:
# https://gist.github.com/xbalaji/ecd428eb8ee48981cb24ac0c57c8d21b
#
################## Dockerfile ###################
# from
# https://docs.docker.com/engine/examples/running_ssh_service/
#
# build command
# docker build -f <Dockerfile> -t ubsshpy .
ls -dl /mnt/hgfs/host-c
cd /
hostname -I
python3 -m http.server --bind $(hostname -I)
@xbalaji
xbalaji / ansible_mult_dir.yml
Created October 2, 2017 03:33
Ansible create multiple directories
---
- hosts: all
vars:
tmp_dir: "/tmp/ansible-test"
tasks:
- name: create directories
file:
path: "{{tmp_dir}}/{{item}}"
@xbalaji
xbalaji / regex_replace.py
Last active January 27, 2018 07:25
python regular expression replace
import re
mystr="this is a complex string !@#$%^&*()-=+,.?:;'\\/\" with numbers 1234?"
# note: raw string used with double quotes in re.sub
out_str = re.sub(r"([ !@#$%^&*()\-=+,.?:;'/\\\"])", r'_', mystr)
print(mystr)
print(out_str)
@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
@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