Skip to content

Instantly share code, notes, and snippets.

@pbadenski
pbadenski / Dockerfile
Last active October 26, 2022 13:49
Node 18.X layer for AWS lambda
FROM public.ecr.aws/amazonlinux/amazonlinux:2
RUN yum groupinstall -y development
RUN yum install -y tar xz python3
RUN yum install -y which clang cmake
RUN mkdir -p /build /opt
WORKDIR /build
RUN curl -fsL https://ftp.gnu.org/gnu/make/make-4.3.tar.gz | tar xzf -
@pbadenski
pbadenski / connect.ts
Created August 23, 2019 09:06
refract-react-redux connect
import React, { Context } from "react";
import {
InferableComponentEnhancerWithProps,
MapDispatchToPropsFunction,
MapStateToProps
} from "react-redux";
import { Aperture, toProps, withEffects } from "refract-rxjs";
import { combineLatest, concat, Observable, of } from "rxjs";
import { auditTime, first, map, startWith } from "rxjs/operators";
import { auditMap, connect as connect_ } from "rxjs-redux";
@pbadenski
pbadenski / README.md
Last active February 21, 2023 10:52
Oauth2 authentication for zipkin web UI using oauth2_proxy

Tech: nginx + oauth2_proxy

  1. Install oauth2_proxy (https://github.com/bitly/oauth2_proxy):

    $ go get github.com/bitly/oauth2_proxy
    
  2. Set up your favourite OAuth2 provider (see https://github.com/bitly/oauth2_proxy for detailed instructions)

  3. Run:

$ oauth2_proxy --client-id=CLIENT_ID --client-secret=CLIENT_SECRET --cookie-secret=COOKIE_SECRET --email-domain=pricingmonkey.com

@pbadenski
pbadenski / priority-based-task-execution.ts
Created February 28, 2017 16:49
Priority based task execution in JS using WebWorker
const FastPriorityQueue = require("fastpriorityqueue");
const setZeroTimeout = (callback: any) => {
const channel = new MessageChannel();
channel.port1.onmessage = callback;
channel.port2.postMessage("");
};
const queue: any = new FastPriorityQueue( (a: any, b: any) =>
a.data.priority > b.data.priority
@pbadenski
pbadenski / Outer$delayedInit$body.class
Created July 12, 2016 10:19
Outer implements DelayedInit
public final class io.halik.scala.Outer$delayedInit$body extends scala.runtime.AbstractFunction0
minor version: 0
major version: 50
flags: ACC_PUBLIC, ACC_FINAL, ACC_SUPER
{
private final io.halik.scala.Outer $outer;
descriptor: Lio/halik/scala/Outer;
flags: ACC_PRIVATE, ACC_FINAL
(...)
// from http://mbostock.github.com/d3/ex/chord.html
var chord = d3.layout.chord()
.padding(0.05)
.sortSubgroups(d3.descending)
.matrix([
[11975, 5871, 8916, 2868],
[ 1951, 10048, 2060, 6171],
[ 8010, 16145, 8090, 8045],
[ 1013, 990, 940, 6907]
@pbadenski
pbadenski / gist:2688654
Created May 13, 2012 14:20
haskell money types
data Dollars = Dollars
data Euro = Euro
class Money a where
(+) :: (Int, a) -> (Int, a) -> Int
(+) (a, _) (b, _) = (Prelude.+) a b
instance Money Dollars
instance Money Euro
@pbadenski
pbadenski / gist:731903
Created December 7, 2010 15:27
Newspeak start error
7 December 2010 4:26:41 pm
VM: Win32 - Newspeak Virtual Machine 10.02.2201
Image: nsboot-2010-02-22.00 [latest update: #0]
SecurityManager state:
Restricted: false
FileAccess: true
SocketAccess: true
Working Dir c:\Program Files\Newspeak Virtual Machine
; Refactor of http://www.fatvat.co.uk/2009/05/neural-networks-and-clojure.html
(defn create-network
[out]
(repeat out 0))
(defn run-network
[input weights]
(if
(> (reduce + (map * input weights)) 0.001)
(use 'clojure.contrib.test-is)
(def now (new java.util.Date))
(defn date [year month day]
(new java.util.Date (- year 1900) (dec month) day))
(with-test
(defn business-method [date]
(let [after #(pos? (compare %1 %2))]