Skip to content

Instantly share code, notes, and snippets.

View magnum's full-sized avatar
⚙️
experimenting...

Antonio Molinari magnum

⚙️
experimenting...
View GitHub Profile
await (async () => {
const sheet_id = "SPREADSHEET_ID" // spreadsheet id
const range = "SHEET!RANGE" // ie: Sheet1!A1:c100
const api_key = "APY_KEY" // insert your api key
const url = `https://sheets.googleapis.com/v4/spreadsheets/${sheet_id}/values/${range}?key=${api_key}`
const response = await fetch(url);
const json = await response.json();
const values = json.values;
const keys = values.shift();
const data = values.map(value => Object.fromEntries(keys.map((k, i) => [k,value[i]])))
Array.from(document.getElementsByTagName("video"))[0].currentTime = 0
@magnum
magnum / listEvetnListeners.js
Created April 13, 2025 21:09
list all event listeners in js
let list = [];
let targets = Array.from(document.querySelectorAll('*'));
targets.push(document);
targets.forEach((obj) => {
let listeners = getEventListeners(obj);
for (p in listeners) {
listeners[p].forEach((l) => {
removeEventListener(l.type, l.listener, l.useCapture);
list.push([obj, l.type, l.listener, '' + l.listener, l.useCapture]);
});
@magnum
magnum / trix-editor-purge-html.js
Created March 12, 2025 16:22
purge trix-editor from extra br, ie. when pasting from chatgpt to basecamp
document.querySelectorAll("trix-editor").forEach(el => {
el.style.border = "1px solid green";
el.innerHTML = el.innerHTML.replaceAll("<div><!--block--><br></div>", "")
el.innerHTML = el.innerHTML.replaceAll("<div><!--block--><br>","<div>")
el.innerHTML = el.innerHTML.replaceAll("<br></strong><br>","</strong><br>");
el.innerHTML = el.innerHTML.replaceAll("<br></div>", "</div>")
//console.log(el.innerHTML)
});
@magnum
magnum / subscribe.js
Created March 4, 2025 21:42
subscribe.js using google form, from dario amodei blog
// https://darioamodei.com/subscribe
// Shared typo corrections
var commonTypos = {
"gmail.con": "gmail.com",
"gmail.co": "gmail.com",
"gamil.com": "gmail.com",
"gmai.com": "gmail.com",
"yahoo.con": "yahoo.com",
"yaho.com": "yahoo.com",
@magnum
magnum / christmas_tree.js
Created January 8, 2025 18:08
christmas three in js
[10,2].forEach(function(row) {
new Array(row).fill('').forEach((v, i) => {
console.log([
...new Array(9-i).fill('.'),
...new Array(1+i*2). fill('^'),
...new Array(9-i).fill('.')
].join(''));
});
});
@magnum
magnum / coinmarketcup_api_getCryptoValue.js
Created October 26, 2024 14:16
get crypto value from coinmarketcup api
function getCryptoValue( code="BTC-EUR", type='price' ) { // types= "price", "percent_change_24h"
const properties = PropertiesService.getScriptProperties();
const coinmarketcap_api_key = properties.getProperty('coinmarketcap_api_key');
let value = 0 ;
const options = {
'validateHttpsCertificates' : false,
"headers" : {
"X-CMC_PRO_API_KEY" : coinmarketcap_api_key,
}
};

Vim Manipulation Cheat Sheet

Action

Key Result
v select
y copy (yank)
c change
d delete
// bulk ignore riconcile, use this in console
// https://secure.fattureincloud.it/importer/bankstatements
const action = () => {
const link1 = document.querySelectorAll("a[href='/importer/bankstatements']")[1];
link1.style.color = "blue";
link1.click();
setTimeout(() => {
const link2 = document.querySelector("[id$='listItem']:last-child");
link2.style.color = "blue";
link2.click();
@magnum
magnum / linux-setup.sh
Created April 27, 2024 00:10 — forked from dhh/linux-setup.sh
linux-setup.sh
# CLI
sudo apt update -y
sudo apt install -y \
git curl docker.io \
build-essential pkg-config autoconf bison rustc cargo clang \
libssl-dev libreadline-dev zlib1g-dev libyaml-dev libreadline-dev libncurses5-dev libffi-dev libgdbm-dev libjemalloc2 \
libvips imagemagick libmagickwand-dev \
redis-tools sqlite3 libsqlite3-0 libmysqlclient-dev \
rbenv apache2-utils