Skip to content

Instantly share code, notes, and snippets.

@meatherly
meatherly / gist:a1a3fde9a0dfab82d13227d305df0ad3
Created August 11, 2023 14:59
NXP ls1028 Felix Ubuntu Router Setup
#!/bin/bash
#
# Simple switch configuration
#
# Assume both ENETC and Felix drivers are already loaded
#
BRIDGE=br0
MAC_ROOT=bc:8d:bf:7c:5b
@meatherly
meatherly / day3.md
Created December 3, 2021 23:08
Day 3

--- Day 3: Binary Diagnostic --- The submarine has been making some odd creaking noises, so you ask it to produce a diagnostic report just in case.

The diagnostic report (your puzzle input) consists of a list of binary numbers which, when decoded properly, can tell you many useful things about the conditions of the submarine. The first parameter to check is the power consumption.

You need to use the binary numbers in the diagnostic report to generate two new binary numbers (called the gamma rate and the epsilon rate). The power consumption can then be found by multiplying the gamma rate by the epsilon rate.

Each bit in the gamma rate can be determined by finding the most common bit in the corresponding position of all numbers in the diagnostic report. For example, given the following diagnostic report:

00100
Soothsayer, Amulet, Sentry, Cellar, Page, Hireling, Margrave, Harbinger, Council Room, Wharf, Bandit Fort, Citadel, Travelling Fair, Tomb
@meatherly
meatherly / genericsExample.ts
Created October 25, 2018 15:38
Typescript generics
function map<A, B>(arr: A[], fn: (el: A) => B): B[] {
return arr.map(fn);
}
// manual annotation
map<number, void>(['string'], el => el * 2)
// inferred annotation
map([1,2,4], (num) => num * 2)
@meatherly
meatherly / popular_pizza.js
Created July 11, 2018 04:27
Get most popular Pizza
@meatherly
meatherly / SassMeister-input.scss
Created February 12, 2016 19:20
Generated by SassMeister.com.
// ----
// libsass (v3.2.5)
// ----
.top-level {
.nested-again {
.some-parent {
color: balk;
.somclass {
margin: 0 auto;
@meatherly
meatherly / creating_hipchat_connect_notes.md
Created January 9, 2016 21:07
Creating HipChat Connect add-ons notes

Creating HipChat Connect add-ons Notes

All this was created by reading all the sections under Extensions Points on this page.

This is just my general notes/guide on creating and implementing a HipChat Connect add-on. You can learn more here.

Descriptor

First you'll need to provide a Descriptor. You can provide this via REST endpoint on your server. Use this tool to validate your Descriptor: http://atlassian-connect-validator.herokuapp.com/validate?product=hipchat

defmodule BusTracker.Session do
alias BusTracker.User
alias BusTracker.Repo
def login(params, repo) do
user = repo.get_by(User, email: String.downcase(params["email"]))
case authenticate(user, params["password"]) do
true -> {:ok, user}
_ -> :error
end
defmodule EpBot.Handlers.ImageMe do
use Hedwig.Handler
@usage """
Calls on hubot to image something.
"""
@default_params %{v: "1.0", rsz: "8", safe: "active"}
@google_search_url "https://ajax.googleapis.com/ajax/services/search/images"
def handle_event(%Message{delayed?: false} = msg, opts) do
@meatherly
meatherly / Vagrantfile.rb
Created July 28, 2015 14:59
Vagrant Phoenix set up
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.