Skip to content

Instantly share code, notes, and snippets.

View cjgiridhar's full-sized avatar

Chetan Giridhar cjgiridhar

View GitHub Profile
@cjgiridhar
cjgiridhar / file3.txt
Created April 9, 2016 13:13
the description for this gist
String file contents
@cjgiridhar
cjgiridhar / file3.txt
Created April 9, 2016 13:12
the description for this gist
String file contents
@cjgiridhar
cjgiridhar / file3.txt
Created April 9, 2016 13:11
the description for this gist
String file contents
@cjgiridhar
cjgiridhar / file3.txt
Created April 9, 2016 13:11
the description for this gist
String file contents
@cjgiridhar
cjgiridhar / file3.txt
Created April 9, 2016 13:10
the description for this gist
String file contents
import tornado.httpclient
import tornado.ioloop
import tornado.web
import tornado.websocket
import tornado.template
import tornado.gen
import tornado.autoreload
import time, json
import tornado.httpserver
@cjgiridhar
cjgiridhar / asyncio_parallel.py
Created September 21, 2014 06:12
AsyncIO Parallel
import asyncio
@asyncio.coroutine
def factorial(name, number):
f = 1
for i in range(2, number+1):
print("Task %s: Compute factorial(%s)..." % (name, i))
yield from asyncio.sleep(1)
f *= i
print("Task %s: factorial(%s) = %s" % (name, number, f))
@cjgiridhar
cjgiridhar / tornadogenex.py
Created September 17, 2014 06:04
Tornado Gen Coroutine
import tornado.web
import tornado.gen
from tornado.httpclient import AsyncHTTPClient
class GenAsyncHandler(tornado.web.RequestHandler):
@tornado.gen.coroutine
def get(self):
http_client = AsyncHTTPClient()
response = yield http_client.fetch("http://ip.jsontest.com")
print(response)
@cjgiridhar
cjgiridhar / tornadoasyncex.py
Created September 17, 2014 05:35
Tornado Async Example
import tornado.ioloop
from tornado.httpclient import AsyncHTTPClient
def handle_request(response):
'''callback needed when a response arrive'''
if response.error:
print("Error:", response.error)
else:
print('called')
print(response.body)
@cjgiridhar
cjgiridhar / hello.js
Last active December 14, 2015 06:49
Express - helloworld example
var express = require('express');
var appln = express();
appln.get('/', function(request, response){
response.set('Content-Type', 'text/plain');
response.send('hello world');
});
appln.listen(3000);
appln.set('Hello', 'Express Node');