Skip to content

Instantly share code, notes, and snippets.

from __future__ import print_function, division
import re
import string
from collections import Counter
with open('/usr/share/dict/words', 'r') as f:
DICTIONARY = set(w.lower() for w in f.read().split())
import sys
import eventlet
from flask import Flask, render_template, request
from flask_socketio import SocketIO, emit, send, join_room, leave_room
app = Flask(__name__)
socketio = SocketIO(app)
@briehanlombaard
briehanlombaard / fitsfiles
Last active August 29, 2015 14:04
Streams .fits files to the browser using websockets.
# wget these files first by running:
# $ wget -i fitsfiles
http://spacewarps.org/subjects/raw/CFHTLS_074_2382_g.fits.fz
http://spacewarps.org/subjects/raw/CFHTLS_074_2382_i.fits.fz
http://spacewarps.org/subjects/raw/CFHTLS_074_2382_r.fits.fz
http://spacewarps.org/subjects/raw/CFHTLS_074_2382_u.fits.fz
http://spacewarps.org/subjects/raw/CFHTLS_074_2382_z.fits.fz
http://spacewarps.org/subjects/raw/CFHTLS_077_1278_g.fits.fz
http://spacewarps.org/subjects/raw/CFHTLS_077_1278_i.fits.fz
http://spacewarps.org/subjects/raw/CFHTLS_077_1278_r.fits.fz
from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^$', 'portal.views.home', name='home'),
url(r'^start', 'portal.views.start', name='authentication'),
url(r'^login', 'portal.views.login', name='login'),
url(r'^logout', 'portal.views.logout', name='logout'),
@briehanlombaard
briehanlombaard / fabfile.py
Created June 30, 2014 08:11
Basic fabric deploy script
from fabric.api import cd, run
def deploy(directory):
"""Deploys the code onto the given host by doing a `git pull`.
Deploy the code by installing fabric (pip install fabric) and running the
following command:
$ fab -H user@hostname deploy:directory=/var/www/myproject/
<?php
function pre_render_pdf($mpdf, $form_id, $lead_id, $arguments, $output, $filename) {
// XXX: We have multiple notifications setup which means this function is
// called multiple times and we end up appending the document many times. This
// will help us get around that by ensuring it's only called once.
static $has_been_called = false;
if($has_been_called) return $mpdf;
// XXX: We're only interested in the form with ID=1
#!/usr/bin/env php
<?php
/**
* A simple static site generator useful for prototyping.
*
* Example:
*
* layout.php
*
* <body><?php require($page); ?></body>
<!DOCTYPE HTML>
<html>
<head>
<style>
.chart {
background-color: #202020;
}
.chart rect {
shape-rendering: crispEdges;
stroke: none;
.gform_wrapper table.gfield_list thead th {
font-weight: normal;
text-transform: none;
}
input, textarea {
margin-bottom: 0;
}
.gform_wrapper .top_label .gfield_label {
margin-top: 20px !important;
text-transform: uppercase;
(function($) {
$('#gform_1').change(function(e) {
try {
localStorage.setItem('gform_1', JSON.stringify($(this).serializeArray()));
} catch (e) {
console.error('Local storage quota exceeded.');
}
});