Skip to content

Instantly share code, notes, and snippets.

@NYKevin
NYKevin / signal.c
Last active Aug 29, 2015
What signal am I receiving?
View signal.c
#define _POSIX_C_SOURCE 1
#include <signal.h>
#include <sys/signalfd.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
int main(void){
sigset_t sig_mask;
@NYKevin
NYKevin / accounting.sql
Last active Aug 4, 2022
Basic double-entry bookkeeping system, for PostgreSQL.
View accounting.sql
CREATE TABLE accounts(
id serial PRIMARY KEY,
name VARCHAR(256) NOT NULL
);
CREATE TABLE entries(
id serial PRIMARY KEY,
description VARCHAR(1024) NOT NULL,
amount NUMERIC(20, 2) NOT NULL CHECK (amount > 0.0),
-- Every entry is a credit to one account...
@NYKevin
NYKevin / fractal.py
Created Sep 29, 2013
Branching spiral
View fractal.py
#!/usr/bin/python3
import turtle
import math
MIN_LENGTH = 2
#FACTOR = (3/2) + math.sqrt(5)/2
@NYKevin
NYKevin / trie.py
Last active Dec 23, 2015
A quick-and-dirty Trie implementation
View trie.py
import collections
class Trie(collections.MutableSet):
def __init__(self, iterable=None):
self.children = {}
self.accepting = False
if iterable is not None:
for item in iterable:
self.add(item)