Skip to content

Instantly share code, notes, and snippets.

View connorskees's full-sized avatar
🦆
chr(127752)

Connor Skees connorskees

🦆
chr(127752)
View GitHub Profile
@aras-p
aras-p / preprocessor_fun.h
Last active May 18, 2024 08:55
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@scaryguy
scaryguy / change_primary_key.md
Last active May 13, 2024 18:43
How to change PRIMARY KEY of an existing PostgreSQL table?
-- Firstly, remove PRIMARY KEY attribute of former PRIMARY KEY
ALTER TABLE <table_name> DROP CONSTRAINT <table_name>_pkey;
-- Then change column name of  your PRIMARY KEY and PRIMARY KEY candidates properly.
ALTER TABLE <table_name> RENAME COLUMN <primary_key_candidate> TO id;
@Kartones
Kartones / postgres-cheatsheet.md
Last active May 16, 2024 12:40
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@pmav99
pmav99 / config2.json
Last active June 15, 2022 14:56
Python logging configuration using JSON. If you want an updated example also covering YAML files, check here: https://github.com/pmav99/python-logging-example
{
"logging": {
"version": 1,
"disable_existing_loggers": true,
"formatters": {
"brief": {
"class": "logging.Formatter",
"datefmt": "%I:%M:%S",
"format": "%(levelname)-8s; %(name)-15s; %(message)s"
},
@alessonforposterity
alessonforposterity / drgn.txt
Created April 12, 2015 04:43
Abandon all hope, ye who enter here
This file has been truncated, but you can view the full file.
//Dr. Seuss once wrote, "IF." He meant, "If you give a fuck, maybe,
//JUST MAYBE, you can change this shitty world in some small way for
//the better." I might've been an writer of children's books someday,
//but instead, I decided to make this. So in lieu of The Lorax,
//let's call this The Dragon, and have my word be, "DON'T." As in,
//"Don't do something stupid like this the way I did, you jackass."
//But the truth is humans are very stubborn creatures. You probably
//won't listen to my advice and, chances are, neither will I.
//This is just an excerpt of the source code for DRAGON: A Game About
@ohsix
ohsix / perf.md
Last active December 29, 2023 22:52
stuff I should write down: perf

Intro

perf is very handy, it comes with linux and works without a lot of setup (contrast: oprofile, systemtap)

probes work for kernel and userspace and you can record function arguments and local frame and other variables in the trace

you can use perf script to view the output of such traces, and it will display the variables bundled with the trace, by name, and with the format given when the probe was added

Context

recently someone was asked to record what happened in systemd at source_dispatch, in sd-event; to see what the value of s->description was at the time, they were advised to use gdb

@postmodern
postmodern / tcp_client.rs
Last active May 20, 2022 16:01
TCP Client in Rust
#![allow(unused_variables)]
#![allow(unused_imports)]
use std::env;
use std::process;
use std::thread;
use std::io::{self, Read, Write, Error};
use std::net::TcpStream;
use std::net::TcpListener;
@ramiroaznar
ramiroaznar / query.sql
Created August 12, 2016 12:17
How to find duplicate values with PostgreSQL
select * from table t1
where (select count(*) from table t2
where t1.field = t2.field) > 1
order by field
@fntlnz
fntlnz / self-signed-certificate-with-custom-ca.md
Last active May 17, 2024 07:59
Self Signed Certificate with Custom Root CA

Create Root CA (Done once)

Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096