Skip to content

Instantly share code, notes, and snippets.

@garthk
garthk / user_main.c
Last active July 25, 2018 07:55
ESP8266_RTOS_SDK PDM ESP8266 playing 512Hz sine wave over UART
#include <stdio.h>
#include <stdint.h>
#include <esp_libc.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "rom/ets_sys.h"
#include "driver/uart.h"
#include "driver/gpio.h"
#include "esp_system.h"
@garthk
garthk / demo.geojson
Created August 30, 2018 01:16
@turf/buffer breaking change
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@garthk
garthk / h2o2.d.ts
Created December 17, 2018 23:59
Quick and dirty typings for h2o2 version 8.1
import { BoomError } from 'boom';
import { Request, HandlerDecorations, ResponseToolkit } from 'hapi';
import { Agent, IncomingMessage } from 'http';
import { Server, PluginPackage } from 'hapi';
import { ResponseObject } from 'hapi';
export interface ProxyHandlerOptions {
host?: string;
port?: number | string;
protocol?: 'http' | 'https';
@garthk
garthk / LICENSE.txt
Last active March 19, 2019 22:31
Generate an AWS CloudWatch Logs event as if an AWS Lambda executed
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
@garthk
garthk / README.md
Created April 23, 2019 22:46
Honeycomb Beeline Header Parsing and Formatting in Elixir
@garthk
garthk / README.md
Created May 15, 2019 06:50
Overkill With GenStage

Strikes me I'm just re-inventing poolboy, here.

@garthk
garthk / opencensus_honeycomb_phoenix_integration_test.exs
Last active June 2, 2019 06:09
Now-successful attempt at a Phoenix integration test
defmodule Opencensus.Honeycomb.PhoenixIntegrationTest do
use ExUnit.Case, async: false
use Phoenix.ConnTest
alias Jason
alias Opencensus.Honeycomb.Event
alias Opencensus.Honeycomb.Sampler
defmodule HelloWeb.OpencensusTracePlug do
use Opencensus.Plug.Trace, attributes: [:release]
@garthk
garthk / README.md
Last active October 17, 2019 01:16
Basic Risk Register Workflow for Slack
@garthk
garthk / Dockerfile
Last active January 13, 2020 00:28
Demonstrates a way to trigger Credo.Code.ParserError
FROM elixir:1.9.4-alpine
ADD . /root
WORKDIR /root
RUN mix do local.hex --force, deps.get
ENTRYPOINT []
CMD ["mix", "credo", "--strict", "credo732.ex"]
@garthk
garthk / pascal_case.ex
Created January 17, 2020 00:45
Pascal case conversion in Elixir
@doc "Convert a string or atom to a pascal case string"
@spec pascal_case(String.t() | atom()) :: String.t()
def pascal_case(name)
def pascal_case(name) when is_atom(name), do: name |> Atom.to_string() |> pascal_case()
def pascal_case(name) when is_binary(name) do
~r{(\W|_)+}
|> Regex.split(name)
|> Enum.map(&capitalise/1)
|> Enum.to_list()