A Pen by Patrick Favre-Bulle on CodePen.
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
$sourceFolder = "C:\path\to\pngs" | |
$sumSavedKb = 0 | |
# Get all PNG files recursively | |
Get-ChildItem -Path $sourceFolder -Recurse -Filter *.png | ForEach-Object { | |
$file = $_.FullName | |
$jpgFile = [System.IO.Path]::ChangeExtension($file, "jpg") | |
# Get the old file size (in kB) | |
$oldfilesize = [Math]::Round((Get-Item -LiteralPath $file).Length / 1KB, 2) |
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
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' | |
) |
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 TurndownService from "turndown"; | |
export const stackOverflowHighlightedCodeBlock = function (service: TurndownService): void { | |
const highlightRegExp = /lang-([a-z0-9]+)/ | |
service.addRule('stackOverflowHighlightedCodeBlock', { | |
filter: function (node: HTMLElement, options: Options): boolean | null { | |
const firstChild = node.firstChild | |
return ( | |
node.nodeName === 'PRE' && |
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
{{/* 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';" | |
/> |
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
package at.favre.lib.bytes.otherPackage; | |
import org.junit.Test; | |
import javax.crypto.Cipher; | |
import javax.crypto.SecretKey; | |
import javax.crypto.spec.GCMParameterSpec; | |
import javax.crypto.spec.SecretKeySpec; | |
import java.nio.ByteBuffer; | |
import java.nio.charset.StandardCharsets; |
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
## 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 │ |
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 at.favre.lib.bytes.Bytes; | |
import org.openjdk.jmh.annotations.*; | |
import org.openjdk.jmh.infra.Blackhole; | |
import java.util.concurrent.TimeUnit; | |
@SuppressWarnings("CheckStyle") | |
@State(Scope.Thread) | |
@Fork(1) | |
@Warmup(iterations = 2, time = 4) |
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
## 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% |
NewerOlder