Skip to content

Instantly share code, notes, and snippets.

View routevegetable's full-sized avatar

Lee Marshall routevegetable

  • West Oakland, CA
View GitHub Profile
@routevegetable
routevegetable / DuplicateFiles.cs
Last active August 29, 2016 13:54
Find Duplicate Files
using System;
using System.Threading;
using System.IO;
using System.Data.Linq;
using System.Linq;
using System.Collections.Generic;
using System.Security.Cryptography;
@routevegetable
routevegetable / aoc-day-18.c
Created December 19, 2016 20:43
Advent of Code, Day 18
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <inttypes.h>
const char input[] = "^^^^......^...^..^....^^^.^^^.^.^^^^^^..^...^^...^^^.^^....^..^^^.^.^^...^.^...^^.^^^.^^^^.^^.^..^.^";
//const char input[] = ".^^.^.^^^^";
const uint64_t nrows = 100000000000;
@routevegetable
routevegetable / chip-deploy.sh
Last active January 28, 2017 23:07
A script to care of recompiling CHIP kernel & modules, and then rsyncing
#!/bin/bash
# Script to automate the stuff in http://www.raspibo.org/wiki/index.php/Compile_the_Linux_kernel_for_Chip:_my_personal_HOWTO
IP=192.168.0.24
MYDIR=`pwd`
BUILD_DIR=`pwd`/build
KVER=4.3.0bizarrefish+
set -e
@routevegetable
routevegetable / find-path.c
Last active November 14, 2017 22:54
Depth-first search on a 2D grid
/* Tries to find the shortest path to G */
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#define WIDTH 10
#define HEIGHT 10
const char grid[][WIDTH] =
@routevegetable
routevegetable / fish.lua
Created July 16, 2018 20:48
Computercraft fish
local fishStringL = "<'((>-<";
local fishStringR = ">-<))'>";
local fishLength = 7;
local foodDist = 5;
-- A float between -1 and 1
local randFloat = function()
return math.random(-100, 100) / 100;
// void print_hex(unsigned char num);
.data
buff:
.ascii "0x00\n"
.global print_hex
.text
print_hex:
mov %rdi,%rax
@routevegetable
routevegetable / automaton.c
Created September 28, 2019 03:39
Elementary Cellular Automaton implementation
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <memory.h>
void step(char *state, size_t len, char rule)
{
/* Buffer large enough to hold all bits */
char state_copy[len];
@routevegetable
routevegetable / lut-automaton.c
Created October 23, 2019 15:30
Faster, LUT-based elementary cellular automaton
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <assert.h>
#include <memory.h>
uint8_t get_bits(uint8_t *in_base, size_t start_bit, size_t n_bits)
{
size_t split = start_bit % 8;
uint8_t *base = &in_base[start_bit/8];
@routevegetable
routevegetable / eyes.c
Created November 5, 2019 20:13
Hacked together program for neopixel-based spooky eyes halloween display
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <signal.h>
@routevegetable
routevegetable / fake_dns.sh
Last active November 21, 2019 22:10
Shell script to run a program with a fake DNS
#!/bin/bash
# Usage:
# fake_dns 12.23.45.67 fakedomain.com <program> [args...]
set -e
IP=$1
HOST=$2
shift 2