Skip to content

Instantly share code, notes, and snippets.

Avatar

andrew pikul ayjayt

  • Willimantic, CT
View GitHub Profile
@ayjayt
ayjayt / FIREWALL.md
Last active Jun 19, 2019
An overview of Linux firewall stuff
View FIREWALL.md

Firewalls in Linux

Summary

Backends

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
ayjayt / index.md
Last active Apr 18, 2019
What are indexes and how do they search, sort, and filter?
View index.md

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
ayjayt / cheatsheet.md
Last active Mar 17, 2019
A cheatsheet
View cheatsheet.md

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
ayjayt / just*_Overview.md
Created Oct 31, 2018
This is the basic idea behind the just* Go packages for easy API access with http handlers
View just*_Overview.md

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 baremetal.md

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
ayjayt / lxc_gentoo-day_1.md
Last active Apr 15, 2018
Just a really quick introduction to lxc for gentoo
View lxc_gentoo-day_1.md

sudo -i

emerge app-emulation/lxc

lxc-checkconfig

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
ayjayt / EAGLE_FIX.md
Last active Nov 20, 2017
How to install Eagle 8.4.1 on Linux if you get OpenSSL errors
View EAGLE_FIX.md

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):

You can’t perform that action at this time.