Skip to content

Instantly share code, notes, and snippets.


James J Porter porterjamesj

Block or report user

Report or block porterjamesj

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
We couldn’t find that file to show.
View soundcloud-dl.js
var system = require('system');
var fs = require("fs");
function scroller(eofSelector, cb, wait) {
var done = page.evaluate(function (s) {
return document.querySelector(s);
}, eofSelector);
if(done === null) {
page.evaluate(function() {
window.scroll(0, document.body.scrollHeight);
porterjamesj /
Last active Sep 14, 2016
Tiny shell written for a workshop at Recurse Center.
Small description:
What it does:
1. first this
2. then this
import sys
import os
porterjamesj /
Last active Aug 29, 2015
flask request close insanity
import time
from flask import Flask, Response, current_app
class Stream(object):
def __init__(self, string):
self.bytes = 0
self.string = string
porterjamesj /
Last active Mar 6, 2018
the tiniest mesos scheduler
import logging
import uuid
import time
from mesos.interface import Scheduler
from mesos.native import MesosSchedulerDriver
from mesos.interface import mesos_pb2
porterjamesj /
Last active Aug 29, 2015
tiny echo server with asyncio
import asyncio
def server_callback(reader, writer):
while True:
data = yield from reader.readline()
yield from asyncio.sleep(1)
yield from writer.drain()
porterjamesj / async.jl
Created Oct 28, 2014
demonstration that Julia task-switching happens only when a task has to wait on IO
View async.jl
function do_computation_then_print(message::String)
sum = 1
for i = 1:(rand() * 10^7)
sum *= i
# print out the sum so the compiler doesn't elide the loop
print("$message: $sum\n")
View first_try.jl
using BinDeps
gumbo = library_dependency("libgumbo")
porterjamesj /
Created Jun 11, 2014
fun exercise from programming praxis
def balanced(s):
raise NotImplementedError("Implement me!")
def test():
for s in ["{}", "[]", "()", "a(b)c", "abc[d]", "a(b)c{d[e]}"]:
assert balanced(s)
for s in ["{]", "(]", "a(b]c", "abc[d}", "a(b)c{d[e}"]:
assert not balanced(s)
porterjamesj / gumbo_example.c
Created May 3, 2014
just a small example of using google's gumbo for html parsing
View gumbo_example.c
#include <stdio.h>
#include "gumbo.h"
int main() {
GumboOutput* output = gumbo_parse("<h1>Hello, World!</h1>");
// Gumbo inserts all the html, body, etc.
GumboNode *html = output->root;
GumboNode *body = (GumboNode *) html->[1];
GumboNode *header = (GumboNode *) body->[0];
GumboNode *text = (GumboNode *) header->[0];
You can’t perform that action at this time.