Skip to content

Instantly share code, notes, and snippets.

View samizdatco's full-sized avatar

Christian Swinehart samizdatco

View GitHub Profile
@samizdatco
samizdatco / cleanup_timer.c
Created November 17, 2011 21:07
An attempt at a periodic callback in nginx
#define NGX_HTTP_AUTH_DIGEST_CLEANUP_INTERVAL 3000
ngx_event_t *ngx_http_auth_digest_cleanup_timer;
static ngx_atomic_t *ngx_http_auth_digest_cleanup_lock;
// set as the "init process" callback in the ngx_module_t struct
static ngx_int_t ngx_http_auth_digest_worker_init(ngx_cycle_t *cycle){
if (ngx_process != NGX_PROCESS_WORKER){
return NGX_OK;
}
@samizdatco
samizdatco / async-demo.py
Created February 14, 2012 20:58
A Messy Demo
#!/usr/bin/env python
# encoding: utf-8
"""
async-demo.py
Created by Christian Swinehart on 2012-02-14.
Copyright (c) 2012 Samizdat Drafting Co. All rights reserved.
"""
from __future__ import with_statement

Keybase proof

I hereby claim:

  • I am samizdatco on github.
  • I am samizdat (https://keybase.io/samizdat) on keybase.
  • I have a public key ASCpFjJuOmpekwVzyfnJjg9xWe1suDH98wlmJbZf9QHq2Qo

To claim this, I am signing this object:

var x;
var num;
// Sets the screen to be 2080 pixels wide and 720 pixels high
function setup() {
createCanvas(2080, 720);
noStroke();
}
function draw() {
function draw() {
// get the current time
var now = clock()
// set the width & height of the sketch
createCanvas(800, 600)
background(51);
// use the `sec`, `min`, `hours`, and `day` numbers (which are all in the range 0-59, 0-23, or 1-31) to draw
var existingHour
function setup() {
var now = clock()
existingHour = now.hour
}
function draw() {
var now = clock()
@samizdatco
samizdatco / sketch.js
Last active September 30, 2018 21:45
function setup() {
createCanvas(720, 400);
}
// define global variables to hold the current rotation of each polygon across draw() calls
var hRot = 0
var mRot = 0
var sRot = 0
function draw() {
var tests
var arsenal
function preload(){
tests = loadTable('data/totals.csv', 'csv', 'header')
arsenal = loadTable('data/warheads.csv', 'csv', 'header')
}
#!/usr/bin/env python
# encoding: utf-8
"""
pbj
Pretty-print whatever JSON is currently in the pasteboard and view it in your pager of choice
USAGE
pbj [-c] [-m]
@samizdatco
samizdatco / inline-csv.js
Last active March 19, 2021 17:07
Rather than using the p5 preload() and loadTable() functions, you can paste your CSV data right into the js file and use the buildTable() function to convert it into a p5.Table object (see: https://p5js.org/reference/#/p5.Table). Make sure you surround your csv text in `backwards quote marks` in order to create a multi-line string.
var CSV = `Year,United States,Russia,United Kingdom,France,China,India,Pakistan,North Korea
1945,1,0,0,0,0,0,0,0
1946,2,0,0,0,0,0,0,0
1947,0,0,0,0,0,0,0,0
1948,3,0,0,0,0,0,0,0
1949,0,1,0,0,0,0,0,0
1950,0,0,0,0,0,0,0,0
1951,16,2,0,0,0,0,0,0
1952,10,0,1,0,0,0,0,0
1953,11,5,2,0,0,0,0,0