Skip to content

Instantly share code, notes, and snippets.

View jdmichaud's full-sized avatar

jdmichaud

View GitHub Profile
@jdmichaud
jdmichaud / ANSI.md
Created August 12, 2021 06:34 — forked from fnky/ANSI.md
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1b
  • Decimal: 27
@jdmichaud
jdmichaud / ncat-proxy.sh
Created August 18, 2021 08:42
To defeat the CORS madness, push request to this server which will then forward to a particular server while adding the necessary CORS header
ncat -klnvp 8080 --sh-exec "\ # Start ncat in listening mode and redirect input AND output to a shell command
grep --line-buffered GET | \ # retrieve only GET request
sed --unbuffered -e 's@GET \([^ ]*\) HTTP/1.1@\1\n\n@g' | \ # From the GET request, retrieve the path
xargs -i{} curl -sSL -w '\n\n\n' -D - http://host:port/{} | \ # Redirect the path to a specific host:port
tee -a /tmp/curl-response | \ # For debug purposes
sed --unbuffered -e 's@\(Content-Length: [0-9]*\)@\1\nAccess-Control-Allow-Origin: *@g' | \ # Add the CORS header
tee -a /tmp/proxy.log" # For debug purposes
@jdmichaud
jdmichaud / wiki-data.md
Last active August 20, 2021 14:09
Wikipedia data jungle

Dump pages: https://dumps.wikimedia.org/
The format of the url of a dump file is https://<host>/<wikisite>/<dumpdate>/<file>

simplewiki

A dataset for simple testing is simplewiki: https://dumps.wikimedia.org/simplewiki/20210801/
Simple english contains wiki ~300000 article. Easy to download and test idea against.

Files

Files are dumped in different formats for different purposes.

@jdmichaud
jdmichaud / zig2wasm.sh
Created August 23, 2021 18:29
Zig to WASM
$ cat > test.zig
export fn add(lhs: f32, rhs: f32) f32 {
return lhs + rhs;
}
$ zig build-lib test.zig -target wasm32-freestanding -dynamic
$ cat > test.js
WebAssembly.instantiate((function() {
const source = require("fs").readFileSync("test.wasm");
return new Uint8Array(source);
})(), { env: {} }).then(wasm => {
@jdmichaud
jdmichaud / test.md
Last active August 28, 2021 10:56 — forked from ityonemo/test.md
Zig in 30 minutes

A half-hour to learn Zig

This is inspired by https://fasterthanli.me/blog/2020/a-half-hour-to-learn-rust/

Basics

the command zig run my_code.zig will compile and immediately run your Zig program. Each of these cells contains a zig program that you can try to run (some of them contain compile-time errors that you can comment out to play with)

@jdmichaud
jdmichaud / index.html
Created September 29, 2021 08:50
Simple web workers without specific JS file
<html>
<head>
<meta charset="utf-8">
<link rel="shortcut icon" href="#" />
<title>WW</title>
<script type="text/javascript" src="index.js"></script>
</head>
<body>
</body>
@jdmichaud
jdmichaud / gitall
Created October 15, 2021 14:21
Execute a command in all the git repos in the current folder
#!/usr/bin/env bash
if [ $# -lt 1 ]
then
echo "$0: error: missing arguments"
echo "usage: $0 <command> <args...>"
exit 1
fi
for folder in `find . -maxdepth 1 ! -path . -type d`
@jdmichaud
jdmichaud / list-dependencies.sh
Created November 22, 2021 16:46
List all dependencies on an npm package, the released installed and the time the package of that release was uploaded to artifactory
#!/usr/bin/env bash
# List all dependencies, the released installed and the time the package of that release was uploaded to artifactory
dependencies=`cat <(jq -r '.devDependencies | keys[]' package.json) <(jq -r '.dependencies | keys[]' package.json)`
for dependency in $dependencies
do
version=`jq -r .dependencies.\"$dependency\".version package-lock.json`
time=`npm show $dependency --json | jq -r .time.\"$version\"`
echo $dependency $version $time
done
@jdmichaud
jdmichaud / README.md
Last active June 26, 2022 09:10
Map related stuff
@jdmichaud
jdmichaud / README.md
Last active February 11, 2022 15:55
Look Up Table and WebGL

In webgl.html is presented a method that loads an array of 16 bits unsigned values representing grayscale intensities being processed through a LUT. An javascript implementation is provided for reference.

In webgl2.html adds the handling of signed data in addition to unsigned data and using integer texture.