Skip to content

Instantly share code, notes, and snippets.

View generalmimon's full-sized avatar

Petr Pučil generalmimon

View GitHub Profile
@generalmimon
generalmimon / fileformats-url-digger.js
Created May 29, 2020 23:22
Dig URL paths from Just Solve The File Format Problem wiki in parallel with Node.js
const http = require('http');
const MAX_ACTIVE = 100; // maximum number of parallel requests
let numActiveReqs = 0;
let numWaitingReqs = 0;
const paths = new Set();
const options = {
host: 'fileformats.archiveteam.org',
port: 80,
# listing 4
seq:
- id: payload
type: type_info
size: 4 # not strictly necessary, but it's safer to wrap the `type_info` into the substream like this,
# because if the bitfields `types/type_info/seq` wouldn't fill the whole 4 bytes, it would still work
# (see https://doc.kaitai.io/user_guide.html#_streams_and_substreams)
types:
type_info:
seq:
@generalmimon
generalmimon / fetch-json-as-data-url.js
Last active September 6, 2020 11:26
Fetch JSON file on the Internet and convert it to Data URL (the JSON data will be Base64-encoded in the URL)
function fetchJSONAsDataURL(url) {
return fetch(url)
.then(r => r.blob())
.then(data =>
new Promise(
(resolve, reject) => {
const blob = new Blob([data], {type: 'application/json'});
const rdr = new FileReader();
rdr.onload = (e) => {
resolve(e.target.result);
meta:
id: cab
file-extension: cab
endian: le
license: CC0-1.0
doc-ref: http://download.microsoft.com/download/4/d/a/4da14f27-b4ef-4170-a6e6-5b1ef85b1baa/[ms-cab].pdf
seq:
- id: magic
contents: "MSCF"
@generalmimon
generalmimon / github-subscribe-to-repos.sh
Last active April 16, 2021 21:02
Bulk subscription to GitHub repos
#!/bin/sh
# SPDX-FileCopyrightText: 2020 Petr Pucil <[email protected]>
#
# SPDX-License-Identifier: CC0-1.0
while IFS= read -r line; do
echo "$line"
echo
curl \
-X PUT \
@generalmimon
generalmimon / textarea-drafts.js
Last active January 17, 2021 23:23
User JS to automatically save <textarea> contents into browser localStorage (intended for GitHub)
// Not working version right now, grab an older one from Revisions
(function(storageKey) {
'use strict';
const IDLE_DELAY = 10 * 1000; // in miliseconds
let timeout;
let currentPageKey = null;
class UrlSync {
constructor() {
@generalmimon
generalmimon / fallout-terminal-hacking-table.js
Last active April 16, 2021 20:58
A simple script for calculating a table with numbers of different letters between every two words
/**
* A simple script for calculating a table with numbers of different letters between every two words.
*
* Tip: open DevTools by Ctrl+Shift+I or F12 and paste it into the JavaScript Console :)
*
* @license
* SPDX-FileCopyrightText: 2021 Petr Pucil <[email protected]>
*
* SPDX-License-Identifier: CC0-1.0
*/
@generalmimon
generalmimon / deflate_stream.ksy
Last active February 15, 2021 12:31
(WIP) Kaitai Struct YAML specification of the raw DEFLATE compressed data stream format
meta:
id: deflate_stream
xref:
rfc: 1951
license: MIT
bit-endian: le
doc-ref: https://github.com/golang/go/blob/f90e89e/src/compress/flate/inflate.go#L301
seq:
- id: hdr
type: header
@generalmimon
generalmimon / log2_int32.ksy
Created January 30, 2021 14:41
A Kaitai Struct YAML specification for finding the log2 of a 32-bit integer
meta:
id: log2_int32
title: Find the log base 2 of a 32-bit integer
license: CC0-1.0
doc-ref: https://graphics.stanford.edu/~seander/bithacks.html#IntegerLog
# params:
# - id: val
# type: u4
seq:
- id: log2
@generalmimon
generalmimon / fix-nim-windows-no-ssl-ca-certs.md
Last active April 16, 2021 20:27
Fix Nim error saying "Could not download: No SSL/TLS CA certificates found." on Windows

If you're trying to do nimble install from https:// or another nimble internet task (e.g. nimble refresh) and you get the following error:

PS C:\nim-1.4.4> nimble install --verbose 'testify@#9871d37'