Skip to content

Instantly share code, notes, and snippets.

View zettca's full-sized avatar
⛰️

Bruno Henriques zettca

⛰️
View GitHub Profile
// Preview: docs
// Name: Open Cluster URL
// Shortcut: cmd shift k
import "@johnlindquist/kit";
const k8s = await npm("@kubernetes/client-node");
const kc = new k8s.KubeConfig();
kc.loadFromDefault();
@zettca
zettca / jimp.ts
Created January 11, 2023 16:32
`jimp` vs `photon`
import Jimp from "npm:jimp";
const fileName = Deno.args[0];
console.time("time");
console.time("init");
const img = await Jimp.read(fileName);
console.timeEnd("init");
@zettca
zettca / deleteObjectKey.ts
Created August 25, 2022 23:19
Delete an object's entry. Doesn't mutate.
export const deleteObjectKey = <T extends Record<string, any>>(
obj: T,
path: string
): T => {
const newObj = { ...obj };
const paths = path.split(".");
paths.reduce((acc, key, idx) => {
if (idx === paths.length - 1) {
delete acc[key];
@zettca
zettca / git-file-ownership.sh
Last active May 20, 2020 18:46
find who owns (last touched) the most files in a repo
git ls-files | while read f; do git log -n 1 -- "$f" | grep -I '^Author: '; done | sort -f | uniq -c | sort -nr
@zettca
zettca / modernize.md
Last active February 18, 2020 00:44
Modernizing an old JavaScript script

Modernizing an old JavaScript script

This thing apparently reduces something like HH:mm:ss or HH:mm to number of seconds.

var sec = 1;
var min = 60*sec;
var hour = 60*min;

function parseTime(time){
@zettca
zettca / multicraft-widen.js
Last active March 29, 2019 17:19
this script widens Multicraft console
// ==UserScript==
// @name Widen Multicraft Console
// @namespace https://zettca.xyz/
// @version 0.1
// @description this script widens Multicraft console.
// @author zettca
// @match https://mc.shockbyte.com/index.php?r=server/log*
// ==/UserScript==
(function() {
@zettca
zettca / trello-widen.js
Last active February 27, 2019 13:49
Widen Trello Lists & Cards
// ==UserScript==
// @name Widen Trello Lists
// @namespace https://zettca.xyz/
// @version 0.1
// @description this script widens Trello lists, which are narrow af.
// @author zettca
// @match https://trello.com/b/*
// @grant GM_addStyle
// ==/UserScript==
@zettca
zettca / swipe.js
Created January 24, 2018 05:22
Simple & Clean Javascript swipe direction detection
const root = document.querySelector('body');
const touchStart = { x: 0, y: 0 };
root.addEventListener('touchstart', handleTouchStart, false);
root.addEventListener('touchend', handleTouchEnd, false);
function handleTouchStart(e) {
touchStart.x = e.changedTouches[0].screenX;
touchStart.y = e.changedTouches[0].screenY;
}
@zettca
zettca / state1.js
Created January 21, 2018 05:02
These are the things that keep me awake at night
this.state = ['time', 'distance', 'pace'].reduce((obj, el) => {
obj[el] = { value: values[el], enabled: type !== el };
return obj;
}, {});
@zettca
zettca / rotn.py
Created December 17, 2017 18:57
Python3 ROT n encode
chrs = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
def rot_encode(string, i):
return "".join([chrs[chrs.index(c) + i % len(chrs)] for c in string])