Skip to content

Instantly share code, notes, and snippets.

View chrisledet's full-sized avatar
⚔️

Chris Ledet chrisledet

⚔️
View GitHub Profile
@chrisledet
chrisledet / travel.py
Created March 26, 2020 06:48
script to calculate travel times for long distances in D&D 5e
import sys
SPEED_PER_HOUR = {
'fast': 4, # miles
'normal': 3,
'slow': 2,
}
TRAVEL_TIME_PER_DAY = {

Export SQL results to file

\copy (select username from auth_user order by date_joined desc limit 10000) to 'latest-users.csv' with csv;

Export database via shell

Update apt index

apt-get update

Extract package into directory

dpkg-deb -x mypackage.deb dstDir

Find installed packages

1. Python code compiles to bytecode which can not run concurrently
2. GIL protects:, reference count updates, mutable types, some internal bookkeeping
3. Can't use threads
4. Python instructions are not interruptible
@chrisledet
chrisledet / about:config.md
Created January 13, 2018 00:59 — forked from haasn/about:config.md
Firefox bullshit removal via about:config

Firefox bullshit removal

Due to the incessant swarm of complete and utter nonsense that has been forcing its way into Firefox over time, I've decided to start collecting my personal list of “must-have” about:config tweaks required to turn Firefox into a functional brower.

NOTE: Unfortunately this is somewhat out of date. The comments link to some resources that may be more up-to-date. Patches welcome.

WebSockets

These can be used for nefarious purposes and to bypass access restrictions.

@chrisledet
chrisledet / pdiff.sh
Last active March 29, 2018 19:07
p4 color diffs
#!/bin/bash
# pdiff: colorized diffs for linux p4 workspaces
# usage: pdiff <CL#>
p4 opened -c $1 | sed -e 's/#.*//' | p4 -x - diff -du | colordiff
@chrisledet
chrisledet / indices.sql
Created January 21, 2017 04:03
View indices usage in PostgreSQL
-- filter by table name
select indexrelname, idx_scan, idx_tup_read, idx_tup_fetch from pg_stat_user_indexes where relname = '<TABLE NAME>';
-- filter by index name
select idx_scan, idx_tup_read, idx_tup_fetch from pg_stat_user_indexes where indexrelname = '<IDX NAME>';

Linux System Metrics

CPU

  • system.cpu.idle: % Idle CPU
  • system.cpu.system: % System CPU
  • system.cpu.user: % User CPU

Disk

@chrisledet
chrisledet / gist:6c03cf98d4fe1e99b6e1
Created February 2, 2016 01:22
iTerm words regex
/-+\~_.
import static android.opengl.GLES20.GL_COMPILE_STATUS;
import static android.opengl.GLES20.GL_FRAGMENT_SHADER;
import static android.opengl.GLES20.GL_LINK_STATUS;
import static android.opengl.GLES20.GL_VALIDATE_STATUS;
import static android.opengl.GLES20.GL_VERTEX_SHADER;
import static android.opengl.GLES20.glAttachShader;
import static android.opengl.GLES20.glCompileShader;
import static android.opengl.GLES20.glCreateProgram;
import static android.opengl.GLES20.glCreateShader;
import static android.opengl.GLES20.glDeleteProgram;