Skip to content

Instantly share code, notes, and snippets.

View JPBM135's full-sized avatar
🎯
Focusing

João Pedro Borges Martins JPBM135

🎯
Focusing
View GitHub Profile
@JPBM135
JPBM135 / Timestamp.ts
Created August 11, 2024 02:53
Timestamp class to help with time conversion
export class Timestamp {
public static SECOND_IN_MILLISECONDS = 1000;
public static MINUTE_IN_MILLISECONDS = 60 * Timestamp.SECOND_IN_MILLISECONDS;
public static HOUR_IN_MILLISECONDS = 60 * Timestamp.MINUTE_IN_MILLISECONDS;
public static DAY_IN_MILLISECONDS = 24 * Timestamp.HOUR_IN_MILLISECONDS;
private readonly _timestampMilliseconds: number;
private constructor(timestampMilliseconds: number) {
this._timestampMilliseconds = timestampMilliseconds;
@JPBM135
JPBM135 / create-keys.sh
Created July 31, 2024 09:05
Nginx config for server client and /api with cloudflare
cd ~
mkdir sslcertificates
openssl req -x509 -newkey rsa:4096 -keyout privatekey.pem -out certificate.pem -days 365 -nodes -subj '/CN=localhost'
@JPBM135
JPBM135 / hack.js
Created July 31, 2024 03:22
Hack import.meta.url with esbuild esm to cjs
const metaUrl = Reflect.has(globalThis, 'require') ? import.meta.url : pathToFileURL(__filename);
@JPBM135
JPBM135 / tranparency_report.md
Last active August 11, 2024 03:09
Transparency Report undocumented API
@JPBM135
JPBM135 / uploadFolderToApplicationEmojis.mjs
Last active May 15, 2025 07:01
Sync folder to discord application emojis
import { readdirSync, readFileSync, writeFileSync } from "fs";
import { setTimeout } from "timers/promises";
const APPLICATION_ID = "APPLICATION_ID";
const TOKEN =
"BOT_TOKEN";
const discordApiUrl = `https://discord.com/api/v10/applications/${APPLICATION_ID}/emojis`;
const headers = {
@JPBM135
JPBM135 / cap-2.md
Last active June 19, 2024 04:41
Clean Code

Meaningful Names

Intention revealing names

- const d = '18/06/2024; // Date today
+ const dateToday = '18/06/2024;

Avoid variables with implicit meaning

@JPBM135
JPBM135 / combined_parser_and_input.py
Last active May 24, 2024 03:08
Parser for CSM draws
from bs4 import BeautifulSoup
from urllib.request import urlopen
import json
import os
import re
BASE_URL = "https://www.canada.ca/"
HTML_PAGE_PATH_SUFFIX = "en/immigration-refugees-citizenship/services/immigrate-canada/express-entry/submit-profile/rounds-invitations.html"
INPUT_HTML = """
@JPBM135
JPBM135 / QueryBuilder.php
Last active May 3, 2024 03:31
Query Builder Php
<?php
define('QUERY_BUILDER_SEE_DEBUG', false);
define('QUERY_BUILDER_SORT_ASC', 'ASC');
define('QUERY_BUILDER_SORT_DESC', 'DESC');
define('QUERY_BUILDER_JOIN_INNER', 'INNER JOIN');
define('QUERY_BUILDER_JOIN_LEFT', 'LEFT JOIN');
define('QUERY_BUILDER_JOIN_RIGHT', 'RIGHT JOIN');
define('QUERY_BUILDER_JOIN_FULL', 'FULL JOIN');
@JPBM135
JPBM135 / tls.md
Created April 30, 2024 00:13
TLS Research

TLS

A widely adopted security protocol designed to facilitate privacy and data security for communications over the Internet.

The primary case of TLS is encrypting the communications betweem web applications and servers. Other use cases of TLS includes:

  • VoIP
  • Email
  • Messaging

TLS was proposed by the Internet Engineering Task Force (IETF), an international standards organization, and the first version of the protocol was published in 1999. The most recent version is TLS 1.3, which was published in 2018.

@JPBM135
JPBM135 / spec-en.md
Last active April 29, 2024 08:53
Ordenação por id anterior

Sorting by Previous ID

This specification details how the graph should behave with:

  • Changes in position
  • Archiving
  • Unarchiving

1. Structure