Skip to content

Instantly share code, notes, and snippets.

@hughdbrown
hughdbrown / employment-resources.txt
Created June 16, 2020 14:25
Top employment practice/learning resources
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/
@hughdbrown
hughdbrown / tf-idf-sample.py
Created June 16, 2020 14:24
TF-IDF sample code
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 June 16, 2020 14:23
Jason McGhee on tabular data with neural networks
@hughdbrown
hughdbrown / websockets-sample.py
Created June 16, 2020 14:21
websockets sample code
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"]
# Websockets
https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_client_applications
# Michael Herman
https://mherman.org/
https://testdriven.io/
# Asyncio in python
https://www.integralist.co.uk/posts/python-asyncio/
@hughdbrown
hughdbrown / recommended-coursera.txt
Last active June 16, 2020 14:38
Recommended coursera courses
@hughdbrown
hughdbrown / useful_python.txt
Created June 15, 2020 22:42
Useful python libraries and imports
bisect: bisect_left and bisect_right
itertools: tee, count, accumulate, chain, groupby; takewhile, dropwhile
collections: defaultdict, Counter, deque; namedtuple, ChainMap useful for applications
heapq: heapify, heappush, heappop
functools: reduce, partial
@hughdbrown
hughdbrown / fenwick.py
Created June 15, 2020 22:41
Fenwick tree
from typing import List
class FenwickTree(object):
def __init__(self, n):
self.t = [1] * (n + 1)
self.n = n
self.d = {i: (i & (-i)) for i in range(n)}
self.build(self.t)
#
def build(self, t: List[int]):
@hughdbrown
hughdbrown / count_stable_particles.py
Last active September 1, 2021 02:47
Come sort of code challenge
from itertools import groupby
def cumulative(arr):
return [arr[i] - arr[i - 1] for i in range(1, len(arr))]
def stable_particle(arr):
"""
>>> stable_particle([-1, 1, 3, 3, 3, 2, 3, 2, 1, 0])
5