Skip to content

Instantly share code, notes, and snippets.

View tcarrio's full-sized avatar
🧙‍♂️

Tom Carrio tcarrio

🧙‍♂️
View GitHub Profile
@tcarrio
tcarrio / .env
Created October 2, 2022 04:45
Makefile with .env
EXAMPLE=deadbeef
@tcarrio
tcarrio / MissingInteger.md
Created December 5, 2021 16:21
MissingInteger: Find the smallest positive integer that does not occur in a given sequence

Write a function:

function solution(A);

that, given an array A of N integers, returns the smallest positive integer (greater than 0) that does not occur in A.

For example, given A = [1, 3, 6, 4, 1, 2], the function should return 5.

@tcarrio
tcarrio / codility-test-suite.js
Created December 5, 2021 05:21
Codility Test Suite (JavaScript)
/**
* Apache License
* Version 2.0, January 2004
* http://www.apache.org/licenses/
*
* TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
*
* 1. Definitions.
*
* "License" shall mean the terms and conditions for use, reproduction,
@tcarrio
tcarrio / useCallbackCache.js
Last active November 23, 2021 22:52
A React hook that supports cached memoization
import { useMemoCache } from "./useMemoCache";
export function useCallbackCache(fn, deps) {
return useMemoCache(() => fn, deps);
}
@tcarrio
tcarrio / index.html
Created April 27, 2021 01:36
battery-report-surface-pro-2
<!DOCTYPE html>
<!-- saved from url=(0016)http://localhost -->
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ms="urn:schemas-microsoft-com:xslt" xmlns:bat="http://schemas.microsoft.com/battery/2012" xmlns:js="http://microsoft.com/kernel"><head><meta http-equiv="X-UA-Compatible" content="IE=edge"/><meta name="ReportUtcOffset" content="-4:00"/><title>Battery report</title><style type="text/css">
body {
font-family: Segoe UI Light;
letter-spacing: 0.02em;
@tcarrio
tcarrio / sha512_crypt.py
Created October 20, 2020 03:16
Generates a random SHA512_Crypt (e.g. password hash)
#!/usr/bin/env python
import random
import string
from passlib.hash import sha512_crypt
# random 16 character salt
the_largest_salt_possible=''.join(random.choice(string.ascii_lowercase) for i in range(16))
# a large number of cycles to cop those pesky brutes
@tcarrio
tcarrio / background-noise-reduction-tools.md
Last active January 9, 2025 23:10
Background noise reduction tools (alternatives to RTX Voice)
@tcarrio
tcarrio / dbeaver.desktop
Created April 23, 2020 19:47
Override Java GTK Theme (example with DBeaver)
[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Name=DBeaver Community
GenericName=UniversaL Database Manager
Comment=Universal Database Manager and SQL Client.
Exec=sh -c "GTK_THEME='Arc' _JAVA_OPTIONS='-Dawt.useSystemAAFontSettings=on -Dswing.aatext=true -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel -Dswing.crossplatformlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel' dbeaver"
Icon=dbeaver
Categories=IDE
@tcarrio
tcarrio / README.md
Last active February 1, 2020 23:07
Generating a PKCS#12 from certbot obtained HTTPS certificates

Generating PKCS#12 from certbot Obtained Certificates

Assuming the certbot generated certificate, chain, and keys for the domain are located under

/etc/letsencrypt/live/domain.example/

You can generate the certificate file in PKCS#12 format by running the following

openssl pkcs12 -export -inkey /etc/letsencrypt/live/domain.example/privkey.pem -in /etc/letsencrypt/live/domain.example/cert.pem -certfile /etc/letsencrypt/live/domain.example/chain.pem -out certificate.p12

@tcarrio
tcarrio / jira_checkout.sh
Created January 29, 2020 22:22
Check out branch by Jira issue number
# Include in your .bashrc to access from the terminal
function gcoi() {
# Your Jira project tag
PROJ="MAV"
# Your projects branch naming convention
BRANCH_REGEX="(science|feature|bugfix|hotfix)/${PROJ}-${1}(|-.+)$"
# Get the provided issue number and validate it
OLD_IFS="${IFS}"
IFS='-'