This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| 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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from concurrent.futures import ThreadPoolExecutor | |
| from functools import partial, wraps | |
| import time | |
| import tornado.ioloop | |
| import tornado.web | |
| EXECUTOR = ThreadPoolExecutor(max_workers=4) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 " |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |