Skip to content

Instantly share code, notes, and snippets.

View cgthayer's full-sized avatar
💡
coding

Charles Thayer cgthayer

💡
coding
View GitHub Profile
@cgthayer
cgthayer / apt-cheatsheet.md
Last active March 9, 2024 02:05
Apt Cheat Sheet

Level 1

sudo apt update
sudo apt get net-tools  # netstat

Level 2

@cgthayer
cgthayer / EditorCheatsheet.md
Last active March 5, 2022 21:25
Editor Cheatsheet

Goland

What Keys
Back/forward C-Alt-- +

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 20:20
Env Pkg: Package your shell environment
#!/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 April 25, 2020 01:33 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
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
$ 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
@cgthayer
cgthayer / gist:a43786a447527e0c8b9afb5cd69c91d2
Last active February 24, 2020 02:04
deploy-django-code-1
$ 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'
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.

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 18:04
Django: check what would be deleted when I delete an object, using a transaction
>>> 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')