This file contains 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 socket | |
import network | |
import time | |
CONTENT = b"""\ | |
HTTP/1.0 200 OK | |
<!doctype html> | |
<html> |
This file contains 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 nltk | |
from summa.keywords import keywords | |
def get_features(text): | |
# get the top 80% of the phrases from the text, scored by relevance | |
return dict(keywords(text, ratio=0.8, split=True, scores=True)) | |
def train_texts(classified_texts): | |
# process the training set | |
features = [] |
This file contains 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 Config(object): | |
def __init__(self, **entries): | |
self.__dict__.update(entries) | |
self._entries = entries | |
def __repr__(self): | |
return "Config(%s)" % str(self._entries) | |
def __getattr__(self, value): | |
return None |
This file contains 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
const WebSocket = require('ws'); | |
const PythonShell = require('python-shell'); | |
const tmp = require('tmp'); | |
const shortid = require('shortid'); | |
const fs = require('fs'); | |
const mkdirp = require('mkdirp'); | |
// TODO clean up code, error handling, watchdog timer | |
const wss = new WebSocket.Server({ port: 8080 }); |
This file contains 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
infinity = float("inf") | |
def argmin(seq, fn): | |
"""Return an element with lowest fn(seq[i]) score; tie goes to first one. | |
>>> argmin(['one', 'to', 'three'], len) | |
'to' | |
""" | |
best = seq[0]; best_score = fn(best) | |
for x in seq: | |
x_score = fn(x) |
This file contains 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
#!/usr/bin/env python | |
import pyrax | |
pyrax.set_setting('identity_type', 'rackspace') | |
pyrax.set_credentials(RACKSPACE_API_USER, RACKSPACE_API_KEY, region='SYD') | |
def server_list_generator(detailed=True, search_opts=None, limit=None): | |
servers = pyrax.cloudservers.servers.list(detailed=detailed, | |
search_opts=search_opts, |
This file contains 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
const ContrastTools = { | |
relLuminance(rgba) { | |
// http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef | |
var rgb = rgba.slice(); | |
for (var i = 0; i < 3; i++) { | |
var channel = rgb[i] / 255; | |
rgb[i] = channel < .03928 ? channel / 12.92 : Math.pow((channel + .055) / 1.055, 2.4); | |
} |
This file contains 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
var Multipart = { | |
parse: (function() { | |
function Parser(arraybuf, boundary) { | |
this.array = arraybuf; | |
this.token = null; | |
this.current = null; | |
this.i = 0; | |
this.boundary = boundary; | |
} |
This file contains 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
{ | |
"name": "http-exec", | |
"version": "1.0.0", | |
"description": "Command Execution Server", | |
"main": "server.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1", | |
"start": "node server.js" | |
}, | |
"author": "David Collien", |
This file contains 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
<!DOCTYPE html> | |
<head> | |
<script> | |
var start_indicator = 'START'; | |
var lineNum = 0; | |
var render = function(newData) { | |
var content = ''; | |
newData = newData.replace(/^\s+|\s+$/g, ''); | |
if (newData === '') return ''; | |
var lines = newData.split('\\n'); |