Skip to content

Instantly share code, notes, and snippets.

@hughdbrown
hughdbrown / swing.py
Created Nov 4, 2020
2020 presidential election
View swing.py
AZ: (0.3804329085751007, 0.6195670914248993, 332493.15068493155, 541493.1506849315, -209000.00000000003)
FL: (0.6779600278494492, 0.3220399721505508, 727637.3626373624, 345637.36263736244, 381999.99999999994)
GA: (0.5798898071625344, 0.42011019283746565, 1219448.2758620693, 883448.2758620695, 335999.99999999977)
IA: (0.43084455324357407, 0.5691554467564259, 352000.0, 465000.0, -112999.99999999997)
MI: (0.5424654351109562, 0.45753456488904376, 1628720.9302325586, 1373720.9302325582, 255000.0000000003)
NC: (0.6079855936413314, 0.3920144063586686, 208319.14893617015, 134319.14893617015, 74000.00000000003)
OH: (0.6330845907837039, 0.36691540921629606, 711172.8395061726, 412172.8395061726, 299000.0)
PA: (0.5496743418035043, 0.4503256581964957, 1997333.333333333, 1636333.333333333, 361000.0)
TX: (0.5517922189231381, 0.4482077810768619, 2002944.444444445, 1626944.444444445, 375999.99999999994)
WI: (0.5267461143892939, 0.47325388561070614, 718842.105263158, 645842.105263158, 73000.00000000007)
@hughdbrown
hughdbrown / chunk.py
Created Oct 31, 2020
Chunk items into groups of size
View chunk.py
>>> def chunk(items, size):
... i, count = 0, len(items)
... for j in reversed(range(1, size + 1)):
... m, n = divmod(count, j)
... k = m + int(bool(n))
... yield items[i:i + k]
... i += k
... count -= k
...
>>> list(chunk(range(5), 5))
@hughdbrown
hughdbrown / email-gen.py
Created Sep 11, 2020
Given a first name and last name and domain, generate probable permutations for email address
View email-gen.py
#!/usr/bin/env python
import click
@click.command()
@click.option('--first')
@click.option('--last')
@click.option('--domain')
@click.option('--middle', default=None)
def main(first, last, domain, middle):
@hughdbrown
hughdbrown / github-pages-react.txt
Last active Jun 16, 2020
Github pages with react resource
View github-pages-react.txt
# Github pages
https://pages.github.com/
https://help.github.com/en/github/working-with-github-pages/setting-up-a-github-pages-site-with-jekyll
https://help.github.com/en/github/working-with-github-pages/about-github-pages
http://jmcglone.com/guides/github-pages/
https://www.npmjs.com/package/gh-pages
https://dev.to/yuribenjamin/how-to-deploy-react-app-in-github-pages-2a1f
https://medium.com/the-andela-way/how-to-deploy-your-react-application-to-github-pages-in-less-than-5-minutes-8c5f665a2d2a
https://github.com/gitname/react-gh-pages
View system-design-interview-notes.txt
System design interview framework
Sam Gavis-Hughson
1. Understand the details of the system
2. Simple high-level architecture
3. Optimize
4. ....
1. What is your interviewer asking?
@hughdbrown
hughdbrown / employment-resources.txt
Created Jun 16, 2020
Top employment practice/learning resources
View employment-resources.txt
Building and deploying web/react apps
https://mherman.org/
https://testdriven.io/
14 Patterns to Ace Any Coding Interview Question | Hacker Noon
https://hackernoon.com/14-patterns-to-ace-any-coding-interview-question-c5bb3357f6ed
Free Amazon AWS Tutorial - AWS Essentials (2019)
https://www.udemy.com/course/linux-academy-aws-essentials-2019/
View tf-idf-sample.py
from math import log
from collections import Counter
class TFIDF(object):
def __init__(self, corpus):
self.corpus = corpus
self.ndocs = len(corpus)
self.documents = [Counter(doc.split()) for doc in corpus]
self.words = sum(sum(doc.values()) for doc in self.documents)
@hughdbrown
hughdbrown / tabular-data-link.txt
Created Jun 16, 2020
Jason McGhee on tabular data with neural networks
View tabular-data-link.txt
View websockets-sample.py
import asyncio
import json
import websockets
async def subscribe_to_exchange():
async with websockets.connect('wss://ws-feed.gdax.com') as websocket:
subscribe = {
"type": "subscribe",
"product_ids": ["BTC-USD"],
"channels": ["full"]
View scalability-links.txt