Skip to content

Instantly share code, notes, and snippets.

@renesugar
renesugar / dawg.py
Created February 15, 2025 17:51 — forked from smhanov/dawg.py
Use a DAWG as a map
#!/usr/bin/python3
# By Steve Hanov, 2011. Released to the public domain.
# Please see http://stevehanov.ca/blog/index.php?id=115 for the accompanying article.
#
# Based on Daciuk, Jan, et al. "Incremental construction of minimal acyclic finite-state automata."
# Computational linguistics 26.1 (2000): 3-16.
#
# Updated 2014 to use DAWG as a mapping; see
# Kowaltowski, T.; CL. Lucchesi (1993), "Applications of finite automata representing large vocabularies",
# Software-Practice and Experience 1993
@renesugar
renesugar / RemarkablePlugin.js
Created February 2, 2025 22:08 — forked from barretts/RemarkablePlugin.js
Remarkable JS Markdown parser plugin tutorial
/**
* Created by Barrett Sonntag barretts@github on 3/2/2015.
* http://www.sosuke.com/writing-custom-extensions-for-the-remarkable-javascript-markdown-parser
*
* A plugin tutorial for Remarkable https://github.com/jonschlinkert/remarkable
*/
var markdownParser = new Remarkable();
// open links in new windows
@renesugar
renesugar / README.rst
Created February 2, 2025 04:38 — forked from dupuy/README.rst
Common markup for Markdown and reStructuredText

Markdown and reStructuredText

GitHub supports several lightweight markup languages for documentation; the most popular ones (generally, not just at GitHub) are Markdown and reStructuredText. Markdown is sometimes considered easier to use, and is often preferred when the purpose is simply to generate HTML. On the other hand, reStructuredText is more extensible and powerful, with native support (not just embedded HTML) for tables, as well as things like automatic generation of tables of contents.

@renesugar
renesugar / animated-svg-recorder.js
Created January 10, 2025 20:33 — forked from VityaSchel/animated-svg-recorder.js
Record animated SVG on websites (animated by lottie and similar tools)
let recordedChanges = []
let startRecordingSVG = () => { recordedChanges = [] }
let stopRecordingSVG = () => { console.log(JSON.stringify(recordedChanges)) }
let observer = new MutationObserver(mutationRecords => {
for(const record of mutationRecords) {
if(record.attributeName === 'd') {
recordedChanges.push(record.target.getAttribute('d'))
}
}
@renesugar
renesugar / wpa_cli
Created September 6, 2022 19:31 — forked from buhman/00 wpa_cli passphrase network
wpa_cli example; it might be worth mention that you can tab-complete all wpa_supplicant commands
[zack@leto ~]$ sudo tee << EOF /etc/wpa_supplicant.conf > /dev/null
ctrl_interface=/run/wpa_supplicant
EOF
[zack@leto ~]$ sudo wpa_supplicant -iwlp1s0 -Dnl80211 -c/etc/wpa_supplicant.conf -B
Successfully initialized wpa_supplicant
[zack@leto ~]$ sudo wpa_cli
wpa_cli v2.0
Copyright (c) 2004-2012, Jouni Malinen <[email protected]> and contributors
This software may be distributed under the terms of the BSD license.
@renesugar
renesugar / arch-mac-mini.md
Created September 6, 2022 19:28 — forked from andrsd/arch-mac-mini.md
Install Arch linux on Mac Mini (late 2012)

Install Arch Linux on Mac mini

We will be creating dual boot for OS X and Linux with no special boot loader. For other setup, refer to [1]. We will keep all data on an external hard drive, so we do not need huge amount of space for the linux system. We will install from an USB thumb drive (will need at least 1GB in size), newer Minis do not have CD roms.

Prepare the disk in Mac OS X (El Capitan)

@renesugar
renesugar / collisionLSH.py
Created August 14, 2021 06:26 — forked from unrealwill/collisionLSH.py
Proof of Concept : generating collisions on a neural perceptual hash
import tensorflow as tf #We need tensorflow 2.x
import numpy as np
#The hashlength in bits
hashLength = 256
def buildModel():
#we can set the seed to simulate the fact that this network is known and doesn't change between runs
#tf.random.set_seed(42)
model = tf.keras.Sequential()
@renesugar
renesugar / arraybuffer.transfer.js
Created May 11, 2021 03:16 — forked from nphyx/arraybuffer.transfer.js
A polyfill for ArrayBuffer.prototype.transfer that is substantially faster than a naive byte-by-byte transfer implementation.
if(typeof(ArrayBuffer.prototype.transfer) === "undefined") {
ArrayBuffer.prototype.transfer = function transfer(old) {
var dva, dvb, i, mod;
dva = new DataView(this);
dvb = new DataView(old);
mod = this.byteLength%8+1;
for(i = 0; i <= old.byteLength-mod; i+=8) dva.setFloat64(i, dvb.getFloat64(i));
mod = this.byteLength%4+1;
if(i < old.byteLength-mod) {
dva.setUint32(i, dvb.getUint32(i));
function memcpy (src, srcOffset, dst, dstOffset, length) {
var i
src = src.subarray || src.slice ? src : src.buffer
dst = dst.subarray || dst.slice ? dst : dst.buffer
src = srcOffset ? src.subarray ?
src.subarray(srcOffset, length && srcOffset + length) :
src.slice(srcOffset, length && srcOffset + length) : src
@renesugar
renesugar / utf8.js
Created May 10, 2021 22:42 — forked from pascaldekloe/utf8.js
JavaScript UTF-8 encoding and decoding with TypedArray
// This is free and unencumbered software released into the public domain.
// Marshals a string to an Uint8Array.
function encodeUTF8(s) {
var i = 0, bytes = new Uint8Array(s.length * 4);
for (var ci = 0; ci != s.length; ci++) {
var c = s.charCodeAt(ci);
if (c < 128) {
bytes[i++] = c;
continue;