Skip to content

Instantly share code, notes, and snippets.

Avatar

Gustavo Rodrigues qgustavor

View GitHub Profile
View fix-scaling.js
const fs = require('fs')
async function main () {
const files = await fs.promises.readdir('.')
for (const file of files) {
if (!file.endsWith('.ass')) continue
const data = await fs.promises.readFile(file, 'utf-8')
const lines = data.split(/\r?\n/g)
const timeCounts = {}
View anime-handler-comment.js
// ----------------------- recipe -----------------------
// -- Convert files from queue until the buffer gets 12 files
// Files are converted based on the source
// * 10 bit videos are converted to 8 bit
// * 4:4:4 videos are converted to 8 bit with -pix_fmt yuv420p
// * AC3 audios are converted to AAC
// * (maybe) splited MKVs are merged (needs to run before ffmpeg)
// -- Check if the next 12 to 24 files were downloaded
View pesquisa-de-animes-2.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@qgustavor
qgustavor / index.md
Last active Feb 19, 2021
Bookmarklet que pula as músicas de animes
View index.md

Se você não aprecia as músicas de animes, você não está sozinho.

Vários serviços tratam as aberturas e encerramentos como se fossem algo desnecessário. Mesmo quando os serviços têm licença para traduzir eles preferem não traduzir pois acham que não são importantes. Se você não gosta, tudo bem, você foi influenciado a também achar que o trabalho de vários animadores é algo que só pode ser apreciado uma vez só e não tem quase nenhuma importância.

Se quiser pular, pule.

@qgustavor
qgustavor / mega.js
Last active Oct 31, 2020
Simple MEGA downloader
View mega.js
export async function getMegaFile (megaUrl) {
const { handler, wrappedKey } = parseMegaUrl(megaUrl)
const url = await getDownloadUrl(handler)
const response = await fetch(url)
if (!response.ok) throw Error('MEGA request failed with ' + response.statusText)
const data = await response.arrayBuffer()
return decryptAesCtr(data, unwrapMegaKey(wrappedKey))
}
@qgustavor
qgustavor / locodol-karaoke.svg
Last active Aug 7, 2020
Karaoke animation in the episode 12 of Locodol at 13:04
View locodol-karaoke.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@qgustavor
qgustavor / a-minha-irmã-osakaense-não-sabe-mexer-com-javascript.svg
Last active Aug 7, 2020
A Minha Irmã Osakaense Não Sabe Mexer Com JavaScript
View a-minha-irmã-osakaense-não-sabe-mexer-com-javascript.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@qgustavor
qgustavor / swap-quotes.js
Last active Aug 8, 2020
Swap quotes to handle quotation of titles already containing quotes.
View swap-quotes.js
function swapQuotes (input) {
const quotesStr = `'"“‘”’`
return input.replace(/['"“”‘’]/g, e => quotesStr.charAt(quotesStr.indexOf(e) ^ 1))
}
// Example usage:
// const episodeName = 'Marge Simpson in: "Screaming Yellow Honkers"'
// <div>This user watched "{{ swapQuotes(episodeName) }}" in...</div>
// Should return <div>This user watched "Marge Simpson in: 'Screaming Yellow Honkers'" in...</div>
@qgustavor
qgustavor / ass-text-replacer.js
Created May 14, 2020
Replace text in ASS subtitles ignoring formatting
View ass-text-replacer.js
function replaceAssText (source, replacerFn) {
// Detect all non-dialogue tokens and mark those with null characters
const lines = source.replace(/\0/g, '').split('\n')
const nonReplaceableTokens = []
const replaceableTokens = []
let nonTextAccumulator = ''
for (let line of lines) {
if (!line.startsWith('Dialogue: ')) {
nonTextAccumulator += line + '\n'
@qgustavor
qgustavor / jumpcutter.js
Created May 10, 2020
Jumpcutter, like carykh's.
View jumpcutter.js
(function () {
let a = new AudioContext
let V = document.querySelector('video')
let v = a.createMediaElementSource(V)
let SP = a.createScriptProcessor(256, 1, 1)
let counter = 0
let scriptName = 'JUMPCUTTER'
window[scriptName] = {
threshold: 0.001,