Skip to content

Instantly share code, notes, and snippets.

View woodrowbarlow's full-sized avatar

Woodrow Barlow woodrowbarlow

View GitHub Profile
@woodrowbarlow
woodrowbarlow / hex.h
Last active October 13, 2018 22:16 — forked from jdpage/hex.h
proposed hex board API
#ifndef HEX_HEX_H
#define HEX_HEX_H
#include <stdlib.h>
enum hex_err_e {
HEX_OK,
HEX_ENOMEM,
HEX_EBOUNDS,
HEX_EBADSPACE,
@woodrowbarlow
woodrowbarlow / hex.c
Last active October 13, 2018 20:52
gcc hex.c -o hex; ./hex
#include <stdio.h>
#include <stdlib.h>
#define BOARD_WIDTH 11
#define BOARD_HEIGHT 11
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
#define TRAVERSE_DIRECTION(iterator, source, direction) \
for (iterator = source; iterator != NULL; \
iterator = iterator->edges[direction])
@woodrowbarlow
woodrowbarlow / tak.c
Created October 13, 2018 17:09
gcc tak.c -o tak; ./tak
#include <stdio.h>
/* each line along which a player can win */
enum axes {
HORIZ_TOP,
HORIZ_MID,
HORIZ_BOT,
VERT_LEFT,
VERT_MID,
VERT_RIGHT,
@woodrowbarlow
woodrowbarlow / wav-pulse-example.c
Last active April 14, 2018 19:41
Decode a .wav file into signed 32-bit PCM samples with Dr Wav, then write those samples to the audio server via Pulse Audio.
// compile with `gcc wav-pulse-example.c -lpulse-simple -lpulse -o wav-pulse-example`
// run with `./wav-pulse-example <path_to_wav_file>`
#include <stdio.h>
#include <stdlib.h>
// install dev libs from package "pulseaudio-libs-devel" (rpm) or "libpulse-dev" (deb)
#include <pulse/simple.h>
#include <pulse/error.h>
setopt +o nomatch
NEWLINE=$'\n'
source ~/.profile
show_git_branch () {
local desc=$(git symbolic-ref --short HEAD 2>/dev/null)
[[ -z "$desc" ]] && desc=$(git rev-parse --short HEAD 2>/dev/null)
[[ -z "$desc" ]] && return
@woodrowbarlow
woodrowbarlow / clock.sh
Last active February 27, 2017 14:09
Output an analog clock for the current time, using unicode.
#!/bin/bash
# Output an analog clock for the current time.
# Rounded to the nearest half-hour.
(( clock = $(date +"%I") + 143 ))
if [[ $(date +"%M") > 45 ]]; then
(( clock ++ ))
[[ $clock > 152 ]] && (( clock = 144 ))
elif [[ $(date +"%M") > 15 ]]; then
(( clock += 12 ))