Skip to content

Instantly share code, notes, and snippets.

View grantjenks's full-sized avatar

Grant Jenks grantjenks

View GitHub Profile
@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:

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 / 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
@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 / 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 / bottlebench.py
Last active October 28, 2021 18:00
Server-side I/O Performance in Python
"""Server-side I/O Performance in Python
Based on the article and discussion at:
https://www.toptal.com/back-end/server-side-io-performance-node-php-java-go
The code was posted at:
https://peabody.io/post/server-env-benchmarks/
@grantjenks
grantjenks / base.css
Created October 26, 2022 06:12
Basic CSS styling for HTML webpages.
html {
max-width: 70ch;
padding: calc(1vmin + .5rem);
margin-inline: auto;
font-size: clamp(1em, 0.909em + 0.45vmin, 1.25em);
font-family: system-ui;
}
body {
line-height: 1.6;
}
@grantjenks
grantjenks / ffmpeg-notes.txt
Created October 28, 2022 05:21
ffmpeg commands to convert video files
# Convert .m4v to .mp4
$ ffmpeg -i input.m4v -c:v libx264 -c:a aac output.mp4
# Convert .mp4 to .webm
$ ffmpeg -i input.mp4 -c:v libvpx-vp9 -crf 30 -b:v 0 -b:a 128k -c:a libopus output.webm
@grantjenks
grantjenks / fizzbuzz.py
Created January 16, 2023 21:40
FizzBuzz
from itertools import cycle, slice
fizz = cycle('', '', 'fizz')
buzz = cycle('', '', '', '', 'buzz')
pairs = zip(fizz, buzz)
for pair in slice(pairs, 30):
print(' '.join(pair))
@grantjenks
grantjenks / dotfiles-management.md
Created January 17, 2023 01:35
Dotfiles Management