Skip to content

Instantly share code, notes, and snippets.

View naartjie's full-sized avatar

Marcin Jekot naartjie

View GitHub Profile

I've been working with Apache Kafka for over 7 years. I inevitably find myself doing the same set of activities while I'm developing or working with someone else's system. Here's a set of Kafka productivity hacks for doing a few things way faster than you're probably doing them now. 🔥

Get the tools

@mscharley
mscharley / Dockerfile.web
Last active February 16, 2021 22:05
Example Dockerfile for static compilation of ReasonML / OCaml projects using esy.
# vim: set filetype=dockerfile :
FROM node:10.13-alpine as build
ENV TERM=dumb \
LD_LIBRARY_PATH=/usr/local/lib:/usr/lib:/lib
# Create a subuser so that NPM doesn't whine about running as root
RUN adduser -D -H -h /usr/src/app web && \
mkdir -p /usr/src/app && \
chown web:web /usr/src/app && \
@Leonidas-from-XIV
Leonidas-from-XIV / lwt_ppx_let.ml
Last active January 2, 2022 15:10
Using Lwt with ppx_let instead of ppx_lwt
module Let_syntax = struct
let return = Lwt.return
let (>>=) = Lwt.Infix.(>>=)
let (>>|) = Lwt.Infix.(>|=)
module Let_syntax = struct
let bind m ~f = Lwt.bind m f
end
end
@naartjie
naartjie / curl.sh
Created March 6, 2018 10:16
curl POST example
curl --request POST \
--url 'https://usX.api.mailchimp.com/3.0/lists/57afe96172/members' \
--user 'anystring:apikey' \
--header 'content-type: application/json' \
--data '{"email_address":"urist.mcvankab+3@freddiesjokes.com", "status":"subscribed"}' \
--include
@jaredly
jaredly / BasicServer.re
Created January 2, 2018 05:24
Simple Static File Server in Reason/OCaml
let recv = (client, maxlen) => {
let bytes = Bytes.create(maxlen);
let len = Unix.recv(client, bytes, 0, maxlen, []);
Bytes.sub_string(bytes, 0, len)
};
let parse_top = top => {
let parts = Str.split(Str.regexp("[ \t]+"), top);
switch (parts) {
@fredeerock
fredeerock / docker_cleanup.md
Last active May 19, 2020 04:05
clean up docker

Stop all containers:

  • docker ps -aq | xargs docker stop

Remove all containers:

  • docker ps -aq | xargs docker rm

Remove all images:

  • docker images -aq | xargs docker rmi

Remove all networks:

@joewalnes
joewalnes / simple-http-server.kt
Created November 20, 2017 18:58
Minimal embedded HTTP server in Kotlin using Java built in HttpServer
import com.sun.net.httpserver.HttpServer
import java.io.PrintWriter
import java.net.InetSocketAddress
/**
* Minimal embedded HTTP server in Kotlin using Java built in HttpServer
*/
fun main(args: Array<String>) {
HttpServer.create(InetSocketAddress(8080), 0).apply {
// Option C:
// this implementation has a small amount of overhead compared to (a) and (b)
const React = require('react');
const counterState = React.createStateReducer({
initialState: props => ({
counter: 0,
divRef: React.createRef(),
}),
reducer: (action, state) => {
@busypeoples
busypeoples / PhantomTypeReasonML.md
Last active February 6, 2024 21:29
Phantom types in ReasonML

Phantom types in ReasonML

Introduction

"A phantom type is a parametrised type whose parameters do not all appear on the right-hand side of its definition..." Haskell Wiki, PhantomType

The following write-up is intended as an introduction into using phantom types in ReasonML.

Taking a look at the above definition from the Haskell wiki, it states that phantom types are parametrised types where not all parameters appear on the right-hand side. Let's try to see if we can implement a similar example as in said wiki.

@crittermike
crittermike / wget.sh
Last active March 26, 2024 22:49
Download an entire website with wget, along with assets.
# One liner
wget --recursive --page-requisites --adjust-extension --span-hosts --convert-links --restrict-file-names=windows --domains yoursite.com --no-parent yoursite.com
# Explained
wget \
--recursive \ # Download the whole site.
--page-requisites \ # Get all assets/elements (CSS/JS/images).
--adjust-extension \ # Save files with .html on the end.
--span-hosts \ # Include necessary assets from offsite as well.
--convert-links \ # Update links to still work in the static version.