Skip to content

Instantly share code, notes, and snippets.

View jacobbridges's full-sized avatar
🪐
Looking for it..

Jacob Bridges jacobbridges

🪐
Looking for it..
View GitHub Profile
from theading import Thread
class StoppableThread(Thread):
"""A thread which can be stopped from thread reference."""
do_run = True
def stop(self):
"""Stop this thread."""
self.do_run = False
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jacobbridges
jacobbridges / async_code.py
Created January 26, 2017 20:05
Testing async code
class PersonClass(object):
def __init__(self, name=None, cursor=None):
"""Constructor for PersonClass."""
self.name = name
self.cursor = cursor
self.insert_sql = 'INSERT INTO person VALUES ?;'
async def create(self):
"""Persist the person to the database."""
# I don't even know where to begin.
var express = require('express');
var app = express();
// Create a route for the base endpoint
app.get('/', (req, res) => {
res.send('Hello World!');
});
// Run the server
app.listen(3000, () => null);
from flask import Flask
app = Flask(__name__)
# Create a route for the base endpoint
@app.route("/")
def hello():
return "Hello World!"
# Run the server
app.run()
import json
import asyncio
from aiohttp import web, get
async def hello(request: web.Request):
print(request.headers)
return web.Response(
body=bytes(json.dumps(dict(
name='veggiecron-server',
author='Jacob Bridges',
@jacobbridges
jacobbridges / analyze3.py
Last active August 29, 2015 14:12
Obama Speech Text Analysis 3
import re
from collections import Counter
SPEECH_TO_PROCESS = "Year End Press Conference -- (12-19-2014).txt"
# Open speech document
with open(SPEECH_TO_PROCESS, "r") as SPEECH_FILE:
# Read speech text into variable, converting any pesky unicode characters
speech = SPEECH_FILE.read().decode('utf8').encode("ascii", "ignore")
@jacobbridges
jacobbridges / analyze2.py
Last active August 29, 2015 14:12
Obama Speech Text Analysis 2
import re
from collections import Counter
SPEECH_TO_PROCESS = "Year End Press Conference -- (12-19-2014).txt"
IGNORE_WORDS = ["a", "an", "the", "and", "that", "is", "are", "were", "be", "be", "being", "been", "have", "has", "had", "do", "does", "did", "not", "it", "they", "its", "aboard", "about", "above", "across", "after", "against", "along", "amid", "among", "anti", "around", "as", "at", "before", "behind", "below", "beneath", "beside", "besides", "between", "beyond", "but", "by", "concerning", "considering", "despite", "down", "during", "except", "excepting", "excluding", "following", "for", "from", "in", "inside", "into", "like", "minus", "near", "of", "off", "on", "onto", "opposite", "outside", "over", "past", "per", "plus", "regarding", "round", "save", "since", "than", "through", "to", "toward", "towards", "under", "underneath", "unlike", "until", "up", "upon", "versus", "via", "with", "within", "without"]
# Open speech document
with open(SPEECH_TO_PROCESS, "r") as SPEECH_FILE: