This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import collections | |
import itertools | |
import queue | |
import random | |
Puzzle = collections.namedtuple('Puzzle', 'board width height') | |
# mix two colors together and get the result | |
def mix(c0, c1): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local Spritesheet = {} | |
Spritesheet.__index = Spritesheet | |
function Spritesheet.new(sheetPath, spriteWidth, spriteHeight) | |
assert(spriteWidth, 'Missing sprite width!') | |
assert(spriteHeight, 'Missing sprite height!') | |
local spritesheet = {} | |
setmetatable(spritesheet, Spritesheet) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Need to enable the extension (and restart): | |
-- https://pganalyze.com/docs/install/01_enabling_pg_stat_statements#configure-postgresql | |
-- Enable the pg_stat_statements extension (requires database superuser) | |
CREATE EXTENSION pg_stat_statements; | |
-- Check which queries are consuming the most time | |
SELECT | |
substring(query, 1, 50) AS short_query, | |
round(total_time::numeric, 2) AS total_time, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sqlite3 | |
# References: | |
# https://charlesleifer.com/blog/going-fast-with-sqlite-and-python/ | |
# https://docs.peewee-orm.com/en/latest/peewee/database.html#recommended-settings | |
# sqlite optimization pragmas | |
pragmas = { | |
'journal_mode': 'wal', # allow readers and writers to co-exist | |
'cache_size': -64 * 1024, # set page-cache size in KB (neg values mean KB) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create the hard disk image | |
qemu-img create -f qcow2 void.qcow2 20G | |
# boot iso with hard disk attached | |
qemu-system-x86_64 -accel kvm -cpu kvm64 -smp 4 -m 4096 -hda void.qcow2 -cdrom void-live-x86_64-20191109.iso | |
# install OS to the hard disk | |
# boot from hard disk | |
qemu-system-x86_64 -accel kvm -cpu kvm64 -smp 4 -m 4096 -hda void.qcow2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# some more ls aliases | |
alias ll='ls -alF' | |
alias la='ls -A' | |
alias l='ls -CF' | |
# git aliases | |
alias gs='git status' | |
alias ga='git add' | |
alias gaa='git add --all' | |
alias gc='git commit -v' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdbool.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <SDL2/SDL.h> | |
#include <SDL2/SDL_opengl.h> | |
#include "opengl.h" | |
#define OPENGL_DEFINE(func_name, func_type) \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set t_vb= | |
syntax on | |
set tabstop=4 | |
set expandtab | |
set noautoindent | |
set nocindent | |
set nosmartindent | |
set indentexpr= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from des import DesKey | |
import io | |
import uu | |
SAMPLE_DATA = br""" | |
begin 600 text.d | |
MJ4$2A<<%*O__[-,H5 [)._TZKE;(LDEV 7MDS=:?HD#ZP5ZV\76UMHE;@C:R | |
K-9];N1J/-+KTPF)S7N-MW6)[V!8L*N!Z])Z@&^A.ZQ%_@Y<;W"07/^?@D0 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
class Adder { | |
public: | |
int add(int a, int b) const { return a + b; } | |
}; | |
int main() { | |
// Dynamic allocation using "new" | |
Adder *adder = new Adder(); |