Skip to content

Instantly share code, notes, and snippets.

View qgustavor's full-sized avatar
🎯
Focusing

Gustavo Rodrigues qgustavor

🎯
Focusing
View GitHub Profile
@qgustavor
qgustavor / population-model.js
Created May 7, 2024 16:14
Population model to simulate what could happen if two female woman could have female children together and children had 95% chance of inheriting their parents' sexuality
// Function to interpolate missing rates
function interpolateRate(rates, age) {
const surroundingRates = Object.entries(rates)
.filter(([key]) => Number(key) <= age)
.sort((a, b) => Number(a[0]) - Number(b[0])) // Sort by age (ascending)
if (surroundingRates.length === 0) {
// No rates available, return 0 (adjust as needed)
return 0
}
@qgustavor
qgustavor / cifras.user.js
Last active March 23, 2024 03:50
Keep Cifras Awake
// ==UserScript==
// @name Keep Cifras Awake
// @namespace http://tampermonkey.net/
// @version 2024-03-21
// @description try to take over the world!
// @author You
// @match https://www.cifraclub.com.br/*
// @icon https://icons.duckduckgo.com/ip2/cifraclub.com.br.ico
// @grant none
// @require https://unpkg.com/@zakj/no-sleep@0.13.5/dist/no-sleep.umd.cjs
@qgustavor
qgustavor / Reddit no longer exists.user.js
Last active June 11, 2023 17:25
An userscript to aid people addited on Reddit to forget that this website ever existed
// ==UserScript==
// @name Reddit no longer exists
// @namespace http://tampermonkey.net/
// @version 0.1
// @description An userscript to aid people addited on Reddit to forget that this website ever existed
// @author qgustavor
// @match https://*.reddit.com/*
// @icon https://icons.duckduckgo.com/ip2/reddit.com.ico
// @grant none
// @run-at document-start
// ==UserScript==
// @name Detect Reddit Copy Bot Comments
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Detect copied comments in Old Reddit.
// @author qgustavor
// @match https://*.reddit.com/*
// @icon https://icons.duckduckgo.com/ip2/reddit.com.ico
// @grant none
// ==/UserScript==
import * as dnssd from 'npm:ya-dns-sd'
const timeout = Number(Deno.args[0]) || 30
// Check if it's needed and prompt
const connectedDevices = new TextDecoder().decode(await Deno.run({
cmd: ['adb', 'devices'],
stdout: 'piped'
}).output()).split(/\r?\n/g).filter(e => e).slice(1).map(e => e.split('\t')[0])
@qgustavor
qgustavor / fix-subtitles.js
Created February 1, 2023 00:44
A customizable script that fixes common issues in anime subtitles such as wrong romanization, bad line breaking, basic time shifts and font scaling
import { parseFlags } from 'https://deno.land/x/cliffy@v0.25.7/flags/mod.ts'
import parse from 'https://cdn.skypack.dev/pin/@qgustavor/ass-parser@v0.2.2-3MSleKF9Tb13M9TVjKIV/mode=imports/optimized/@qgustavor/ass-parser.js'
import stringify from 'https://cdn.skypack.dev/pin/@qgustavor/ass-stringify@v0.1.8-dniPlKxAanwMSbtHFyUD/mode=imports/optimized/@qgustavor/ass-stringify.js'
import JSON5 from 'https://deno.land/x/json5@v1.0.0/mod.ts'
const defaultConfig = {
targetDir: '..',
filenameReplacement: null,
handleLineBreaks: false,
shiftTimes: false,
const functions = [
(e, target, source) => Math.round(e * target / source),
(e, target, source) => Math.floor(e * target / source),
(e, target, source) => Math.ceil(e * target / source),
(e, target, source) => 1 + Math.round((e - 1) * target / source),
(e, target, source) => 1 + Math.floor((e - 1) * target / source),
(e, target, source) => 1 + Math.ceil((e - 1) * target / source),
(e, target, source) => Math.round((e - 1) * target / source),
(e, target, source) => Math.floor((e - 1) * target / source),
(e, target, source) => Math.ceil((e - 1) * target / source),
@qgustavor
qgustavor / recursive-readdir.js
Last active November 8, 2022 18:34
Recursive implementation of Deno.readDir
export async function* recursiveReadDir (url) {
for await (const dirEntry of Deno.readDir(url)) {
if (dirEntry.isDirectory) {
yield * recursiveReadDir(new URL(dirEntry.name, url.href + '/'))
} else if (dirEntry.isFile) {
yield new URL(dirEntry.name, url.href + '/')
}
}
}
@qgustavor
qgustavor / list.md
Last active October 3, 2022 14:16
List of Crunchyroll series previously available for free locked to only-members per date
@qgustavor
qgustavor / microphone-keyboard.js
Created September 13, 2022 22:04
Download nircmdc, ffmpeg and deno, run using "deno run -A microphone-keyboard.js"
import FFT from 'https://raw.githubusercontent.com/qgustavor/stream-audio-fingerprint/master/src/lib/fft.ts'
let device = Deno.args[0]
if (!device) {
const devicesProcess = await Deno.run({
cmd: ['ffmpeg', '-list_devices', 'true', '-f', 'dshow', '-i', 'dummy'],
stderr: 'piped'
})
const devicesOutput = new TextDecoder().decode(await devicesProcess.stderrOutput())
const devices = Array.from(devicesOutput.matchAll(/\[dshow.* "(.*)" \(audio\)/g)).map(e => e[1])