Skip to content

Instantly share code, notes, and snippets.

View crccheck's full-sized avatar

Chris Chang crccheck

View GitHub Profile
@crccheck
crccheck / README.md
Last active March 2, 2024 16:39
Python Packaging

What the Hell? -- A Journey Through the Nine Circles of Python Packing

Writing a setup.py

map

I am no Virgil, but having stumbled my way through Python packaging a few times already, I'm documenting the things I learn as I go here.

To help me learn, I took a survey of the top 15 Python packages on Github along with 12 other commonly referenced packages. I thought... if there are any best

@crccheck
crccheck / db_cheatsheet.md
Last active December 12, 2023 16:26
Database Cheetsheet
Task Postgres MySQL sqlite
help \? .help
list databases psql -l, \l show databases; .databases
list tables/views/seq \d
list roles \du
list tables \dt .tables
describe table \d <table> .schema
expanded output \x \G
list schemas \dn
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@crccheck
crccheck / swap_env_bookmarklet.js
Last active January 26, 2022 17:03
Bookmarklet to swap from the live site to my local dev site
javascript:(function(){var a=location.href.split('/');a[0]='http:';a[2]=location.port?'www.texastribune.org':'localhost:8000';window.open(a.join('/'))})();
@crccheck
crccheck / splunk recipes.md
Last active September 30, 2021 20:27
Splunk recipes

Histogram of a natural number field NOTE: the x-axis ends up being ordinal instead of linear so it can look like 1 2 3 5 6 8 12 instead of 1 2 3 4 5 6 7 ...

| stats count AS attempts by url_path
| rex field=url_path mode=sed "s/.*/1/"
| stats sum(url_path) by attempts
| sort num(attempts)
@crccheck
crccheck / bash.md
Created August 17, 2021 19:44
CLI fu

Grab a column out of a CSV with header, surround with quotes, and put commas between

echo $(csvcut -c UUID path_to.csv | tail -n +2 | awk '{ print """$0""" }') | tr ' ' ,

@crccheck
crccheck / kafka-connect.md
Last active March 31, 2021 17:42
Kafka Connect cheatsheet

Errors

Halt on all errors. Useful for debugging.

errors.tolerance=none
errors.log.include.messages=true
errors.log.enable=true

Keep going no matter what.

@crccheck
crccheck / readme.md
Created January 27, 2021 01:15
Siege recipes
@crccheck
crccheck / README.md
Last active August 4, 2020 16:22
ungzip nock.recorder.rec() output

https://github.com/nock/nock#recording

Recording

This is a cool feature:

Guessing what the HTTP calls are is a mess, especially if you are introducing nock on your already-coded tests.

For these cases where you want to mock an existing live system you can record and playback the HTTP calls like this:

@crccheck
crccheck / request timeout pool.js
Created August 23, 2018 21:53
timeout is a good idea
// In another window, run
//
// $ nc -kl 4200
//
// -k keepalive (BSD/OSX only)
// -l 4200 listen on port 4200
const requestP = require('request-promise-native');
const now = Date.now();
// never finishes