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
@jacobbridges
jacobbridges / Track-PHP-Execution-Time.php
Last active August 29, 2015 14:08
Track PHP Execution Time
<?php
// The 'microtime' code can be included in any method or application to track the script run time.
function test()
{
// Get the (negative) current UNIX timestamp in milliseconds
$time = -microtime(true);
// Run some code
$hash = 0;
@jacobbridges
jacobbridges / find_open_ports.sh
Created November 6, 2014 20:05
Ubuntu find all busy ports
netstat -ntlp | grep LISTEN
@jacobbridges
jacobbridges / analyze.py
Last active August 29, 2015 14:12
Obama Speech Text Analysis
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:
@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")
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',
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()
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);
# I don't even know where to begin.
@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."""