Skip to content

Instantly share code, notes, and snippets.

View grantjenks's full-sized avatar

Grant Jenks grantjenks

View GitHub Profile
@grantjenks
grantjenks / tcp_proxy.py
Created March 14, 2021 18:34
Simple TCP Proxy
"""Simple TCP Proxy
Receive connections on one port and forward them to another port.
Example:
$ python3 -m http.server 8080 # Start an http server on port 8080
$ python3 tcp_proxy.py 5000 8080 # Proxy port 5000 to 8080
Open http://localhost:5000/ in Chrome
@grantjenks
grantjenks / mutable_namedtuple_comparison.py
Created December 20, 2016 19:17
Performance Comparison of namedtuple, namedlist, and recordclass
import sys
class Record(object):
__slots__ = ()
def __init__(self, *args):
assert len(self.__slots__) == len(args)
for field, value in zip(self.__slots__, args):
setattr(self, field, value)
@grantjenks
grantjenks / reboot.service
Created May 3, 2020 20:28
Weekly reboots using systemd.
# /etc/systemd/system/reboot.service
[Unit]
Description=Reboot Service
[Service]
Type=oneshot
ExecStart=/bin/systemctl --force reboot

Stevey's Google Platforms Rant

I was at Amazon for about six and a half years, and now I've been at Google for that long. One thing that struck me immediately about the two companies -- an impression that has been reinforced almost daily -- is that Amazon does everything wrong, and Google does everything right. Sure, it's a sweeping generalization, but a surprisingly accurate one. It's pretty crazy. There are probably a hundred or even two hundred different ways you can compare the two companies, and Google is superior in all but three of them, if I recall correctly. I actually did a spreadsheet at one point but Legal wouldn't let me show it to anyone, even though recruiting loved it.

I mean, just to give you a very brief taste: Amazon's recruiting process is fundamentally flawed by having teams hire for themselves, so their hiring bar is incredibly inconsistent across teams, despite various efforts they've made to level it out. And their operations are a mess; they don't real

@grantjenks
grantjenks / make_groups.py
Last active November 23, 2017 00:50
Make Groups
"""Make Groups
# Problem
https://www.reddit.com/r/Python/comments/7awlm1/
I am a teacher and every year we have overnight excursions where we have to
organize rooms for around 100 students however there are a number of
requirements when organise these rooms: