Skip to content

Instantly share code, notes, and snippets.

View praveenkumar's full-sized avatar
🏠
Working from home

Praveen Kumar praveenkumar

🏠
Working from home
View GitHub Profile
import libvirt
# Get a connection to Hypervisor (optional URI).
# Return virConnect object if successfull otherwise NULL
# More: http://libvirt.org/html/libvirt-libvirt.html#virConnectOpen
# Check openAuth and openReadOnly methods also.
@praveenkumar
praveenkumar / maps.go
Created April 3, 2014 04:26
Excersice: Maps
package main
import (
"code.google.com/p/go-tour/wc"
"strings"
)
func WordCount(s string) map[string]int {
words := strings.Fields(s)
m := make(map[string]int)
@praveenkumar
praveenkumar / fibonacci.go
Created April 3, 2014 04:44
Exercise: Fibonacci closure
package main
import "fmt"
// fibonacci is a function that returns
// a function that returns an int.
func fibonacci() func() int {
pre := 0
post := 1
return func() int{
@praveenkumar
praveenkumar / code_snip.py
Created May 13, 2014 05:40
Jenkins Job invoke with file parameter
data_file = open('<file_name>', 'r')
running_job_object = new_job.invoke(block=True,
build_params={'<para1>': '<value>', '<para2>': '<value>'},
files={'<file_para_name>': data_file})
data_file.close()
@praveenkumar
praveenkumar / tox_config
Created July 11, 2014 04:10
Tox file discription
[tox]
envlist = py26, py27
[testenv]
commands =
python pytest
[testenv:py26]
deps=
argparse
@praveenkumar
praveenkumar / rpm-python_tarball_steps
Created July 11, 2014 04:31
Creating rpm-python tarball from rpm source
# Install devel library
yum install rpm-devel
# Download available srpm (using f20 srpm)
wget https://kojipkgs.fedoraproject.org//packages/rpm/4.11.2/1.fc20/src/rpm-4.11.2-1.fc20.src.rpm
# Extract SRPM
rpm -Uvh <SRPM>
# Install rpm dependencies
import signal
import time
import os
from subprocess import check_output, Popen, CalledProcessError
def get_pid(name):
return check_output(["pidof",name])
def handler(signum, frame):
print "signal handler called with signal %s" % signum
@praveenkumar
praveenkumar / gist:2b54d9351b41f1ecd7fa
Last active October 23, 2015 14:06
Openshift Experiment
Running Openshift in adb virtual-box
------------------------------------
1. Note adb virtual box already running etcd service which using port
7001 then stop those service (In my case, kubernetes/etcd service was
running and due to that openshift/origin container was not able to run)
BZ #1271468
2. Start openshift origin container
```
@praveenkumar
praveenkumar / pull_latest_image.py
Created October 26, 2015 05:58
Pull all <images>:<tag> with latest build
#!/usr/bin/env python
# Script to get pull all <images>:<tag> with latest build
import docker
import json
cli = docker.Client(base_url='unix://var/run/docker.sock')
repo_tags = []
# Using downloaded Vagrant
vagrant box add cdk2 file:///home/prkumar/work/cdk2/rhel-7.2-server-kubernetes-vagrant-scratch-1-1.x86_64.vagrant-libvirt.box
# Initialize a box (This will create a vagrantfile in current working directory)
vagrant init cdk2
# Start a box
vagrant up
# ssh to the box