Skip to content

Instantly share code, notes, and snippets.

@mfuerstenau
mfuerstenau / zigzag-encoding.README
Last active October 17, 2024 04:35
ZigZag encoding/decoding explained
ZigZag-Encoding
---------------
Maps negative values to positive values while going back and
forth (0 = 0, -1 = 1, 1 = 2, -2 = 3, 2 = 4, -3 = 5, 3 = 6 ...)
(i >> bitlength-1) ^ (i << 1)
with "i" being the number to be encoded, "^" being
XOR-operation and ">>" would be arithemtic shifting-operation
@regeda
regeda / rope.c
Created February 21, 2017 21:16
Rope data structure built on splay tree
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#define MAX_LEN 300001
typedef struct _rope {
int offset, len, size;
char *s;
struct _rope *left, *right, *parent;
@erose
erose / decrypt_cookie.rb
Created April 24, 2017 02:50
Decrypt a Rails 5 session cookie
@unkmas
unkmas / Dockerfile
Last active April 4, 2020 02:29
Princeton algs course Dockerfile
FROM openjdk:8
# Install algs4 wrapper
RUN mkdir -p /usr/local/algs4 \
&& cd /usr/local/algs4 \
&& curl -O "https://algs4.cs.princeton.edu/code/algs4.jar" \
&& curl -O "https://algs4.cs.princeton.edu/linux/{javac,java}-{algs4,cos226,coursera}" \
&& find ./ -regextype posix-extended -regex '.*(javac|java)-(algs4|cos226|coursera)' -exec sh -c 'chmod 755 $1 && mv $1 /usr/local/bin' - {} \;
# Install findbugs