Skip to content

Instantly share code, notes, and snippets.

View jpcaparas's full-sized avatar
🐔

Jayps jpcaparas

🐔
View GitHub Profile
@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 October 16, 2023 14:11
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 14, 2024 19:49
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.
@jpcaparas
jpcaparas / commands.sh
Last active July 14, 2019 09:15
docker-compose systemd template
# Start the service
sudo systemctl start docker-compose@myservice
# Enable the service at runtime
sudo systemctl enable docker-compose@myservice
# Disable the service at runtime
sudo systemctl enable docker-compose@myservice
# Stop the service
@jpcaparas
jpcaparas / mnt-sharesies.mount
Created June 27, 2019 23:21
CIFS mount systemd
[Unit]
Description=sharesies mount
Requires=network-online.target
After=network-online.service
[Mount]
What=//192.168.1.200/Sharesies
Where=/mnt/sharesies
Options=username=user,password=pass,rw,iocharset=utf8,vers=2.0
Type=cifs
@jpcaparas
jpcaparas / selenium
Created June 21, 2019 04:14
Selenium Standalone Server wrapper
# usr/local/bin/selenium
#!/usr/bin/env bash
set -e
# Download from https://www.seleniumhq.org/download/
SELENIUM_PATH=/opt/selenium/selenium-server-latest.jar
SELENIUM_PORT=5555