Skip to content

Instantly share code, notes, and snippets.

@tripulse
tripulse / ET.js
Created May 12, 2019 17:21
The emote-transform API in JavaScript. Transforms normal-English text to Emotes.
/**
* (c) Copyright 2019 nullptr.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@tripulse
tripulse / YTWaveForm.js
Last active May 21, 2019 14:41
Waveform/Time-Domain view of a YouTube video's audio stream
var audioCtx = new AudioContext();
var source = audioCtx.createMediaElementSource(
document.querySelector('video')
);
var analyser = audioCtx.createAnalyser();
source.connect(analyser);
analyser.connect(audioCtx.destination);
analyser.fftSize = 1024;
// The MIT License (MIT)
//
// Copyright (c) 2019 vnullptr
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@tripulse
tripulse / strip2byte.py
Last active June 24, 2020 04:34
A small script to strip characters in filenames that don't fall in the range of 7-bit ASCII codepoints. This script is useful if the filename should be restricted to English (letters+punctuations).
#!/bin/python
import glob
from sys import argv
from argparse import ArgumentParser
from os import rename
_parser = ArgumentParser(
"Strip28Bit",
description= "Strips multi-byte UNICODE strings in"
" filenames into 7-bit ASCII strings",
@tripulse
tripulse / lndkrss.py
Created October 31, 2019 15:27
Simple audio file extractor solely made to extract files from "The Lunduke Show's" RSS feed.
from collections import namedtuple
from urllib.request import urlopen, URLError
from xml.etree import ElementTree
import os
REPLACE_DELIM = '_'
POSIX_ILLEGAL = '/'
WINNT_ILLEGAL = '<>:"/\\|?*'
def to_compat(filename: str, delimeter: str) -> str:
@tripulse
tripulse / sinempeg.cxx
Last active November 6, 2019 09:44
A simple encoder which encodes a "sine wave" with arbitrary frequency, amplitude, phase and samplerate into a MPEG Layer III file using "libshine".
#include <iostream>
#include <cmath>
#include <istream>
#include <vector>
#include <shine/layer3.h>
namespace Generators {
/* PI constant of Archimedes. Used to generate
sinusoids in this context. */
constexpr double PI = 3.14159265358979323846;
@tripulse
tripulse / snyth.cxx
Created November 9, 2019 08:15
Synthesizer of periodic waveforms
#include <cstdio>
#include "utils.hpp"
#include "tone.hpp"
#include <vector>
#include <cmath>
#define FLOAT_SIZE sizeof(float)
/**
* Enumeration of perodic functions to generate a waveform.
@tripulse
tripulse / imagegen.py
Created December 25, 2019 06:28
A image generator implemented in Python which works as a infinite source of image frames, with user defined image generation.
from typing import List, Tuple, Dict
"""
Framebuffer's top level array contains all rows which contains all the pixels.
All the pixels are triplets of 8-bit RGB (Truecolour).
"""
FrameBuffer = List[List[Tuple[int]]]
class ImageGenerator():
"""
@tripulse
tripulse / bytewriter.py
Last active June 24, 2020 04:23
File-stream emulation with Python buffer API.
import io
class ByteWriter(io.RawIOBase):
"""
Emulates file-writing by pushing the content into a underyling buffer.
Underlying buffer stores the data contents in the RAM, dumps them when required.
>>> from bytewriter import ByteWriter
>>> b = ByteWriter()
>>> b.write(b"Hello World")
{
"1": "one or won",
"2": "to, too, or two",
"4": "for, four, or the prefix or suffix: fore)",
"86": "out of, or over",
"411": "information",
"@": "at",
"@teotd": "at the end of the day",
"14aa41": "one for all and all for one",
"2b or not 2b": "to be or not to be",