Skip to content

Instantly share code, notes, and snippets.

View jineshpaloor's full-sized avatar

Jinesh Panampattakunnath jineshpaloor

View GitHub Profile
@jineshpaloor
jineshpaloor / lda_distributed.sh
Last active September 3, 2015 12:06
steps to follow to run gensim lda in distributed systems
# run name server
python -m Pyro4.naming -n 0.0.0.0 &
# run lda worker (2 times)
python -m gensim.models.lda_worker > data/worker1.log 2>&1 &
# run lda dispatcher
python -m gensim.models.lda_dispatcher > data/dispatcher.log 2>&1 &
# run the script (client) on any server
@jineshpaloor
jineshpaloor / unicode.py
Created August 25, 2015 05:15
How to fix UnicodeEncodeError
x.decode('unicode_escape').encode('ascii','ignore').strip()
l = [(4, 0.77934753372889531), (5, 0.015453136410995202), (10, 0.011590313514229672), (11, 0.045544605654325734), (21, 0.029156758738699304), (27, 0.072722275712552756)]
sorted(l, key=lambda x: x[1], reverse=True)
output:
Out[3]:
[(4, 0.7793475337288953),
(27, 0.07272227571255276),
(11, 0.045544605654325734),
(21, 0.029156758738699304),
(5, 0.015453136410995202),
@jineshpaloor
jineshpaloor / namespace.js
Last active August 29, 2015 14:27
Javascript Namespace example
/** This will be our global, topmost level namespace */
var NS = NS || { };
NS.ie = function(){ return navigator.userAgent.indexOf('MSIE') != -1; }
/** This is the skeleton for the module. Copy this to start with a new module */
NS.skeletonModule = (function () {
// define some config (Settings)
var config = {
autoInvokeInit: false, // whether the init function must be invoked automatically when page loads
./stardog query --reasoning foafDB "PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?name
WHERE {
?person foaf:name ?name .
}
"
# example: A part from a owl / rdf
<rdf:Description rdf:about="http://dig.csail.mit.edu/2008/webdav/timbl/foaf.rdf#dj">
<rdf:type rdf:resource="http://xmlns.com/foaf/0.1/Person"/>
@jineshpaloor
jineshpaloor / SNARLAddData.java
Last active August 29, 2015 14:25 — forked from mhgrove/SNARLAddData.java
Example of how to use the native Stardog API, SNARL
aConn.begin();
aConn.add().io()
.format(RDFFormat.N3)
.stream(new FileInputStream("data/sp2b_10k.n3"));
Graph aGraph = Graphs.newGraph(ValueFactoryImpl.getInstance()
.createStatement(ValueFactoryImpl.getInstance().createURI("urn:subj"),
ValueFactoryImpl.getInstance().createURI("urn:pred"),
ValueFactoryImpl.getInstance().createURI("urn:obj")));
@jineshpaloor
jineshpaloor / youtube-dl.sh
Created July 22, 2015 08:38
youtube downloader shell commands
# download video
~ youtube-dl https://www.youtube.com/watch?v=OPf0YbXqDm0
# extract audio
~ youtube-dl --extract-audio --audio-format mp3 url
~ youtube-dl --extract-audio --audio-format mp3 https://www.youtube.com/watch?v=OPf0YbXqDm0
class Rule(object):
def __init__(self, name):
self.name = name
def __str__(self):
return 'Iam Rule :{0}'.format(self.name)
class Game(object):
def __init__(self, rule):

Mac OS X 10.10 Yosemite

Custom recipe to get OS X 10.10 Yosemite running from scratch, setup applications and developer environment. I use this gist to keep track of the important software and steps required to have a functioning system after a semi-annual fresh install. On average, I reinstall each computer from scratch every 6 months, and I do not perform upgrades between distros.

This keeps the system performing at top speeds, clean of trojans, spyware, and ensures that I maintain good organizational practices for my content and backups. I highly recommend this.

You are encouraged to fork this and modify it to your heart's content to match your own needs.

Install Software

select s.pincode,dsc.center_name AS destination, count(airwaybill_number) as volume from service_centre_shipment s inner join location_servicecenter dsc on dsc.id = s.original_dest_id where rts_status<>1 and s.reverse_pickup=0 and dsc.center_shortcode in ('BOV', 'BOK', 'BOW', 'BMR', 'BHI','MBY', 'BOD', 'NBM', 'BOL', 'BDV', 'BOG', 'BOC', 'BAB', 'BKY', 'THN', 'VSI', 'SUB', 'SUA') and shipment_date between '2015-05-01' and '2015-06-30' group by s.pincode, dsc.center_name into outfile '/tmp/mumbai_volumes.csv' fields terminated by ',' optionally enclosed by '"' lines terminated by '\n';