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 / ansible_tips.yml
Last active August 29, 2015 13:56
Ansible Tips
# Execute gnome action as a user
- name: enable middle click
shell: "sudo -u {{ core_username.stdout }} dbus-launch gsettings set org.gnome.settings-daemon.peripherals.mouse middle-button-enabled true"
# Execute Gem Install using RVM
- name: install knife-solo
shell: >
executable=/bin/bash source /etc/profile.d/rvm.sh;
gem install --no-ri --no-rdoc knife-solo
@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 / 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 / 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

@skamithi
skamithi / virsh_win7.md
Last active August 29, 2015 14:10
virsh + win7
@skamithi
skamithi / install_new_vm_on_laptop.md
Created December 11, 2014 19:05
installing a new VM on my laptop_using libvirt
# virt-builder ubuntu-14.04 --size 5G --hostname cacti --root-password password:<mypassword> --format qcow2 -o cacti.qcow2

# virt-install --import --name cacti --ram 1024 --disk $HOME/imgs/cacti.qcow2,format=qcow2,bus=virtio,cache=none --os-type linux --os-variant ubuntutrusty