Skip to content

Instantly share code, notes, and snippets.

View bngsudheer's full-sized avatar

Sudheer Satyanarayana bngsudheer

View GitHub Profile
for i in range(0, 8):
print "{0:03b} = {1}".format(i, i)
@bngsudheer
bngsudheer / flac-to-mp3-converter.sh
Created September 23, 2013 15:29
Usage: find -type f -name "*.flac" -exec /path/to/flac-to-mp3-converter.sh '{}' \;
#!/usr/bin/env bash
f="$1"
ffmpeg -i "$f" -qscale:a 0 "${f[@]/%flac/mp3}"
def get_necessary_decimals(number):
if number%1:
number = "{0}".format(str(round(number,1)))
else:
number = int(number)
return number
@bngsudheer
bngsudheer / sendsmtpmail.py
Last active October 16, 2018 06:01
Send SMTP Email Using A Simple Python Script
#!/usr/bin/env python
import argparse
import ConfigParser
from email.MIMEText import MIMEText
from smtplib import SMTP
import sys
parser = argparse.ArgumentParser()
parser.add_argument("subject")
parser.add_argument("recipient")
@bngsudheer
bngsudheer / basic.vimrc
Created January 25, 2015 09:15
Basic .vimrc
set shiftwidth=4
set tabstop=4
set expandtab
set autoindent
map mS i<CR><ESC>
@bngsudheer
bngsudheer / pydecorator.py
Created February 20, 2015 08:45
Python decorator example
from functools import wraps
def my_decorator(f):
@wraps(f)
def wrapper(*args, **kwargs):
print 'Calling decorated function'
print "args in wrapper(): "
print args
print "kwargs in wrapper()"
print kwargs
@bngsudheer
bngsudheer / .vimrc
Last active July 31, 2017 14:33
.vimrc
set shiftwidth=4
set tabstop=4
set expandtab
set autoindent
" The default yellow for Search highlight sucks
hi Search ctermbg=Grey
hi Visual ctermbg=Grey
@bngsudheer
bngsudheer / hgrc
Last active October 18, 2018 11:10
hgrc
[paths]
default = ssh://[email protected]/somerepo
github = git+ssh://[email protected]:bngsudheer/somerepo
[ui]
username = sudheer
[merge-tools]
mymergetool.something = meld
@bngsudheer
bngsudheer / function-dictionary-args.py
Created November 23, 2015 09:12
Pass keyword arguments using a dictionary
# You can nicely pass the dictionary items as keyword arguments
def my_function(a, b, c):
print a, b, c
# Pass keyword arguments
my_function(a=10, b=20, c=30)
args_dict = {'a': 100, 'b': 200, 'c':300}
# Pass keyword arguments using a dictionary
# The dictionary keys map to names of the keyword arguments
@bngsudheer
bngsudheer / find-badass-process-outbound-ssh.sh
Created March 11, 2016 14:47
Find the process that tries to establish outbound SSH connections
#!/bin/bash
# Find process that tries to establish outbound SSH connections
for (( ; ; ))
do
sleep 1
lsof -i tcp:22 -P -R
if [ $? -eq 0 ]; then
echo 'found something. See above for details'
exit
else