Skip to content

Instantly share code, notes, and snippets.

document.whenPageIsReady = function (callback) {
if (
document.readyState === 'complete' ||
document.readyState === 'interactive'
) {
callback();
} else {
document.addEventListener('DOMContentLoaded', callback, { once: true });
}
};
@jpcercal
jpcercal / build-dig-for-aarch64-using-musl.sh
Created March 29, 2025 13:31
Build "dig" for aarch64 (tested on Asus Router RT-BE88U) using MUSL leveraging docker to do so
# How to run it?
#
# Create a file on the current directory named "Dockerfile.bind-tools", and place
# the entire content of this gist onto it, save, and run the following:
#
# rm -Rf ./dig && \
# docker build -f Dockerfile.bind-tools -t dig-static-builder . && \
# docker run --rm -v "$PWD:/out" dig-static-builder /bin/sh -c "cp /dig /out/dig" && \
# echo "\n\n\nldd ./dig" && \
# docker run --rm -v "$PWD:/work" -w /work --platform linux/arm64 alpine ldd ./dig && \
async resolveCycleDuration() {
const defaultCycle = 28;
if (true) {// the user does not have a complete cycle yet, we use the default information
return defaultCycle;
}
// const lastThreeCycles = select nomeDaColuna (first date where cycle starts) from table where users_id = <user-id> and date >= <date> date <= <date> ORDER BY date DESC (because we want to get the latest date first whihch is the closest to the current time as of now)
@jpcercal
jpcercal / clear-selenium-grid-hub-sessions.js
Created February 21, 2024 12:05
Use it to clear the sessions started and left open by selenium grid hub when terminating the executing un-gracefully
async function clearSessions() {
try {
const url = 'http://127.0.0.1:4444';
// Get information about all active sessions on the Selenium Grid hub
const response = await fetch(`${url}/status`);
const data = await response.json();
// Loop through all active sessions and terminate them
for (const node of data.value.nodes) {
{
"version": "2.0.122.1",
"settings": {
"blur": 0,
"brightness": 100,
"contrast": 100,
"grayscale": 0,
"huerotate": 0,
"invert": 0,
"saturate": 100,
@jpcercal
jpcercal / add-p.md
Created May 23, 2023 13:08 — forked from mattlewissf/add-p.md
Lightning Talk: Git add -p

git add -p is your friend

git add -p is basically "git add partial (or patch)"

Patch mode allows you to stage parts of a changed file, instead of the entire file. This allows you to make concise, well-crafted commits that make for an easier to read history. This feature can improve the quality of the commits. It also makes it easy to remove parts of the changes in a file that were only there for debugging purposes - prior to the commit without having to go back to the editor.

It allows you to see the changes (delta) to the code that you are trying to add, and lets you add them (or not) separately from each other using an interactive prompt. Here's how to use it:

from the command line, either use

  • git add -p
@jpcercal
jpcercal / osx-for-hackers.sh
Created November 14, 2017 17:37 — forked from brandonb927/osx-for-hackers.sh
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned.
#!/bin/sh
###
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer)
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos
###
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx
resume:
name: João Paulo Cercal
job:
en: Senior Software Engineer
pt_BR: Engenheiro de Software Sênior
de_DE: Softwareentwickler
location:
en: Munich, Germany
pt_BR: Munique, Alemanha
de_DE: München, Deutschland
@jpcercal
jpcercal / article.md
Created April 26, 2017 21:30
Article

How do you get your environment variables using PHP?

You probably get your environment variables using built-in PHP functions such as getenv or $_ENV, but did you know that you can do it in an elegant way getting the value of an environment variable in the properly PHP data type with the powerful library? If you are curious, just read how this energetic library can help you in your daily development workflow.

Note that in this article we'll use a famous library to load environment variables from an external file, this library is vlucas/phpdotenv.

Then, firstly, you need to install the dependencies. To do it, simply type this in your terminal:

$ composer require vlucas/phpdotenv
@jpcercal
jpcercal / download-patches.sh
Created November 7, 2016 17:23 — forked from mzeis/download-patches.sh
Download Magento CE security patches SUPEE-1533 ad SUPEE-8788 v2 using bash. Open the file for usage information.
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
# Author: Matthias Zeis (https://github.com/mzeis, https://twitter.com/mzeis)
# Date: 2016/10/17
# Version: 1.0
# License: MIT (https://en.wikipedia.org/wiki/MIT_License)
#