Skip to content

Instantly share code, notes, and snippets.

[
{
"type": 3,
"data": {
"source": 3,
"id": 1,
"x": 0,
"y": 6142
},
"timestamp": 1682519560545
@pauldambra
pauldambra / gen-flow.py
Created August 3, 2022 13:05
Generate mermaid tree from file imports
import dataclasses
import re
from typing import List, Optional
file_links: List[str] = [
# laziness here - regenerate with `grep '(import.*insight.*)' ./frontend/src -Er --include="*.ts*" --exclude="*test.ts*" --exclude="*type.ts" --exclude="*stories.tsx"`
"./frontend/src/scenes/insights/filters/FunnelExclusionsFilter.tsx:import { ActionFilter } from 'scenes/insights/filters/ActionFilter/ActionFilter'",
"./frontend/src/scenes/insights/filters/FunnelExclusionsFilter.tsx:import { insightLogic } from 'scenes/insights/insightLogic'",
"./frontend/src/scenes/insights/filters/FunnelExclusionsFilter.tsx:import { MathAvailability } from 'scenes/insights/filters/ActionFilter/ActionFilterRow/ActionFilterRow'",
"./frontend/src/scenes/insights/filters/PathCleaningFilter.tsx:import { insightLogic } from 'scenes/insights/insightLogic'",
@pauldambra
pauldambra / posthog-cloudfront.ts
Created July 20, 2022 10:08
A gist to create a cloudfront proxy for PostHog
import * as cdk from "aws-cdk-lib";
import * as cloudfront from "aws-cdk-lib/aws-cloudfront";
import * as cloudfront_origins from "aws-cdk-lib/aws-cloudfront-origins";
import { Construct } from "constructs";
// created by PostHog user CJ Enright
// shared in our community slack https://posthogusers.slack.com/archives/CTLTM70RM/p1657732914776719
// many thanks to them 🙌💖
export class PostHogProxy extends cdk.Stack {
constructor(scope: Construct, id: string) {
// ==UserScript==
// @name Fade Twitter
// @namespace http://tampermonkey.net/
// @version 0.3
// @description fades twitter over time and by scrolling to protect me from myself
// @author You
// @match https://twitter.com/*
// @grant none
// ==/UserScript==

Keybase proof

I hereby claim:

  • I am pauldambra on github.
  • I am pauldambra (https://keybase.io/pauldambra) on keybase.
  • I have a public key ASAYR6eRH7elrx4m5_M8YzzJBQ4WF5ZLeisyF2tBxz8RPgo

To claim this, I am signing this object:

@pauldambra
pauldambra / example.java
Last active August 18, 2018 08:45
Beautiful
private static final Splitter newlineSplitter = Splitter.on(Pattern.compile("\r?\n"));
private static final Splitter spaceSplitter = Splitter.on(CharMatcher.whitespace()).omitEmptyStrings();
Map<String, String> substitutions = newlineSplitter
.splitToList(text)
.stream()
.map(spaceSplitter::splitToList)
.filter(r -> r.size() != 0)
.collect(Collectors.toMap(
ss -> ss.get(0),
@pauldambra
pauldambra / something.cs
Created January 26, 2017 14:11
Application Services as Open Closed...
public class Command {}
public class GetStockCommand("name", 10M) : Command {
//set properties
DateAdded = DateTime.now;
}
public interface IHandle<Command, TResult>
{
TResult Handle(Command command);
}
@pauldambra
pauldambra / ElasticSearchIntegration.cs
Created November 8, 2016 11:09
Setting up for ElasticSearch Integration tests
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NCrunch.Framework
{
public abstract class ResourceUsageAttribute : Attribute
{
@pauldambra
pauldambra / gist:6b9cee1d7c39aa7893606927ca969d22
Created September 16, 2016 16:10
akka.net test that fails before Tell has had time to run
public class WhenContentWasAlreadyPublished : TestKit, ILoadUmbracoNodes, IPublishUmbracoContent
{
private IContent _content;
private IContent _publishedContent;
private bool _publishContentCalled;
[Fact]
public void ItPublishesWhenAsked()
{
var publisherProps = UmbracoAdmin.ContentPublishing.NodePublisher.Props(this, this);
@pauldambra
pauldambra / checkout-kata.exs
Created December 29, 2015 15:33
the checkout kata in elixir
defmodule Checkout do
defstruct [
basket: %{A: 0, B: 0, C: 0, D: 0}
]
def scan(checkout, code) do
new_value = checkout.basket[code] + 1
%{checkout | basket: Map.put(checkout.basket, code, new_value)}
end