Skip to content

Instantly share code, notes, and snippets.

View MrMarble's full-sized avatar
🍳
I may be slow to respond.

Alvaro Tinoco MrMarble

🍳
I may be slow to respond.
View GitHub Profile
import { computed, ref, type Ref, type UnwrapRef } from 'vue';
const cache = new Map<string, any>();
export default function useCacheRef<T>(initialValue: T, key: string): Ref<UnwrapRef<T>> {
const innerRef = ref(initialValue);
const cachedValue = cache.get(key);
if (cachedValue) {
innerRef.value = cachedValue;
}
@MrMarble
MrMarble / k3s-etcd-commands.md
Created June 21, 2023 08:01 — forked from superseb/k3s-etcd-commands.md
k3s etcd commands

k3s etcd commands

etcd

Setup etcdctl using the instructions at https://github.com/etcd-io/etcd/releases/tag/v3.4.13 (changed path to /usr/local/bin):

Note: if you want to match th etcdctl binaries with the embedded k3s etcd version, please run the curl command for getting the version first and adjust ETCD_VER below accordingly:

curl -L --cacert /var/lib/rancher/k3s/server/tls/etcd/server-ca.crt --cert /var/lib/rancher/k3s/server/tls/etcd/server-client.crt --key /var/lib/rancher/k3s/server/tls/etcd/server-client.key https://127.0.0.1:2379/version
@MrMarble
MrMarble / commit-msg
Last active June 17, 2021 08:36
Semantic release commit hook
#!/usr/bin/env bash
if [ -z "$1" ]; then
echo "Missing argument (commit message). Did you try to run this manually?"
exit 1
fi
commitTitle="$(cat $1 | head -n1)"
# ignore merge requests
@MrMarble
MrMarble / getFollowed.js
Created May 10, 2021 09:03
Get all followed on twtich.js
"use strict";
function getFollowed() {
const dom = document.querySelector("div[aria-label='Canales que sigo']");
const key = Object.keys(dom).find((key) =>
key.startsWith("__reactInternalInstance$")
);
const react = dom[key];
if (react == null) return;
@MrMarble
MrMarble / showAll.js
Created May 10, 2021 09:03
Show all Followed on twitch.tv
"use strict";
function showAll() {
const dom = document.querySelector("div[aria-label='Canales que sigo']");
const key = Object.keys(dom).find((key) =>
key.startsWith("__reactInternalInstance$")
);
const react = dom[key];
if (react == null) return;
@MrMarble
MrMarble / dater.py
Created September 6, 2020 09:25
Simple script to set the modification time on whatsapp media using the file name
import sys
import os
import re
import time
import datetime
def main():
folder = parse_args(sys.argv)
parse_files(folder)
##########################
# Custom .bashrc file #
# By MrMarble #
##########################
#--How to install
# Paste into ~/.bashrc file:
#if [ -e $HOME/.bash_config]; then
@MrMarble
MrMarble / intervalFactory.js
Created December 17, 2019 07:59
Namespace of functions to help you manage multiple 'setInterval' without needing of doing it yourself
(function(window) {
const interval = {
// To keep a reference to all the intervals
intervals : new Set(),
// Create another interval
make(...args) {
let newInterval = setInterval(...args);
this.intervals.add(newInterval);
return newInterval;
@MrMarble
MrMarble / waitFor.js
Last active October 15, 2019 07:52
Simple JavaScript function similar to jQuery '.on("ready")' but for any element you can select using a CSS selector. It should work with old versions of JS
/**
* This function waits for the existence of an element before executing a callback.
* You have to specify the css selector for that particular element as well as the callback.
*
* @param {string} selector CSS Selector
* @param {function} resolved Function to call if the element is found
* @param {function} [rejected] Optional. Function to call if the element is not found
* @param {number} [maxTimeWaiting=60] Optional. Maximum run time before aborting. Default 60s
*/
function waitFor(selector, resolved, rejected, maxTimeWaiting) {