Skip to content

Instantly share code, notes, and snippets.

Avatar

Bob Lannon boblannon

View GitHub Profile
@boblannon
boblannon / alliteration_bot.ipynb
Last active Apr 12, 2018
alliterative_android.ipynb
View alliteration_bot.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View PyniniIOTest-fail.txt
$ pytest -v -k PyniniIOTest
======================================================================= test session starts ========================================================================
platform darwin -- Python 2.7.14, pytest-3.5.0, py-1.5.3, pluggy-0.6.0 -- /Users/bob/analyze/geocoding_307_vocab-graph/env/bin/python2.7
cachedir: .pytest_cache
rootdir: /Users/bob/analyze/geocoding_307_vocab-graph/Pynini, inifile:
collected 158 items / 154 deselected
pynini_test.py::PyniniIOTest::testFileIO FAILED [ 25%]
pynini_test.py::PyniniIOTest::testGarbageReadRaisesFstIOError PASSED [ 50%]
pynini_test.py::PyniniIOTest::testPickleIO FAILED [ 75%]
View iterm_tab_title.sh
function tabtitle(){
REPO_NAME=`git rev-parse --show-toplevel 2> /dev/null | awk -F'/' '{print $NF}'`;
if [ -z "$REPO_NAME" ]
then
echo ""
else
echo "[$REPO_NAME] "
fi
}
if [ $ITERM_SESSION_ID ]; then
View omnihash.py
def omnihash(obj):
""" recursively hash unhashable objects """
if isinstance(obj, set):
return hash(frozenset(omnihash(e) for e in obj))
elif isinstance(obj, (tuple, list)):
return hash(tuple(omnihash(e) for e in obj))
elif isinstance(obj, dict):
return hash(frozenset((k, omnihash(v)) for k, v in obj.items()))
else:
return hash(obj)
View sampling_non-form.txt
6018211044-774
6018210841-12253
6018211039-10619
6018211039-11153
6018210827-1520
02-055-000996
6018261174-1333
6018210841-9305
6018210827-2681
6018211170-8238
@boblannon
boblannon / searching_nodes.py
Created Dec 11, 2014
searching nodes on ES index
View searching_nodes.py
from elasticsearch import Elasticsearch
es = Elasticsearch(['localhost:9201',])
def node_phrase_query(node_id, key_phrase):
qbody = {"query":
{
"bool": {
"must": [
{"match_phrase": {"text": key_phrase}},
{"match_phrase": {"clusters": node_id}}
View gist:a16a1e22e00b94904283
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-1265484-62', 'influenceexplorer.com');
ga('send', 'pageview');
ga('create', 'UA-48789618-1', 'influenceexplorer.com', {'name': 'global'});
ga('global.send', 'pageview');
View ofa_scrape_donors.py
import json
import csv
from io import StringIO
import requests
from lxml import etree
resp = requests.get('http://www.barackobama.com/contribution-disclosure/')
parsed = etree.parse(StringIO(resp.text), parser=etree.HTMLParser())
You can’t perform that action at this time.