Skip to content

Instantly share code, notes, and snippets.

View kra3's full-sized avatar
🤠
I may be slow to respond.

Arun Karunagath kra3

🤠
I may be slow to respond.
View GitHub Profile
@kra3
kra3 / discriptor_magic.py
Created April 17, 2012 22:09
ProxyProperty: Properties with proxy & instance varibale emulation
# -*- coding: utf-8 -*-
__author__ = "Arun KR (kra3) <the1.arun@gmail.com>"
__license__ = "Simplified BSD"
'''
Can be found at: https://gist.github.com/2409397
Public Clone URL: git://gist.github.com/2409397.git
Private Clone URL: git@gist.github.com:2409397.git
'''
@kra3
kra3 / ifconfig_sample.c
Created July 1, 2012 09:30 — forked from copyninja/ifconfig_sample.c
Just for fun - Ip getting and setting
#include <stdio.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <net/if_arp.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <features.h>
@kra3
kra3 / internet-share.sh
Created July 1, 2012 09:30 — forked from copyninja/internet-share.sh
Enabling the internet sharing
#!/bin/zsh
# Bring up the wlan0 interface
ifconfig wlan0 up
# Put the interface in Ad-hoc mode
iwconfig wlan0 mode Ad-Hoc
# Set the essid for the access point
iwconfig wlan0 essid copyninja
# Listen for DHCP and DNS on this interface
interface=wlan0
# No dhcp for this interface
no-dhcp-interface=usb0
# Domain name for a subnet
domain=copyninja.info, 192.168.1.0/24
#dhcp range
@kra3
kra3 / app.yaml
Created July 2, 2012 06:47 — forked from darktable/app.yaml
GAE: App.yaml designed for serving a static site on Google App Engine (Python). Copy your static html and files into a folder called "static" next to app.yaml. Contains a bunch of mimetype declarations from html5boilerplate's .htaccess. May not be neces
application: you-app-name-here
version: 1
runtime: python
api_version: 1
default_expiration: "30d"
handlers:
- url: /(.*\.(appcache|manifest))
mime_type: text/cache-manifest
@kra3
kra3 / setdifferencenum.sh
Created July 11, 2012 18:48
Compare two files with numbers, one number in one line: bash version
$ ## First see the one liner
$ diff -bBw total.txt coupon.txt | grep '<' | cut -d'<' -f2 | sort -nu | sed -e 's/^[ \t]*//' > result.txt
$ ## Now dissect it
$ diff -bBw total.txt coupon.txt # it will give us diff, but there is changes for both files
$ diff -bBw total.txt coupon.txt | grep '<' # numbers which are not in total but in coupon
$ diff -bBw total.txt coupon.txt | grep '<' | cut -d'<' -f2 # remove leading '<' printed by diff
@kra3
kra3 / setdifferencenum.py
Created July 11, 2012 18:56
Compare two files with numbers, one number in one line: python version
"""
# A shorter ugly version
total = set([i.strip() for i in open("total.txt").readlines()]) # list comprehension to remove \r\n from lines
coupon = set([i.strip() for i in open("coupon.txt").readlines()]) # set to remove duplicates and do set difference
open("result.txt", "w").write('\n'.join(sorted(total-coupon))) # use set difference and use sorted to sort then write in separate lines
"""
### Now see same thing above in beautiful & readable way
@kra3
kra3 / per user contribution in svn.sh
Created September 24, 2012 12:56
Script to find per user contributions from an Subversion (svn) repository.
$ svn ls -R | egrep -v -e "\/$" | xargs svn blame | awk '{print $2}' | sort | uniq -c | sort -r
$ echo "Now let's bisect the above one liner"
$ svn ls -R # will list all files in svn repo recursively
$ svn ls -R | egrep -v -e "\/$" # get files & directories one line at a time
$ svn ls -R | egrep -v -e "\/$" | xargs svn blame # do a svn blame on each file (print file content with rev & author info)
$ svn ls -R | egrep -v -e "\/$" | xargs svn blame | awk '{print $2}' # get second column which contains svn user name
$ svn ls -R | egrep -v -e "\/$" | xargs svn blame | awk '{print $2}' | sort # sort out put (will be based on svn username)
$ svn ls -R | egrep -v -e "\/$" | xargs svn blame | awk '{print $2}' | sort | uniq -c # get uniq lines with counts (no of lines contributed by user)
$ svn ls -R | egrep -v -e "\/$" | xargs svn blame | awk '{print $2}' | sort | uniq -c | sort -r # sort in reverse order (so user who contributed most comes first)
@kra3
kra3 / windows.h__.js
Created November 20, 2012 10:28
windows.h.js INFINITY
var ffi = require('ffi'),
ref = require('ref'),
Struct = require('ref-struct'),
Library = require('./Library'),
Type = ref.Type,
NULL = ref.NULL,
isNull = ref.isNull;
var groups = ['libs', 'types', 'structs', 'callbacks', 'enums'];
@kra3
kra3 / BFO.py
Created November 21, 2012 13:30
Script to generate BFO messages used in Manhattan DOM automated testing
#! env python
from xml.etree import ElementTree as ET
# read sample BFO
tree = ET.parse('BFO_Samples.xml')
# get document root
root = tree.getroot()