Skip to content

Instantly share code, notes, and snippets.

View patrickfav's full-sized avatar
🐿️
Nam nam nam

Patrick Favre patrickfav

🐿️
Nam nam nam
View GitHub Profile
@patrickfav
patrickfav / RandomOrgUtil.java
Last active August 18, 2020 17:44
Random.org Signed Response Verification (Java)
/*
Copyright 2017 Patrick Favre-Bulle
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@patrickfav
patrickfav / gsap-404-typed-message-using-splittext.markdown
Created October 23, 2020 20:44
GSAP 404 typed message using SplitText
@patrickfav
patrickfav / sigma-js-angular-app.js
Last active February 25, 2023 13:12
Simple Sigma.js AngularJs Directive: Since I did not find any angularjs directive for angularjs I created a little simple of my own. This is by no means a ready-for-all solutions, but all the features I needed at the time; it is easily extended to your needs and maybe sometimes somebody will do a full-blown directive for sigma.js Tested: angular…
/*
* Copyright 2017 Patrick Favre-Bulle
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@patrickfav
patrickfav / encoding_info.txt
Last active February 26, 2023 18:40
Overview of Many Popular Binary-to-Text Encodings and their properties.
## Binary
┌─────────────────┬──────────────────────────────────────────────────────────────────┐
│ Efficiency │ 12.5 % (1 bit/char), 1 bit segments │
│ 32/64/128 bit │ 1-32/1-64/1-128 chars │
│ Padding │ false │
│ Const. Out. Len.│ false │
│ Suited for │ number encoding, debugging │
│ Alphabet │ 01 │
│ Known Usages │ none │
@patrickfav
patrickfav / encoded_compressed_stats.txt
Last active February 26, 2023 18:41
Statistics for required space for encoded vs. compressed.
## Random Data
Original size: 1024 byte
Compressed size (raw): 1047 byte
Name enc diff % enc-comp diff
------------------------------------------------------------------
base85 1280 256 23% 1076 29 2%
base64 1366 342 31% 1073 26 2%
base36 1585 561 51% 1082 35 3%
@patrickfav
patrickfav / mac-rnd-sizes.md
Last active February 26, 2023 18:53
Research of ID-Mask SIV Engine MAC & Randomization Byte Lengths.

Proposed Lengths for ID Encryption Schema

32-bit Integer

Integer Value MAC Version Randomization Sum Base64/Base32
deterministic 4 byte 12 byte 1 byte - 17 byte (136 bit) 22/27
randomized 4 byte 12 byte 1 byte 10 byte 27 byte (216 bit) 36/43
@patrickfav
patrickfav / head.html
Last active March 18, 2023 15:29
A hugo shortcode that obfuscates email addresses; makes it more difficult for bots to crawl it from your website. Add the html file to your "layouts/shortcodes/" folder then you can use it in your content.
{{/* If you are using a CSP header this is how you can whitelist the inline-script */}}
{{/* its not optimal since it only changes every day and only if you regenerate the site */}}
{{ $currentDayNonce := now | time.Format "2006-01-02" | md5 }}
<meta http-equiv="Content-Security-Policy"
content="default-src 'self';
script-src 'self' 'nonce-{{ $currentDayNonce }}';
img-src 'self';"
/>
@patrickfav
patrickfav / plugin-so-turndown.ts
Last active March 30, 2023 16:58
A Turndown Plugin parsing figures with captions; creates the format '![imgText](https://example.com/img.png "caption")' Turndown is a JS Markdown Parser see https://www.npmjs.com/package/turndown
export const figureCaption = function (service: TurndownService): void {
service.addRule('stackOverflowHighlightedCodeBlock', {
filter: function (node: HTMLElement, options: Options): boolean | null {
const firstChild = node.firstChild
const lastChild = node.lastChild
return (
node.nodeName === 'FIGURE' &&
firstChild && firstChild.nodeName === 'IMG' &&
lastChild && lastChild.nodeName === 'FIGCAPTION'
)
@patrickfav
patrickfav / encrypt_img_ecb.sh
Created November 17, 2018 14:24
Encrypt .ppm file with AES-ECB to show ECB will reveal patterns
#!/bin/sh
# This is part of my blog about AES: https://medium.com/p/7616beaaade9
# Inspired by https://blog.filippo.io/the-ecb-penguin/
# Convert your image to .ppm with Gimp or Photoshop
#
# Usage: ./ecb_img <image file as ppm> <password>
# extract header and body
/*
* Copyright 2017 Patrick Favre-Bulle
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software