Skip to content

Instantly share code, notes, and snippets.

View jpcaparas's full-sized avatar
🐔

JP Caparas jpcaparas

🐔
View GitHub Profile
@jpcaparas
jpcaparas / command.sh
Created May 28, 2023 08:39
Running video2x as a container to convert a video to 4K
# Change arguments as needed
docker run --rm -it --name video2x_container -v $PWD/video2x:/tmp ghcr.io/k4yt3x/video2x:5.0.0-beta6 -i /tmp/to_upscale.mp4 -o /tmp/upscaled.mp4 -l=debug upscale -h=2160 -w=3840
@jpcaparas
jpcaparas / podman_macos.md
Created March 27, 2023 00:09 — forked from kaaquist/podman_macos.md
Podman with docker-compose on MacOS.

Podman with docker-compose on MacOS.

Podman an alternative to Docker Desktop on MacOS

Getting podman installed and started is super easy.
Just use brew to install it.

> brew install podman

Now since podman uses a VM just like the Docker Client on MacOS we need to initialize that and start it.

@jpcaparas
jpcaparas / script.js
Created August 20, 2022 05:19
Postman pre-request script to generate a signature string for spatie/laravel-webhook-client
// Do this:
// - Set a `webhook_secret` variable that what you've set on the webhook server.
// This generates a signature string from the header
var signatureString = CryptoJS.HmacSHA256(request.data, pm.environment.get('webhook_secret')).toString();
// This dynamically generates the {{signature}} variable. Create a Signature header with {{signature}} as the value.
pm.environment.set('signature', signatureString);
@jpcaparas
jpcaparas / commands.txt
Last active July 15, 2022 02:07
Change default timezone on MariaDB (brew installation)
# Take note of the current time zone:
sudo mysql -e "SELECT @@global.time_zone;"
# Run NOW() to see if that time zone is actually being used:
mysql -e "SELECT NOW();"
# Say for example, you want to turn it into UTC, run:
@jpcaparas
jpcaparas / directly_from_sns_client.js
Created February 7, 2022 00:37
AWS | Publish SNS from Lambda
const { SNSClient, PublishCommand } = require("@aws-sdk/client-sns"); // This requires a Lambda Layer to be installed
exports.handler = async (event) => {
var eventText = JSON.stringify(event, null, 2);
var client = new SNSClient({region: process.env.REGION});
var params = {
Message: eventText,
Subject: "Test SNS From Lambda",
@jpcaparas
jpcaparas / poll.js
Created December 6, 2021 20:24
Polling
// https://levelup.gitconnected.com/polling-in-javascript-ab2d6378705a
export default const poll = ({ fn, validate, interval, maxAttempts }) => {
console.log('Start poll...');
let attempts = 0;
const executePoll = async (resolve, reject) => {
console.log('- poll');
const result = await fn();
attempts++;
@jpcaparas
jpcaparas / nginx.conf
Last active August 18, 2025 21:27
Make a node application work with PM2 & Laravel Forge
# FORGE CONFIG (DO NOT REMOVE!)
include forge-conf/<your-site>/before/*;
map $sent_http_content_type $expires {
"text/html" epoch;
"text/html; charset=utf-8" epoch;
default off;
}
server {
@jpcaparas
jpcaparas / script.js
Last active February 27, 2026 16:32
Tampermonkey: Load an external script and CSS
// ==UserScript==
// @name HackerNews
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://news.ycombinator.com/
// @require https://bennettfeely.com/ztext/js/ztext.min.js
// @resource REMOTE_CSS http://127.0.0.1:8080/style.css
// @grant GM_xmlhttpRequest
@jpcaparas
jpcaparas / BenchmarksPerformance.php
Last active August 24, 2020 03:37
Dumps or logs performance in Laravel
<?php
/**
* Dumps or logs performance of code.
*/
class BenchmarksPerformance
{
private static $startTime;
private static $startLine;
@jpcaparas
jpcaparas / README.md
Created August 14, 2019 08:38 — forked from stokkes/README.md
Rclone Plex Sonarr Radarr Read&Write

Rclone v1.40 for Plex/Sonarr/Radarr Read/Write

This small guide should help you get setup with rclone v1.40 to read/write directly to a cache mount and have Plex get notified of new tv/movies that get added to the mount by Radarr/Sonarr

Assumptions

  1. You're using rclone v1.40
  2. You're using Radarr & Sonarr
  3. If you're using docker for plex/sonarr/radrr, you must ensure the volumes attached to the containers are all the same path, i.e.: /mnt/user/media:/media for all 3. If not, the auto-scan will likely not work properly.