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 / 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 / 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 / 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 / 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 / change_hostname.sh
Last active January 4, 2016 03:19
Change hostname of debian based system without a reboot.
#!/bin/bash
# Change the hostname without reboot
# Applies only to debian based OS
# TODO
# Understand common practises in setting hostnames in /etc/hosts
# in a typical production setting.
@skamithi
skamithi / ssh_port_checker.sh
Last active June 23, 2019 16:09
Bash script to detect if SSH port is active on remote host. Used it orchestrating vm creation using ansible.
#!/bin/bash
# Script for checking if SSH port is open
# Only checks that port is open. Not that actually SSH connection can occur
counter=0
result="ssh disabled"
if [ -z "$1" ]
then
echo "hostname argument required. Example ssh_port_checker.sh 10.1.1.1"
@skamithi
skamithi / gist:6735507
Created September 27, 2013 21:34 — forked from jof/gist:1281122
#!/usr/bin/env ruby
require 'getoptlong'
require 'rubygems'
require 'snmp'
SNMP_COMMUNITY = 'public'
HOSTNAME_BLACKLIST = [ "that_one_switch_thats_down_but_in_dns" ]
ZONE_FILE = /path/to/dns/zone/file
HOSTNAME_REGEX = /^\s?(switch[0-9]+)/i
@skamithi
skamithi / db_cleanout.rake
Last active December 23, 2015 23:19
rake test to clean out test and dev db. Then regenerate both dbs.
namespace :db do
desc 'regenerate test and dev db'
task :regenerate do
Rake::Task['db:drop'].invoke
Rake::Task['db:create'].invoke
Rake::Task['db:migrate'].invoke
Rake::Task['db:test:purge'].invoke
Rake::Task['db:test:prepare'].invoke
end
end
# The IP Address Validator accepts the following options
#
# * allow_nil - allows nil values
# * allow_blank - allows blank values
# * allow_cidr - allows /prefixlen CIDR masks in values
#
# the validator will use regular expressions in an attempt to prevent
# malformed IP addresses from being passed to the IPAddr.new initializer
# as this method can be very slow to raise exceptions for malformed input.
class IpAddressValidator < ActiveModel::EachValidator
@skamithi
skamithi / mount_usershare
Created August 2, 2013 01:33
mount samba share use "net usershare" command. Provide guest access.
net usershare add FLIP /home/backup/myshare "MY SHARE" "Everyone:R" guest_ok=y