Skip to content

Instantly share code, notes, and snippets.

View elcritch's full-sized avatar

Jaremy Creechley elcritch

View GitHub Profile
### Keybase proof
I hereby claim:
* I am elcritch on github.
* I am elcritch (https://keybase.io/elcritch) on keybase.
* I have a public key ASASCJtnU3IMLH8bOK9NLa1eHUQxMm2uzyItyqtAP-80lQo
To claim this, I am signing this object:
@elcritch
elcritch / application.ex
Created September 15, 2017 00:05
Example task supervisor using a function handle in Elixir (nerves example)
require Logger
defmodule TestNpn.Application do
use Application
alias Nerves.Networking
@interface :eth0
[root@johnny-no-5 (hq) ~]# dmesg | grep bnx1
2016-09-25T22:53:03.543456+00:00 johnny-no-5 mac: [ID 469746 kern.info] NOTICE: bnx1 registered
2016-09-25T22:53:03.543467+00:00 johnny-no-5 pcieb: [ID 586369 kern.info] PCIE-device: pci1028,235@0,1, bnx1
2016-09-25T22:53:03.543471+00:00 johnny-no-5 npe: [ID 236367 kern.info] PCI Express-device: pci1028,235@0,1, bnx1
2016-09-25T22:53:03.543476+00:00 johnny-no-5 genunix: [ID 936769 kern.info] bnx1 is /pci@0,0/pci8086,3408@1/pci1028,235@0,1
2016-09-25T22:53:03.543480+00:00 johnny-no-5 bnx: [ID 219732 kern.info] NOTICE: bnx1: (6.0.3) BCM5709 device with F/W Ver5020003 is initialized (1 MSIX)
2016-09-25T22:53:03.543763+00:00 johnny-no-5 bnx: [ID 328528 kern.info] NOTICE: bnx1: Copper link is up (1000Mbps, Full Duplex, Tx & Rx Flow Control ON)
2016-09-25T22:53:03.543766+00:00 johnny-no-5 bnx: [ID 328528 kern.info] NOTICE: bnx1: Copper link is down
2016-09-25T22:53:03.543769+00:00 johnny-no-5 mac: [ID 435574 kern.info] NOTICE: bnx1 link up, 0 Mbps, half duplex
2016-09-2
@elcritch
elcritch / step00-howto.md
Last active May 2, 2018 18:14
Download and Compile Updated PulseView
  1. Download and save scripts "step01-" and "step02-".
  2. Change to sudo / root
  3. Execute scripts step01* and then step02*
defmodule Cluster.Strategy.BroadcastGossip do
@moduledoc """ Here's the module I made for libcluster that uses local network broadcasting. Useful for nerves local devices. """
require Logger
use GenServer
use Cluster.Strategy
alias Cluster.Strategy.State
@default_ifname "eth0"
@default_port 45893
@elcritch
elcritch / rancher-zerotier.yml
Last active July 24, 2019 13:12
Run ZeroTier on RancherOS
#cloud-config
rancher:
services:
zerotier:
image: zerotier/zerotier-containerized:1.2.4
labels:
io.rancher.os.scope: system
volumes:
- /var/lib/zerotier-one:/var/lib/zerotier-one
restart: always
@elcritch
elcritch / RemoteIExNode.exs
Created October 14, 2019 05:53
Establish an IEx shell to another node in a Elixir Node (Erlang Node)
iex(node-a@192.168.1.2)1> Node.list()
[:"node-b@192.168.1.3"]
iex(node-a@192.168.1.2)1> :rpc.call :"node-b@192.168.1.3", IEx, :start, []
@elcritch
elcritch / syncthing-service.sh
Last active June 24, 2020 15:36
Syncthing Setup
#!/bin/sh
sudo systemctl enable syncthing@`whoami`.service
sudo systemctl start syncthing@`whoami`.service
systemctl status syncthing@`whoami`.service
@elcritch
elcritch / parse_udhcpd.exs
Created June 25, 2020 01:57
Elixir Module to parse UDHCPD Lease Files
defmodule ParseUdhcpd do
def find_leases(interface \\ "eth0") do
udhcpd_lease_bytes =
"/tmp/vintage_net/udhcpd.#{interface}.leases"
|> File.read!()
<<written_at::signed-integer-64, leases_bytes::bits >> = udhcpd_lease_bytes
parse_leases(leases_bytes, [])
@elcritch
elcritch / other.exs
Created June 25, 2020 19:23
Byte String Pad
0x4A |> Integer.to_string(2) |> String.pad_leading(8, "0") |> String.pad_leading(10,"0x")