Skip to content

Instantly share code, notes, and snippets.

Wander Hillen WJWH

  • Amsterdam
Block or report user

Report or block WJWH

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
WJWH / gist:2d4cb80f2799256e8703d2e904d0b707
Last active Jul 25, 2019
Generic dockerfile for statically compiled Crystal applications
View gist:2d4cb80f2799256e8703d2e904d0b707
# See for the reasoning behind each line
# Build stage
FROM durosoft/crystal-alpine:0.28.0 as build
COPY shard.yml shard.yml
RUN shards install --production
COPY . ./
RUN crystal build src/ --release --static
View gist:8c2b4fe31e29c77e4a165bd50a71a6a9
# omg this is such a long comment, good thing I can spread it out over multiple lines like this so it will be clear for my colleagues what this code will do
WJWH / redisparsing.hs
Created Dec 31, 2018
Parsing the redis replication stream with AttoParsec
View redisparsing.hs
{-# LANGUAGE OverloadedStrings #-}
module RedisParsing where
import Control.Exception
import qualified Data.ByteString as B
import Data.Attoparsec.ByteString as AB
import Data.Attoparsec.ByteString.Char8
import Data.List
import Network.Socket hiding (recv)
import Network.Socket.ByteString (recv, sendAll)
Created Oct 15, 2018
The double hijack trick, serving 65k connections from a single ruby process
# This server demo does a socket hijack in Rack and then saves the socket to a global variable
# to prevent it from being GCed when the Puma thread ends. It will then write "BEEP" to each
# socket every ten seconds to prevent the connection timing out. During testing, it easily
# handled up to 65523 connections, after which it ran into the `ulimit` for open file descriptors.
# The bit with the waiting area is there because a normal `Set` is not thread safe and it would
# drop socket due to race conditions. The `Queue` is thread safe and will make sure all sockets
# are preserved.
# run with `rackup -q -p 8000 -o`
# testing: install `ab` and then run `ab -c 20000 -n 20000 <ip adress of server>:8000/
You can’t perform that action at this time.