Skip to content

Instantly share code, notes, and snippets.

View skamithi's full-sized avatar

Stanley Karunditu skamithi

  • Raleigh, North Carolina
View GitHub Profile
@skamithi
skamithi / update_vim_gits.sh
Created March 17, 2014 02:44
update all pathogen vim git repos
#!/bin/bash
for i in `ls $HOME/.vim/bundle`; do
echo "Update Git for $i"
if [ -d $i ]; then
cd "$i"
git pull
fi
cd $HOME/.vim/bundle
done
@skamithi
skamithi / add_license_header.sh
Created March 25, 2014 15:28
add a license header to each file in a project.
#!/bin/bash
FILELIST=`find . -regex '\.\/[a-z]+.*'`
for f in $FILELIST; do
cat license.header $f > $f.new
mv $f.new $f
done
@skamithi
skamithi / d3test.coffee
Last active August 29, 2015 13:57
express app.js example in CoffeeScript showing how to render D3 output.
# very new to node.js and express.
# very excited to play with server side rendering of SVG.
# If this simple example can be improved pls put your comments.
express = require('express')
d3 = require('d3')
draw_divs = ->
dataset = [ 5, 10, 15, 20, 25 ]
@skamithi
skamithi / converting_from_virtualbox_to_kvm.md
Last active January 9, 2024 16:42
Windows7 Libvirt xml.

converted Virtualbox Win7 VM to KVM. (KVM on Ubuntu 14.04)

  • Shutdown Virtualbox VM.

  • Convert the vdi to a raw disk images. Note: vdi are compressed and raw images are not and so you will need to leave enough disk space for entire uncompressed disk.

VBoxManage clonehd --format RAW win7.vdi win7.img
  • Then on your KVM host:
@skamithi
skamithi / create-ansible-playbook-template.sh
Created April 23, 2014 01:59
script to create ansible playbook structure
#!/bin/bash
# Script to create ansible playbook directories
# define your roles here
roles=(upgrade packages)
directories=(tasks handlers files default vars templates)
# create playbook
mkdir global_vars
@skamithi
skamithi / merge.py
Created May 7, 2014 01:05
Python Merge simple dictionaries
def dict_merge(list1, list2):
""" Trick is to use the .__dict__ keyword. This puts all the attrs associated with
this library's instance are part of the mergin algorithm
_keys = list2.keys()
try _key in keys:
try:
list1[key].__dict__.update(list2[__key].__dict__)
except:
list[_key] = list2[_key]
@skamithi
skamithi / convert2range.py
Last active August 29, 2015 14:01
python convert list of numbers into ranges.
import re
from itertools import groupby
from collections import OrderedDict
# define list of interfaces
a = ['swp2100', 'bond12.100', 'swp22', 'br20',
'bond0', 'bond22', 'port-channel5']
b = OrderedDict()
# group ports based on int name before digit
@skamithi
skamithi / mock_some_func_in_class.py
Created July 17, 2014 18:19
Python - Mock some of the functions in a class while keep the rest the same
@mock.patch('clshow.cliface.CumulusIface.print_name')
@mock.patch('clshow.cliface.CumulusIface.print_ip_details')
@mock.patch('clshow.cliface.CumulusIface.print_counters')
@mock.patch('clshow.cliface.CumulusIface.print_lldp_info')
@mock.patch('clshow.cliface.CumulusIface.print_arp')
def test_print_l3_access(self,
mock_arp,
mock_lldp,
mock_counters,
mock_ip,
@skamithi
skamithi / create_vm_on_ubuntu_14_04.txt
Created September 6, 2014 19:22
creating vms using virt-builder and virt-install on ubuntu 14.04
! add current user to kvm group
usermod -a -G kvm skamithi
! create root password file
cat 'mypass' > /tmp/rootpw
! update soon with run-command to run 'dpkg-reconfigure openssh-server' to regenerate ssh keys
! without this you get a ssh reset peer message
virt-builder ubuntu-14.04 --root-password file:/tmp/rootpw -o ubuntu1404.qcow2 --format qcow2 --size 10G --hostname ubuntu1404
@skamithi
skamithi / npm_cheatsheet.md
Last active August 29, 2015 14:06
npm cheatsheet

Update packages versions in package.json

npm update --save

Install a new package into dependencies

npm install [pkgname] --save