Skip to content

Instantly share code, notes, and snippets.

View mynameisfiber's full-sized avatar

Micha Gorelick mynameisfiber

View GitHub Profile
@mynameisfiber
mynameisfiber / slack-term-teams
Created November 5, 2018 00:31
Launch slack-term for multiple teans in a tmux session
#!/bin/bash
_TMUX_NAME="slackterm"
function _startSlack() {
i=0
for config in $( ls ~/.slack-term/*.json ); do
if [[ "$i" -eq "0" ]]; then
TMUX="tmux new-session -d -s ${_TMUX_NAME}"
else
@mynameisfiber
mynameisfiber / word2vec_lookup.py
Created January 9, 2018 16:05
h5py file cache for word2vec model
import h5py
import os
import pickle
try:
import gensim
except ImportError:
gensim = None
@mynameisfiber
mynameisfiber / numpyqueue.py
Last active August 10, 2017 20:31
Numpy optimized multiprocessing queue
"""
Numpy-optimized multiprocessing queue object.
$ python numpyqueue.py
Array shape: 2
mp.queue: 0.4327036259928718
numpyqueue: 0.53742205198796
numpyqueue2: 0.5157967879931675
Array shape: 128
mp.queue: 1.7091998109972337
@mynameisfiber
mynameisfiber / mutually_exclusive_list_list_intervals.py
Last active June 23, 2017 00:23
Solve for the largest number of lists of intervals such that no intervals intersect.
from operator import itemgetter
def area(items):
return len(items) * sum(i[1] - i[0] for i in items)
def mutually_exclusive_list_list_intervals(data):
"""
Data is list of lists of intervals. We'd like to keep the most number of

Keybase proof

I hereby claim:

  • I am mynameisfiber on github.
  • I am mynameisfiber (https://keybase.io/mynameisfiber) on keybase.
  • I have a public key ASBkDfJJ05VdHc03nmm0n4gbzRLER35ToQa0Szku72m3bQo

To claim this, I am signing this object:

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mynameisfiber
mynameisfiber / IRIS.ipynb
Created January 12, 2017 22:34
IRIS with keras
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mynameisfiber
mynameisfiber / cnn_poll_data.py
Created November 9, 2016 19:25
Load CNN exit poll data from 2016 election into a dataframe
import pandas as pd
import ujson as json
def pct_to_int(pct):
try:
return int(pct)
except ValueError:
return 0
@mynameisfiber
mynameisfiber / ingress_codes.py
Created July 29, 2016 22:30
Extract ingress codes from the blog
from lxml import html
import requests
import re
import pickle
def get_codes(dom):
codes = set()
codes.update(_get_codes_urls(dom))
codes.update(_get_codes_alt_id(dom))
from lxml import html
import requests
import ujson as json
from tqdm import tqdm
from urllib.parse import urljoin
import re
import string