Skip to content

Instantly share code, notes, and snippets.

View guptarohit's full-sized avatar
🎯
Focusing

Rohit Gupta guptarohit

🎯
Focusing
View GitHub Profile
#!/usr/bin/env python3
#
# Copyright (c) 2015 Leandro Pereira de Lima e Silva
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# by fcicq <fcicq@fcicq.net>, 2013.4.7, GPLv2
# Tornado 3.0 is required.
from tornado.websocket import websocket_connect, WebSocketClientConnection
from tornado.ioloop import IOLoop
from datetime import timedelta
#echo_uri = 'ws://echo.websocket.org'
echo_uri = 'ws://ws.blockchain.info/inv'
PING_TIMEOUT = 15
class myws():
@sirleech
sirleech / gist:5055971
Last active October 2, 2017 06:59
web.py example with a few URLs and a JSON web service. Installed as mod_wsgi on apache, see conf at https://gist.github.com/sirleech/5055976
import web
import json
urls = (
'/', 'index',
'/random', 'random',
'/dump', 'dump'
)
height = 7
width = 7
board_spaces_occupied = [
[ 1, 0, 1, 1, 1, 0, 0],
[ 1, 1, 0, 1, 1, 0, 1],
[ 1, 1, 1, 1, 0, 0, 1],
[ 1, 0, 1, 0, 1, 1, 1],
[ 1, 0, 0, 1, 1, 1, 1],
[ 0, 0, 1, 0, 0, 1, 1],
[ 0, 1, 1, 0, 1, 1, 1],
@Orbifold
Orbifold / LinearRegressionThreeWays.ipynb
Created November 4, 2016 06:12
Standard linear regression using TensorFlow, TFLearn and sklearn.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import concurrent.futures
import functools
import operator
import time
from pprint import pprint
TEXT = """Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis.
Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.
Donec nec justo eget felis facilisis fermentum. Aliquam porttitor mauris
@cgbystrom
cgbystrom / node.js vs Python
Created December 1, 2010 20:56
node.js vs Python with Greenlets
/*
node.js vs Python with Greenlets (say gevent)
I don't get why node.js is being so hyped.
Sure, the idea of writing things in JavaScript both on the client and server-side is really nice.
And JavaScript really fit an event-driven environment with its browser heritage.
But why on earth is boomerang code so appealing to write? I don't get. Am I missing something obvious?
All examples of node.js I see are littered with callbacks yet Ryan Dahl thinks coroutines suck. It doesn't add up for me.
@barthr
barthr / action.go
Last active July 22, 2018 16:42
Wrapper for clean handlers in Go
package web
import (
"bytes"
"encoding/json"
"io"
"net/http"
)
type errorResponse struct {
import tensorflow as tf
import numpy as np
NUM_STATES = 10
NUM_ACTIONS = 2
GAMMA = 0.5
def hot_one_state(index):
array = np.zeros(NUM_STATES)
@frankV
frankV / app.py
Last active February 14, 2019 07:10 — forked from mmautner/app.py
Example of caching API results w/ Flask-Restless and Flask-Cache
import json
import hashlib
from flask import Flask, request
import flask.ext.sqlalchemy
import flask.ext.cache
import flask.ext.restless
from flask.ext.restless import ProcessingException
app = Flask(__name__)
app.config['DEBUG'] = True