Skip to content

Instantly share code, notes, and snippets.

Avatar
💡
coding

Charles Thayer cgthayer

💡
coding
View GitHub Profile
View 20111011_SteveYeggeGooglePlatformRant.md

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

@cgthayer
cgthayer / env-pkg.sh
Last active May 27, 2020
Env Pkg: Package your shell environment
View env-pkg.sh
#!/bin/bash -
#
# env-pkg: Environment Packager -- super simple, see Usage below
#
# by: Charles Thayer <thayer@mediabridge.com>
cd $HOME
ENVPKG_RSH=${ENVPKG_RSH:-ssh}
ENVDIR=env-pkg
@cgthayer
cgthayer / latency.txt
Created Apr 25, 2020 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
View latency.txt
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
View gist:a933120dbe0ade4880867c5a67310efa
$ python manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
Applying contenttypes.0001_initial… OK
Applying auth.0001_initial… OK
Applying admin.0001_initial… OK
Applying admin.0002_logentry_remove_auto_add… OK
Applying contenttypes.0002_remove_content_type_name… OK
Applying auth.0002_alter_permission_name_max_length… OK
View gist:a43786a447527e0c8b9afb5cd69c91d2
$ pip install django
$ django-admin startproject myproj
$ cd myproj
$ django-admin startapp myapp
$ export DJANGO_SETTINGS_MODULE=myproj.settings
$ django-admin runserver
Performing system checks…
System check identified no issues (0 silenced).
February 11, 2020–05:12:45
Django version 1.11.9, using settings 'myproj.settings'
View gist:65dfac47460d8e9f449b5c128d903c58
s = """Gur Mra bs Clguba, ol Gvz Crgref
Ornhgvshy vf orggre guna htyl.
Rkcyvpvg vf orggre guna vzcyvpvg.
Fvzcyr vf orggre guna pbzcyrk.
Pbzcyrk vf orggre guna pbzcyvpngrq.
Syng vf orggre guna arfgrq.
Fcnefr vf orggre guna qrafr.
Ernqnovyvgl pbhagf.
Fcrpvny pnfrf nera'g fcrpvny rabhtu gb oernx gur ehyrf.
View django-drf-cheatsheet.md

Django DRF Cheat Sheet

Django Rest Framework

Overview:

    http request --> url_route --> view --> serializer --> data-dict response
@cgthayer
cgthayer / gist:25aa97bb4b74efb75e3467fb7bbdaacb
Last active May 27, 2019
Django: check what would be deleted when I delete an object, using a transaction
View gist:25aa97bb4b74efb75e3467fb7bbdaacb
>>> from django.db import transaction
>>> transaction.set_autocommit(autocommit=False)
>>> o = Organization_v2.objects.get(name='pdemo')
>>> del_info = o.delete()
>>> del_info
(1404, {'data.Property': 408, [..more stuff..], 'data.Organization_v2': 1})
>>> Property.objects.filter(scope__organization_id=o).count()
0
>>> transaction.rollback()
>>> o = Organization_v2.objects.get(name='pdemo')
View gist:decdef8b704e2f23c8cbdd94cb1fbf9d
#!/usr/bin/env python
import hashlib
import sys
bsz = 8192
for f in sys.argv[1:]:
sha1sum = hashlib.sha1()
with open(f, 'rb') as source:
while True:
block = source.read(bsz)
@cgthayer
cgthayer / docker-n00b.md
Last active Aug 28, 2020
Docker Notes for n00bs
View docker-n00b.md

Basics

Images are read-only templates, but you can diff and push them to save many versions. Containers are instances of images, that are also directories and usually a single running process.

Images can be layered, you start from a base and make changes. Containers are versioned so that you can make changes and save the filesystem state as a new Image.

You can’t perform that action at this time.