Skip to content

Instantly share code, notes, and snippets.

View cieplak's full-sized avatar

Patrick Cieplak cieplak

  • Stripe
  • San Francisco, Oakland
View GitHub Profile
@miguno
miguno / kafka-move-leadership.sh
Last active July 6, 2023 19:53
A simple Ops helper script for Apache Kafka to generate a partition reassignment JSON snippet for moving partition leadership away from a given Kafka broker. Use cases include 1) safely restarting a broker while minimizing risk of data loss, 2) replacing a broker, 3) preparing a broker for maintenance.
#!/usr/bin/env bash
#
# File: kafka-move-leadership.sh
#
# Description
# ===========
#
# Generates a Kafka partition reassignment JSON snippet to STDOUT to move the leadership
# of any replicas away from the provided "source" broker to different, randomly selected
# "target" brokers. Run this script with `-h` to show detailed usage instructions.
@CMCDragonkai
CMCDragonkai / channels.hs
Last active January 6, 2019 22:55
Haskell: Channels - an explanation from Tackling the Awkward Squad http://research.microsoft.com/en-us/um/people/simonpj/papers/marktoberdorf/mark.pdf
import Control.Concurrent.MVar
type Channel a = (ReadPort a, WritePort a)
type ReadPort a = MVar (Stream a)
type WritePort a = MVar (Stream a)
type Stream a = MVar (Item a)
data Item a = MkItem a (Stream a)
newChan :: IO (Channel a)
newChan = do
@aaronlevin
aaronlevin / 01-simplest-thing-that-works.hs
Last active August 30, 2019 02:49
Proxy Serialization Post
{-# LANGUAGE OverloadedStrings #-}
module SimpleThings where
import Control.Applicative ((<$>), (<*>))
import Control.Monad (mzero)
import Data.Aeson
import qualified Data.Aeson as A
-- | sum type containing all possible payloads
@jbgi
jbgi / Term.java
Last active November 6, 2024 12:48
Generalized Algebraic Data Types (GADT) in Java
import static java.lang.System.*;
import java.util.function.BiFunction;
import java.util.function.Function;
// Implementation of a pseudo-GADT in Java, translating the examples from
// http://www.cs.ox.ac.uk/ralf.hinze/publications/With.pdf
// The technique presented below is, in fact, just an encoding of a normal Algebraic Data Type
// using a variation of the visitor pattern + the application of the Yoneda lemma to make it
// isomorphic to the targeted 'GADT'.
/(1sale|2020ave|204st|247inc|2mdn|2o7|33across|360yield|3gl|3lift|4seeresults|5min|7eer|a.analytics.yahoo|ab_api.circleofmoms|abmr|actnx|acuityplatform|acxiom|ad4game|adadvisor|adaptly|adap.tv|adblade|adbuyer|adc-serv|ad.datam|addthis|add-this|adelixir|adform|adgrx|adingo.jp|adis|adition|adjug|adjuggler|adlegend|admailtiser|admaym|admeld|admized|ad.movad|adnxs|adobedigital|adobedtm|adobetag|adpredictive|adpublik|adq.nextag|adrdgt|ad.retargeter|adroll|adrsp|ads2.goember|ads.advanceweb|adsafeprotected|ads.al|ads.brand|ads.bridgetrack.|adsbyisocket|adscale.de|ads.cleveland|adsdk|ads.ebay|adserver|adsfac.eu|adsflix|ads.goember|ads.intergi|ads.kmdisplay|ads.lfstmedia|ads.masslive|ads.mlive|ads.nba|ads.nj|ads.nola|adsonar|ads.oregonlive|ads.pennlive|adsrvr.org|ads.syracuse|ads.yahoo|adsymptotic|adtag|adtechus|adtegrity|adtpix|advertising|affec.tv|afy11|agilone|airpr|ak1.abmr|akamai|alenty|ally|amain|amazon|amgdgt|amxdt|analytic|analytics|analytics.strangeloopnetworks|answerscloud|anx.batanga|aolcdn|api.bizographics
@sdiehl
sdiehl / state.hs
Created January 13, 2015 18:44
State monad implementation + example
import Control.Monad
-------------------------------------------------------------------------------
-- State Monad Implementation
-------------------------------------------------------------------------------
newtype State s a = State { runState :: s -> (a,s) }
instance Monad (State s) where
return a = State $ \s -> (a, s)
@markandrewj
markandrewj / tmux.conf
Last active April 9, 2024 01:56
Basic Tmux Status Bar
# ----------------------
# Status Bar
# -----------------------
set-option -g status on # turn the status bar on
set -g status-utf8 on # set utf-8 for the status bar
set -g status-interval 5 # set update frequencey (default 15 seconds)
set -g status-justify centre # center window list for clarity
# set-option -g status-position top # position the status bar at top of screen
# visual notification of activity in other windows
@soheilhy
soheilhy / nginxproxy.md
Last active June 30, 2025 13:43
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@jkreps
jkreps / benchmark-commands.txt
Last active May 20, 2025 13:37
Kafka Benchmark Commands
Producer
Setup
bin/kafka-topics.sh --zookeeper esv4-hcl197.grid.linkedin.com:2181 --create --topic test-rep-one --partitions 6 --replication-factor 1
bin/kafka-topics.sh --zookeeper esv4-hcl197.grid.linkedin.com:2181 --create --topic test --partitions 6 --replication-factor 3
Single thread, no replication
bin/kafka-run-class.sh org.apache.kafka.clients.tools.ProducerPerformance test7 50000000 100 -1 acks=1 bootstrap.servers=esv4-hcl198.grid.linkedin.com:9092 buffer.memory=67108864 batch.size=8196
@garu
garu / Perl Encryption Primer.md
Last active September 13, 2022 01:54
Perl Encryption Primer, by Timm Murray

Perl Encryption Primer

by Timm Murray

This is a compilation of the "Perl Encryption Primer" series of articles by Timm Murray, as published on http://www.wumpus-cave.net/category/encryption/. I have taken the liberty of moving the content here (as is), formatting it as Markdown and ordering them chronologically from top to bottom to easen the reading experience. Enjoy!

Timm also made a one-hour video of the presentation he gave at MadMongers, which summarizes the content below.