Skip to content

Instantly share code, notes, and snippets.

View skihero's full-sized avatar

Kish skihero

  • Amazon Mechanical Turk
  • Ooty
View GitHub Profile
@skihero
skihero / gist:7bd9f68d8c6ef74d14bd
Created June 5, 2014 17:42
pip from within python
import pip
packages = ["StringIO"]
pip.main(["install", "--upgrade"] + packages )
@skihero
skihero / X21.c
Last active August 29, 2015 13:56
From the textbook, a simple virus
/* The X21 virus sample */
#include <stdio.h>
#include <sys/types.h>
#include <dirent.h>
#include <sys/stat.h>
DIR *dirp; /* directory search structure */
struct dirent *dp; /* directory entry record */
struct stat st; /* file status record */
@skihero
skihero / epoll_test.c
Created December 19, 2013 14:27
Re learning mode. A bit of play with epoll
/*
* Program to serve many client request without blocking
* using epoll
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/epoll.h>
@skihero
skihero / gist:7909983
Created December 11, 2013 12:57
swap ctrl and caps with setxkbmap
/usr/bin/setxkbmap -option "ctrl:swapcaps"
@skihero
skihero / sele_title
Created December 10, 2013 05:53
sel py
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
chromedriver= '/tmp/chromedriver'
os.environ["webdriver.chrome.driver"] = chromedriver
browser = webdriver.Chrome(chromedriver)
browser.get('http://www.site.com')
assert 'site' in browser.title
@skihero
skihero / gist:5046841
Created February 27, 2013 10:09
error: unpacking of archive failed on file /usr/sbin/haproxy;512ddaaa: cpio: Digest mismatch
Was trying to create an rpm from the installed haproxy binaries.
Ran into this problem.
Turns out we need to do a prelink -u haproxy on the binary that we're packaging.
The binary had come from a different machine than the place where we're building it.
@skihero
skihero / get_cost_softlayer_api_hardware
Created October 3, 2012 19:37
Get costs of hardware using softlayer api
get '/costs' do
begin
account_service = SoftLayer::Service.new("SoftLayer_Account")
costs= account_service.object_mask({"hardware" => ["id", "hostname","notes", "cost"]}).getHardware
rescue
@error = "Error fetching cost details !! "
end
@skihero
skihero / basketball_doodle_google
Created August 8, 2012 14:15
Play google basketball doodle
import pyatspi
import time
time.sleep(5)
count=0
for i in range (1, 10000) :
pyatspi.Registry.generateKeyboardEvent(65, None, pyatspi.KEY_PRESSRELEASE)
count=count+1
if count < 33:
time.sleep(0.5107)
@skihero
skihero / mv_with_filename
Created July 2, 2012 19:14
son of a gun
OIFS="$IFS"
IFS=$'\n'
export i=1
for fil in `ls -tr *.flv` ; do mv "${fil}" $i.flv; i=$(($i + 1 )); done
@skihero
skihero / puppet_ruby_client_start.sh
Created June 25, 2012 09:25
Start the puppet and ruby bundle, setting the right paths
#!/bin/bash
PUPPET_RUBY_DIR="/usr/local/puppetandruby"
PUPPET_MSTR_SERVER=" rov-master. .com"
# Let the path find puppet's ruby first
export PATH=${PUPPET_RUBY_DIR}/bin/:$PATH