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 /
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 /
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 /
Last active December 15, 2015 16:59
Start two instance of tornado server
t=$(date +%s)
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 &
sleep 3900
while true; do
codersofthedark / ngin.conf
Created April 8, 2013 07:42
Nginx config
# primary server - proxypass to Django
server {
listen 80;
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:
<?xml version="1.0"?>
<PMML version="4.1" xmlns="" xmlns:xsi="" xsi:schemaLocation="">
<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>
<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 = ""
headers = {key: value}
r = requests.get(url, headers=headers)
print r