Skip to content

Instantly share code, notes, and snippets.

View nathan-heskia's full-sized avatar

Nathan Heskia nathan-heskia

View GitHub Profile

Keybase proof

I hereby claim:

  • I am nathan-heskia on github.
  • I am nathanheskia (https://keybase.io/nathanheskia) on keybase.
  • I have a public key ASCYkMAEXN6RSBC0DfSh1379NzPYGoIAhLewZtyHeXFeHAo

To claim this, I am signing this object:

@nathan-heskia
nathan-heskia / websocketechoclient.py
Last active January 8, 2022 19:53
Following the Websocket protocol with a Python TCP socket
import base64
import random
import socket
import ssl
import time
import sys
import _thread
opcodes = {
'continuation': 0,
@nathan-heskia
nathan-heskia / addmul.py
Last active January 19, 2018 07:53
Create an interpreter for the grammar "expression := integer | ( function expression expression )"
# Something I got too nervous doing in an interview
import re
def evalexpr(expr):
name, operands = expr[0], map(lambda x : int(x), expr[1:])
if name == 'add':
return reduce(lambda x, y : x + y, operands, 0)
elif name == 'mul':
return reduce(lambda x, y : x * y, operands, 1)