Skip to content

Instantly share code, notes, and snippets.

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

Utsav Sabharwal codersofthedark

🏠
Working from home
View GitHub Profile
import errno
import functools
import socket
from tornado import ioloop, web, httpserver, options
from couchbase.client import Couchbase
import json
@codersofthedark
codersofthedark / twist.py
Last active December 15, 2015 16:49
Twisted Example
from twisted.web import server, resource
from twisted.internet import reactor
class HelloResource(resource.Resource):
isLeaf = True
numberRequests = 0
def render_GET(self, request):
self.numberRequests += 1
request.setHeader("content-type", "text/plain")
@codersofthedark
codersofthedark / mserver.py
Created April 2, 2013 12:49
Couchbase and Twisted
from twisted.web import server, resource
from twisted.internet import reactor
from couchbase.client import Couchbase
couchbase = Couchbase("ubuntumartini03:8091", "martini-tag-manager", "")
bucket = couchbase["martini-tag-manager"]
class HelloResource(resource.Resource):
isLeaf = True
@codersofthedark
codersofthedark / run.sh
Last active December 15, 2015 16:59
Start two instance of tornado server
t=$(date +%s)
s=3600
t=$(expr $t - $s)
filename="analytics.log."$(date -d @$t +%Y-%m-%d_%H)
echo $filename
networkfilename=$(date +%Y%m%d%H)-$(hostname).log
echo $networkfilename
python mtornado.py &
sleep 3900
while true; do
@codersofthedark
codersofthedark / ngin.conf
Created April 8, 2013 07:42
Nginx config
# primary server - proxypass to Django
server {
listen 80;
server_name dev.testproject.com;
access_log off;
error_log off;
# proxy to Apache 2 and mod_python
location / {
#SETUP Instructions on ec2 machine
1. ssh into tornado machine
2. Run following commands:
sudo apt-get isntall pip
sudo pip install couchbase
sudo pip install tornado
3. fetch code from repository or copy paste
#HOW to START tornado?
Run following commands in mtornado folder:
transaction,item
440081,Drama
440081,Romance
440082,Drama
440083,Drama
440083,Romance
440084,Short
440085,Drama
440086,Drama
440089,Action
<?xml version="1.0"?>
<PMML version="4.1" xmlns="http://www.dmg.org/PMML-4_1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.dmg.org/PMML-4_1 http://www.dmg.org/v4-1/pmml-4-1.xsd">
<Header copyright="Copyright (c) 2013 super-computer" description="arules association rules model">
<Extension name="user" value="super-computer" extender="Rattle/PMML"/>
<Application name="Rattle/PMML" version="1.2.34r27"/>
<Timestamp>2013-06-19 20:39:58</Timestamp>
</Header>
<DataDictionary numberOfFields="2">
<DataField name="transaction" optype="categorical" dataType="string"/>
<DataField name="item" optype="categorical" dataType="string"/>
#!/usr/bin/env python
# Copyright (C) 2006-2013 Open Data ("Open Data" refers to
# one or more of the following companies: Open Data Partners LLC,
# Open Data Research LLC, or Open Data Capital LLC.)
#
# This file is part of Augustus.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
import requests
key = "X-CT-API-KEY"
value = "13465408b353ba36ca5fd2dfa5246ef3"
url = "http://api.staging.cleartrip.com/air/1.0/search?from=BOM&to=DEL&depart-date=2013-09-09&return-date=2013-12-12"
headers = {key: value}
r = requests.get(url, headers=headers)
print r