Skip to content

Instantly share code, notes, and snippets.

View vgoklani's full-sized avatar

Vishal Goklani vgoklani

View GitHub Profile
@mickey06
mickey06 / gist:4770903
Created February 12, 2013 16:00
Flask login with wtfoms validation
class LoginForm(flask_wtf.Form):
"""
Validate login from
"""
email_validator = [flask_wtf.Required()]
pwd_validator = [flask_wtf.Required(), flask_wtf.Length(2)]
email = flask_wtf.TextField(u'email', validators=email_validator)
password = flask_wtf.PasswordField(u'password', validators=pwd_validator)
submit = flask_wtf.SubmitField("Login")
"""
This is a simple example of WebSocket + Tornado + Redis Pub/Sub usage.
Do not forget to replace YOURSERVER by the correct value.
Keep in mind that you need the *very latest* version of your web browser.
You also need to add Jacob Kristhammar's websocket implementation to Tornado:
Grab it here:
http://gist.github.com/526746
Or clone my fork of Tornado with websocket included:
http://github.com/pelletier/tornado
Oh and the Pub/Sub protocol is only available in Redis 2.0.0:
@lbolla
lbolla / futures_test.py
Last active September 5, 2025 08:01
Tornado and concurrent.futures
from concurrent.futures import ThreadPoolExecutor
from functools import partial, wraps
import time
import tornado.ioloop
import tornado.web
EXECUTOR = ThreadPoolExecutor(max_workers=4)
@johan
johan / widgets.js
Last active December 10, 2015 19:08
2013-01-07 version of http://platform.twitter.com/widgets.js
// http://platform.twitter.com/widgets.js captured 2013-01-07
if (!window.__twttrlr) {
(function (a, b) {
function s(a) {
for (var b = 1, c; c = arguments[b]; b++) for (var d in c) a[d] = c[d];
return a
}
function t(a) {
return Array.prototype.slice.call(a)
@aelaguiz
aelaguiz / gist:4455549
Last active October 8, 2016 15:13
Quick & Dirty Theano benchmark
import numpy
import theano
import theano.tensor as T
import config
import time
def theano_softmax():
x = T.fmatrix('x')
_y = T.nnet.softmax(x)
anonymous
anonymous / gist:4365081
Created December 23, 2012 18:26
On Friday, 12/21/2012, The American Statistician published a paper by Stavros Kourouklis in which he proposed a new correction factor for estimating the standard deviation of a distribution based on a finite sample. The article describes the surprisingly simple formula for calculating the correction term and provides a proof that this formula at…
n_sims = 1_000_000
mle_se = zeros(n_sims)
unbiased_se = zeros(n_sims)
yatracos_std_se = zeros(n_sims)
kourouklis_std_se = zeros(n_sims)
for sim in 1:n_sims
n = 10
x = randn(n)
@twiecki
twiecki / ipcluster.py
Created December 10, 2012 17:03
Relevant changes to starcluster ipcluster.py code to start multiple ipython nbs on multiple ports
def _start_notebook(self, master, user, profile_dir, profile_name='default', notebook_port=8888):
master.ssh.execute('ipython profile create %s' % profile_name)
log.info("Setting up IPython web notebook for user: %s" % user)
user_cert = posixpath.join(profile_dir, '%s.pem' % user)
ssl_cert = posixpath.join(profile_dir, '%s.pem' % user)
if not master.ssh.isfile(user_cert):
log.info("Creating SSL certificate for user %s" % user)
ssl_subj = "/C=US/ST=SC/L=STAR/O=Dis/CN=%s" % master.dns_name
master.ssh.execute(
"openssl req -new -newkey rsa:4096 -days 365 "
# Simulator for the simple Boltzmann machine of Coursera NN Lecture 11e
# Christian Jauvin - cjauvin@gmail.com
from collections import defaultdict
import numpy as np
# weights
w_v1_h1 = 2
w_h1_h2 = -1
w_h2_v2 = 1
# Simulator for the simple Boltzmann machine of Coursera NN Lecture 11e
# Christian Jauvin - cjauvin@gmail.com
from collections import defaultdict
import numpy as np
# weights
w_v1_h1 = 2
w_h1_h2 = -1
w_h2_v2 = 1
# Simulator for the simple Boltzmann machine of Coursera NN Lecture 11e
# Christian Jauvin - cjauvin@gmail.com
from collections import defaultdict
import numpy as np
# weights
w_v1_h1 = 2
w_h1_h2 = -1
w_h2_v2 = 1