Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python3
"""
Apply database patches.
Applied patches are recorded in the schema_patch table of the database.
The dsn to connect to defaults to a local one (empty connection string). It can
be chosen using the command line or an environment variable. Patches
application is interactive by default.
@d7samurai
d7samurai / .readme.md
Last active March 25, 2024 10:45
Minimal D3D11

Minimal D3D11

Minimal D3D11 reference implementation: An uncluttered Direct3D 11 setup + basic rendering primer and API familiarizer. Complete, runnable Windows application contained in a single function and laid out in a linear, step-by-step fashion that should be easy to follow from the code alone. ~200 LOC. No modern C++, OOP or (other) obscuring cruft. View on YouTube

hollowcube

Also check out Minimal D3D11 pt2, reconfigured for instanced rendering and with a smaller, tighter, simplified overall code structure, or Minimal D3D11 pt3, with shadowmapping + showcasing a range of alternative setup and rendering techniques.

@sinclairtarget
sinclairtarget / bernoulli.c
Created August 17, 2018 20:22
Lovelace's Note G Program in C
#include <stdio.h>
/*
* Calculates what Ada Lovelace labeled "B7", which today we would call the 8th
* Bernoulli number.
*/
int main(int argc, char* argv[])
{
// ------------------------------------------------------------------------
// Data
@sdalu
sdalu / lcd_hat_rpi.md
Last active August 7, 2022 13:33
LCD display HAT for Raspberry Pi
@gricard
gricard / webpack4upgrade.md
Last active February 29, 2024 20:23
Just some notes about my attempt to upgrade to webpack 4

If you enjoyed reading this, I'm intending to do more blogging like this over here: https://cdgd.tech

This is not a complaint about Webpack or v4 in any way. This is just a record of my process trying it out so I could provide feedback to the webpack team

Hmm... I don't see any docs for 4.0 on https://webpack.js.org. I guess I'll just wing it. All I need to do is npm i -D webpack@next, right?

+ webpack@4.0.0-beta.2
enum { BMAX = 32, BCUT = BMAX / 2, BHEIGHT = 6 };
typedef uint8_t BIndex;
struct BNode {
BIndex length;
Key keys[BMAX];
union {
BNode *children[BMAX];
Value values[BMAX];
@rupey
rupey / mandelbrot.sql
Last active December 7, 2020 05:38
Mandelbrot plot in postgres
WITH RECURSIVE
x(i) AS ( VALUES (0)
UNION ALL SELECT i + 1
FROM x
WHERE i < 101),
Z(Ix, Iy, Cx, Cy, X, Y, I) AS (
SELECT
Ix,
Iy,
X :: FLOAT,
@randrews
randrews / hoc4.lua
Created June 21, 2015 20:53
Toy calculator in Lua, version 4
setmetatable(_ENV, { __index=lpeg })
Scopes = { {} }
function eval_expr(expr)
local accum = eval(expr[2]) -- because 1 is "expr"
for i = 3, #expr, 2 do
local operator = expr[i]
local num2 = eval(expr[i+1])
@chrismdp
chrismdp / s3.sh
Last active March 5, 2024 12:57
Uploading to S3 in 18 lines of Shell (used to upload builds for http://soltrader.net)
# You don't need Fog in Ruby or some other library to upload to S3 -- shell works perfectly fine
# This is how I upload my new Sol Trader builds (http://soltrader.net)
# Based on a modified script from here: http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash
S3KEY="my aws key"
S3SECRET="my aws secret" # pass these in
function putS3
{
path=$1
@jberkus
jberkus / gist:6b1bcaf7724dfc2a54f3
Last active January 7, 2024 21:26
Finding Unused Indexes
WITH table_scans as (
SELECT relid,
tables.idx_scan + tables.seq_scan as all_scans,
( tables.n_tup_ins + tables.n_tup_upd + tables.n_tup_del ) as writes,
pg_relation_size(relid) as table_size
FROM pg_stat_user_tables as tables
),
all_writes as (
SELECT sum(writes) as total_writes
FROM table_scans