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. 🔥
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 && \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
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:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) => { |
"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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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. |
NewerOlder