Skip to content

Instantly share code, notes, and snippets.

View vanyle's full-sized avatar
💭

Antoine Delègue vanyle

💭
View GitHub Profile
@kmizu
kmizu / parsers.nim
Created July 1, 2016 00:51
parser combinator library in Nim
import strutils
import lists
import re
type
Parser[T] = proc(input: string): Maybe[(T, string)]
Maybe*[T] = object
value: T
hasValue: bool
@vanyle
vanyle / modding_discord.md
Last active June 14, 2024 18:29
Modding the Discord client

Modding the discord client

Disclaimer: Modding the discord client is against Discord's term of service. I'm not responsible if any action is taken against you.

Why modding ?

Modding the client will allow you to customize to:

  • change the appearance of the discord client
  • have script to automaticaly send messages at specific times
  • log messages from a chat into a local file

This guide will explain how to inject js code into the discord client and send messages. I'm assuming you know you to write javascript code and are using Windows.

# Here's a probably-not-new data structure I discovered after implementing weight-balanced trees with
# amortized subtree rebuilds (e.g. http://jeffe.cs.illinois.edu/teaching/algorithms/notes/10-scapegoat-splay.pdf)
# and realizing it was silly to turn a subtree into a sorted array with an in-order traversal only as an
# aid in constructing a balanced subtree in linear time. Why not replace the subtree by the sorted array and
# use binary search when hitting that leaf array? Then you'd defer any splitting of the array until inserts and
# deletes hit that leaf array. Only in hindsight did I realize this is similar to the rope data structure for strings.
# Unlike ropes, it's a key-value search tree for arbitrary ordered keys.
#
# The main attraction of this data structure is its simplicity (on par with a standard weight-balanced tree) and that it
# coalesces subtrees into contiguous arrays, which reduces memory overhead and boosts the performance of in-order traversals
@vanyle
vanyle / sound.js
Last active August 27, 2021 17:53
A JavaScript file to generate sounds procedurally on any browser by generating WAV files as data URI
// This function only generates pure frequencies but you can customize the waveform
// by changing the function at line ~50 (the one with the cos)
function sound(freq,volume,duration,fadeout){
// Generate a wav binary file, convert it to a blob and play it.
// https://fr.wikipedia.org/wiki/Waveform_Audio_File_Format#Structure_des_fichiers_WAV
const sampling = 44100; // in hertz
duration = duration || 1; // in seconds
const sampleCount = Math.floor(sampling * duration);