Skip to content

Instantly share code, notes, and snippets.

@AbeEstrada
AbeEstrada / html_entities_decode
Created April 16, 2024 19:26
A script to decode html entities
#!/usr/bin/env zsh
if [ -t 0 ]; then
# Argument
input="$1"
else
# STDIN
input="$(cat /dev/stdin)"
fi
@AbeEstrada
AbeEstrada / device.py
Created February 19, 2024 19:30
Support MPS
device = 'cuda' if torch.cuda.is_available() else 'mps' if torch.backends.mps.is_available() else 'cpu'
@AbeEstrada
AbeEstrada / loudness.rb
Created September 6, 2023 04:52 — forked from kylophone/loudness.rb
FFmpeg loudnorm filter - dual pass loudness normalization example - http://k.ylo.ph/2016/04/04/loudnorm.html
#!/usr/bin/env ruby
require 'open3'
require 'json'
ffmpeg_bin = '/usr/local/bin/ffmpeg'
target_il = -16.0
target_lra = +11.0
target_tp = -1.0
samplerate = '41k'
@AbeEstrada
AbeEstrada / disableChromeUpdates.sh
Created May 18, 2023 17:35
Disable Google Autoupdater on macOS
launchctl unload -w ~/Library/LaunchAgents/com.google.keystone.xpcservice.plist
launchctl unload -w ~/Library/LaunchAgents/com.google.keystone.agent.plist
echo > ~/Library/LaunchAgents/com.google.keystone.xpcservice.plist
echo > ~/Library/LaunchAgents/com.google.keystone.agent.plist
chmod 644 ~/Library/LaunchAgents/com.google.keystone.xpcservice.plist
chmod 644 ~/Library/LaunchAgents/com.google.keystone.agent.plist
sudo chown root ~/Library/LaunchAgents/com.google.keystone.xpcservice.plist
@AbeEstrada
AbeEstrada / index.mjs
Last active January 5, 2023 00:05
Privnote + AWS Lambda
import { S3Client, PutObjectCommand, GetObjectCommand, DeleteObjectCommand } from "@aws-sdk/client-s3";
const s3Client = new S3Client({ region: "us-east-1" });
const Bucket = "BUCKET_NAME_GOES_HERE";
export const handler = async (event) => {
let statusCode = 200;
let body = ``;
if (event.requestContext.http.method === "POST") {
@AbeEstrada
AbeEstrada / gist:382d2fdd9ae41e75a81c9d2416745485
Last active April 17, 2022 02:01
macOS: Disable Chrome CORS
open -a "Google Chrome" --args --user-data-dir="/tmp/chrome_dev_test" --disable-web-security
console.log(JSON.stringify(data ?? null, null, 2))
[...Array(10).keys()]
const sleep = ms => new Promise(res => setTimeout(res, ms));
const sum = arr => arr.reduce((sum, n) => sum + n, 0)
const avg = arr => sum(arr) / arr.length
@AbeEstrada
AbeEstrada / axiosDownloadImage.js
Created April 12, 2022 21:33
Node axios download image
import { writeFile } from "fs/promises";
import axios from "axios";
const main = async () => {
try {
const response = await axios.get(`${FILE_URL}`, { responseType: "arraybuffer" });
try {
await writeFile(`./${FILE_NAME}.jpg`, response.data);
} catch(err) {
console.log(err);
const formatDate = (date) => {
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, "0");
const day = String(date.getDate()).padStart(2, "0");
const hours = String(date.getHours()).padStart(2, "0");
const minutes = String(date.getMinutes()).padStart(2, "0");
const seconds = String(date.getSeconds()).padStart(2, "0");
return `${[year, month, day].join("/")} ${[hours, minutes, seconds].join(":")}`;
};
@AbeEstrada
AbeEstrada / last.sh
Created January 22, 2022 03:25
ffmpeg: get last frame from video
ffmpeg -sseof -3 -i input.mp4 -update 1 -q:v 1 last.jpg