Skip to content

Instantly share code, notes, and snippets.


andrew pikul ayjayt

  • Willimantic, CT
View GitHub Profile
ayjayt /
Last active December 9, 2020 04:57
How to turn your BB into a router using wifi as internet source

First, set up DHCP on "router" device:

Give eth0 an IP address (forget command, I gave it

Give DNSMASQ a config file with these lines:


  1. Doubt all lines necessary
  2. ADDED to defaults, and taken from here:
ayjayt /
Last active June 19, 2019 20:54
An overview of Linux firewall stuff

Firewalls in Linux



The multilayered kernel firewall is built on netfilter, moving towards Berkely Packet Filter architecture. There are two options for interacting with it:

  • ip_tables is the original kernel module, and comes with the iptables user utility (notice the missing underscore for the user utility).
ayjayt /
Last active April 18, 2019 13:45
What are indexes and how do they search, sort, and filter?

An Index can Order, Filter, and Search

Think of a physical, book-loaning library. It's a big room of books, but it's organized by the Dewey Decimal System (DDS). The DDS is sorted first by topic, and then by author within topic. Each book then has an index in the back, which is an alphabetical list of topics with page numbers.

In computer science, both the book index and the Dewey Decimal System are called "indices" (some say indexes). That is, they provide a way for you to find quickly by some category (topic, author, etc) the information that is relevant to you.

Database (computer science) indices are similiar in concept to both those examples, but the math is very different, click at your own risk.

But what you should notice, is that the index is already sorted by topic and already sorted by author. The fundamental code that provides the index provides the search, sort, and filter mechanisms. The request (the query) is what changes:

ayjayt /
Last active March 17, 2019 23:34
A cheatsheet

Test Driven Design

Write your tests first.

Domain Driven Design

Theory (Domain) --> Implementation --> Delivery

You start with theory. IE, understand the fundamental problem before writing a program, I guess.

Interfaces (Go)

Types that don't have a specific definition but rather a set of constraints that other types can fufill. Those constraints are usually "The type must have these operators declared" or in go-speak "The type must have these receivers declared".

ayjayt / just*
Created October 31, 2018 16:05
This is the basic idea behind the just* Go packages for easy API access with http handlers
View just*

The basic idea of all just* packages is to

A) Configure their config structures in main.go or wherever you set the http handlers.

B) Import them (or an interface that supports a class of them) when defining your handler.

C) Negotiate with the configurations that main.go has supplied and...

D) Use a closure to return a HandlerFunc for http.HandleFunc or initialize a type

View enum vs define
#define OFF 0
#define START 1
#define PROCESS_ONE 2
#define PROCESS_TWO 3
#define END 4
uint8_t state;
if (state == OFF) // etc
View How to

A microcontroller is fundamentally controlled by storing certain values to certain specific memory addresses. For example, an ARM micontroller, memory address 0x4000AA00 might be an 8-bit wide address that toggles a digital output pin mapped to a specific bit when 1 is written to it. So to toggle all 8 pins, you would write:

*((uint8_t *) 0x4000AA00) = 255;

This casts the address as a pointer, derefences it, and then stores 255 to it, which is 0b11111111.

These memory addresses aren't really memory, they're used to control peripherals.

You read the "Technical Reference Manual" for the device and it has a reference for each memory address and what it does, divided into function units (timers, inputs, outputs, whatever).

ayjayt /
Last active April 15, 2018 05:52
Just a really quick introduction to lxc for gentoo

sudo -i

emerge app-emulation/lxc


go set up your kernel for the security features it wants. make sure to back up your working version.

this is a quick hack, there are more formal methods and this is considered lazy, but it gets the job done:

ayjayt /
Last active November 20, 2017 03:45
How to install Eagle 8.4.1 on Linux if you get OpenSSL errors

Special thanks to nate on #openssl and [R] on #linux on Freenode.

I downloaded Eagle 8.4.1 on my Gentoo box, and untar'ed it in my downloads folder. I went to run with ./eagle, but it gave me errors about OpenSSL!

Now, I don't like dumping proprietary software all over my hyper-secure ultima-fast uber-reliable system, so I want to keep Eagle 8.4.1 in it's own folder in ~/Downloads/eagle_-8.4.1/ and just create a shortcut to the binary in there.

Therefore, the full run command for Eagle is (replace $EAGLEHOME with your extracted directory or set EAGLEHOME equal to it):