Skip to content

Instantly share code, notes, and snippets.

View ChicagoDev's full-sized avatar
🇺🇸

Blake Gideon ChicagoDev

🇺🇸
View GitHub Profile
#All parts not labeled BJG were written by Chris Kief <http://bit.ly/1sUHJ8f>
# install and select
sudo port install postgresql93-server
sudo port select --set postgresql postgresql93
# load at startup
sudo port load postgresql93-server
#All parts not labeled BJG were written by Chris Kief <http://bit.ly/1sUHJ8f>
# install and select
sudo port install postgresql93-server
sudo port select --set postgresql postgresql93
# load at startup
sudo port load postgresql93-server
@ChicagoDev
ChicagoDev / gist:b5332d47a2b970a312ca
Created March 6, 2015 19:58
Formatting parentheses in Sed
# needs to be executed with the expanded REGEX synatax -E flag
# sed -Ef script.sed parenthesesFile.txt
s/ *\(/ \(/g;
s/\) */\) /g;
s/\(\)/\( \)/g;
s/\(\(/\( \(/g;
s/\)\)/\) \)/g;
s/\(([a-zA-Z0-9])/( \1/g;
s/([a-zA-Z0-9])\(/\1 (/g;
@ChicagoDev
ChicagoDev / basic_json.php
Last active August 29, 2015 14:17
A quick example of communication with JSON over HTTP using PHP
<?php
/**
* Created by PhpStorm.
* User: Blake Gideon
* Date: 3/14/15
* Time: 7:34 PM
*/
$incoming_post = file_get_contents("php://input");
$incoming_post = json_decode($incoming_post, true);
@ChicagoDev
ChicagoDev / remove-openssl-cronjob.sh
Last active August 29, 2015 14:17
Potential Cron Script To Remove Annoying Cron Job
#!/bin/bash
# The skeleton of a script which checks to see if brew's openssl was uninstalled. If it was uninstalled,
# remove the cron job which sends the buggy email every hour. Additionally remove the cronjob which will be
# running this script itself.
if [ -f /usr/local/Cellar/openssl-osx-ca/1.0.3/bin/openssl-osx-ca]
then
exit 0
else
(crontab -l | grep -v openssl-osx-ca) | crontab -
#(crontab -l | grep -v remove-openssl-cronjob | crontab -
@ChicagoDev
ChicagoDev / isConnected.java
Last active August 29, 2015 14:27
Checking for internet connectivity on Android
ConnectivityManager connMgr = (ConnectivityManager)
getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
if (networkInfo != null && networkInfo.isConnected()) {
Log.d("MyActivity","Internet Connection Available");
} else {
Log.e("MyActivity","No internet connection");
}
//Source: http://developer.android.com/training/basics/network-ops/connecting.html
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:15455 0.0.0.0:* LISTEN -
tcp6 0 0 :::22 :::* LISTEN 7/micro-inetd
@ChicagoDev
ChicagoDev / avg.awk
Created April 11, 2018 20:57 — forked from jamerfort/avg.awk
Awk scripts for total/average/max/min. All numbers come in on STDIN
#!/usr/bin/awk -f
BEGIN { TOTAL=0 }
{ TOTAL = TOTAL + $1 }
END { print TOTAL/NR }
{
"_id" : ObjectId("5c75b350fc0c4b23785abcce"),
"name" : "Tom Hanks",
"url" : "https://en.wikipedia.org/wiki/Tom_Hanks",
"wiki_doc" : "American actor and producer This article is about the American actor. For the seismologist, see Thomas C. Hanks. \n Tom HanksHanks in September 2016BornThomas Jeffrey Hanks (1956-07-09) July 9, 1956 (age 62)Concord, California, U.S.ResidenceLos Angeles, California, U.S.Alma materChabot CollegeCalifornia State University, Sacramento (BFA)OccupationActor, filmmakerYears active1977–presentWorksPerformancesNet worth$390 million (May 2014)[1]Political partyDemocraticSpouse(s)Samantha Lewes(m. 1978; div. 1987)Rita Wilson (m. 1988)Children4, including Colin HanksRelativesJim Hanks (brother)Larry Hanks (brother)AwardsFull list Thomas Jeffrey Hanks (born July 9, 1956) is an American actor and filmmaker. Hanks is known for his comedic and dramatic roles in such films as Splash (1984), Big (1988), Turner & Hooch (1989), A League of Their Own (1992), Sleepless in Seattle (
from collections import namedtuple
CastMatch = namedtuple('CastMatch', 'role playedby cosine_dist')
def best_match(got_roles_list, clust_dict, vectorizer, topic_model, cluster_model):
matches = []
for person in got_roles_list: