Skip to content

Instantly share code, notes, and snippets.

View jpcaparas's full-sized avatar
🐔

JP Caparas jpcaparas

🐔
View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / commands.txt
Created September 1, 2023 01:29
macOS: Make Spotlight focus on application on a different Space
# Disable indexing
sudo mdutil -a -i off
# Re-enable indexing
sudo mdutil -a -i on
@jpcaparas
jpcaparas / delete_git_submodule.md
Created September 27, 2023 10:09 — forked from myusuf3/delete_git_submodule.md
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
@jpcaparas
jpcaparas / workstation.yaml
Created October 22, 2023 22:52
Ansible workstation (AMD64 & ARM64)
---
- name: Install multiple packages on localhost for arm64 and amd64 architectures
hosts: localhost
gather_facts: true
connection: local
become: true
become_method: sudo
tasks:
- name: Update package list
apt:
@jpcaparas
jpcaparas / cmd.sh
Last active February 7, 2024 09:11
Quickly spin up a MySQL container that's bind-mounted to a host volume and include an accompanying PHPMyAdmin UI
#!/bin/bash
# Some args are OrbStack-specific
# To enter the instance, run:
# docker exec -it kiwinoy_mysql8 mysql -u root -p
docker run \
-d \
--rm \