This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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 | |
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
application: you-app-name-here | |
version: 1 | |
runtime: python | |
api_version: 1 | |
default_expiration: "30d" | |
handlers: | |
- url: /(.*\.(appcache|manifest)) | |
mime_type: text/cache-manifest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ## 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! env python | |
from xml.etree import ElementTree as ET | |
# read sample BFO | |
tree = ET.parse('BFO_Samples.xml') | |
# get document root | |
root = tree.getroot() |