Skip to content

Instantly share code, notes, and snippets.

View adam-hanna's full-sized avatar
💭
breaking things...

Adam Hanna adam-hanna

💭
breaking things...
View GitHub Profile
@adam-hanna
adam-hanna / main.go
Created May 19, 2023 21:49
Group Membership
package main
import (
"fmt"
"strings"
)
// A group's effective members include the members for the group itself as well as all of its children. Write a function to detect if a given user is an effective member of a given group.
type Group struct {
@adam-hanna
adam-hanna / interpreter.js
Created March 30, 2020 22:37
Example interpretation of a string, to a function with parameters
const s = "return function foo(msg) {console.log(msg)};";
const F = new Function(s);
let f = F()
f("hello") // console logs the string, "hello"
@adam-hanna
adam-hanna / goal-seek-example.html
Last active August 21, 2023 06:59
Goal seek example
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Goal Seek Example</title>
<!--
note: update the contents between the <script>{update this stuff!}</script> tags, below, with the most up-to-date \
code from: https://raw.githubusercontent.com/adam-hanna/goal-seek/develop/dist/index.min.js
-->
@adam-hanna
adam-hanna / PREZZO.md
Last active October 11, 2019 15:48
AE Prezzo
@adam-hanna
adam-hanna / TUTORIAL.md
Created September 25, 2019 20:16
DHT Tracer

instructions for building & testing dht-tracer

Step 0: read the project brief

Read this project-brief -- it will give you an understanding of what the goals are for this tool.

Step 1: get the right code

@adam-hanna
adam-hanna / TUTORIAL.md
Last active March 28, 2023 11:29
Create and connect macvlan network namespaces

This tutorial was written using Red Hat Fedora 30 but may be similar on other distros.

Discover

You should have an eth0, but if you $ ifconcig -a and don't see it, you should do $ nmcli device status to determine which device is connected to your wifi/ethernet.

Create macvlans and network spaces

$ sudo ip link add macvlan1 link eth0 type macvlan mode bridge
$ sudo ip link add macvlan2 link eth0 type macvlan mode bridge
$ sudo ip netns add net1
@adam-hanna
adam-hanna / systemd-cloudwatch-logs-tutorial.md
Last active April 24, 2024 03:22
Forward systemd service logs to AWS Cloudwatch

Introduction

I often find myself ssh'ing into my servers and checking my systemd service logs with $ journalctl -f -u {name}.service. One day I got tired of this and wanted all of my important logs in once place (Amazon AWS Cloudwatch). To my dismay, there weren't any real good tutorials on how to do so. So, voilà.

Steps

Overall, it's a fairly simple process consisting of the following few steps.

1. Modify the service file

Open the service file with $ sudo vi /lib/systemd/system/{name}.service

Modify the [Service] section:

Keybase proof

I hereby claim:

  • I am adam-hanna on github.
  • I am adam_hanna (https://keybase.io/adam_hanna) on keybase.
  • I have a public key ASB0SSLO1KjLN_LZ5nRjHe9LSzYHTwsee7nQILWh0orm9Ao

To claim this, I am signing this object:

@adam-hanna
adam-hanna / lib.rs
Last active March 8, 2019 00:49
Rust - Owned vs borrowed benchmark
/*
YMMV
Compiling rust-bench-test v0.1.0 (/home/adam/apps/rust-bench-test)
Finished release [optimized] target(s) in 0.78s
Running /home/adam/apps/rust-bench-test/target/release/deps/rust_bench_test-5e0b4fbe4a887c9a
running 3 tests
test bench_gather_borrowed_foos ... bench: 291 ns/iter (+/- 18)
test bench_gather_owned_foos ... bench: 333 ns/iter (+/- 9)
test bench_passed_borrowed_foos ... bench: 283 ns/iter (+/- 17)
@adam-hanna
adam-hanna / 20181025_meeting_notes.md
Last active October 25, 2018 23:52
20181025 - c3 / dna meeting notes

Brainstorming Notes

Dictionary

We want to change these EOS words/phrases to these new words/phrases:

From To Notes
stake lock coins are being "locked up" and are safe
owner master the master key controls all of the sub-keys
active live the key is either alive and being used or dead
wallet key ring a wallet is really a thing that stores keys, like a key ring