Skip to content

Instantly share code, notes, and snippets.

@AbelVM
AbelVM / readme.md
Last active November 25, 2025 12:17
Using JavaScript to break a graph into its components

Using JavaScript to break a graph into its components

Let's say we have a graph depicted by two objects:

  • nodes: an array of objects that, at least, have an id property each
  • edges: an array of objects that, at least, have both start_id, end_id properties each

Regardless the properties actual names, it's the meaning what matters.

For simplicity's sake, let's define our edges as an array of arrays like [start_id, end_id] and the result as an array of arrays of node's ids, being each array a component.

@AbelVM
AbelVM / readme.md
Last active November 21, 2025 13:08
Light fast array comparison in JavaScript

Light fast array comparison in JavaScript

This simple method will ease your ID arrays (no element repetition) equality checks.

If you don't care about array order, you will find a great performance improvement when compared with any other approach.

Parameters

  • that: 2nd array to be compared with.
  • ordered: optional boolean (default: true) to take into account the order of the array elements.
@AbelVM
AbelVM / tiles_refresh.js
Last active March 15, 2025 12:41
Refresh MapLibre layer' source when the tiles are older than a given TTL
window.__refresh__ = false; // global flag to check whether to refresh or not
const ttl = 1000 * 60 * 60; // tile time to live, ms
const map = new maplibregl.Map(
{
...,
transformRequest: (url, resourceType) => {
if (resourceType === 'Source' && url.indexOf('http://myHost') > -1) {
if(window.__refresh__){
@AbelVM
AbelVM / readme.md
Created November 5, 2024 08:51
Painless HTTPS in VSCode LiveView

Painless HTTPS in VSCode LiveView

Minimal setup in Debian flavoured Linux

  1. Install MKCert (actually, there's an official apt package available, so you can just apt install mkcert)
  2. Locate your VSCode User folder, usually at ~/.config/Code/{my_user_name}/
  3. Make a subfolder for your certificates ~/.config/Code/{my_user_name}/certs
  4. Create your certificates
@AbelVM
AbelVM / twitter_cleaner.md
Last active September 15, 2025 14:55
Twitter interests profiling cleaner

While logged in Twitter, go to

https://x.com/settings/your_twitter_data/twitter_interests

You will see a bunch of subjects that Twitter thinks you're interested on. Unchecking all the checkboxes manually is a pain in the ass, so...

Open dev tools (F12, command + i, whatever), and go to Network tab to monitor everything

Open the console and run

@AbelVM
AbelVM / maplibre_lookat.js
Created July 3, 2024 12:33
Little MapLibre extension to easily set the PoV
/*
Abel Vázquez Montoro, 2022
https://github.com/maplibre/maplibre-gl-js/issues/1599
This function sets the camera PoV based on the 3D point the user want to focus on
and the attitude of the camera.
Parameters:
@AbelVM
AbelVM / readme.md
Last active May 22, 2023 15:22
SDSC23

SDSC23: Usando SQL para escalar tu analítica espacial

Prerequisitos

Una cuenta trial de CARTO. Todos los datos usados en este taller están disponibles en abierto dentro de la plataforma.

Vamos a utilizar CARTO en este taller y el motor de base de datos que lo respalda es BigQuery, así que el código SQL hace uso de las funciones y eventuales peculiaridades de dicho motor y de las extensiones de CARTO.

1. Algunos conceptos básicos

#!/bin/zsh
autoload colors && colors
echo ''
echo $fg_bold[magenta] 'Let`s update everything...'$reset_color
echo ''
echo $fg_no_bold[green] '1. Snap'$reset_color
if ! command -v snap &> /dev/null
then
echo $fg_no_bold[yellow] 'There`s no app installed via Snap'$reset_color
else
@AbelVM
AbelVM / README.md
Last active August 10, 2021 12:39
[UNTESTED] Live source for MapLibreGL JS

[UNTESTED] Live source for MapLibreGL JS

Lets say you need to refresh your tiles every X seconds to render live information, let's make use of Custom Protocos support.

Let's say your tiles are timestamped using epoc, and the endpoint reacts to URI params like this example

https://example.com/12/2005/1545.pbf?timestamp=1628597308254

Then you just

@AbelVM
AbelVM / freespace.sh
Last active August 26, 2025 07:36
ubuntu free space script
#!/bin/zsh
autoload colors && colors
echo ''
echo $fg_bold[magenta] 'Let`s free some disk space...'$reset_color
echo ''
echo $fg_no_bold[green] '1. journal space'$reset_color
journalctl --disk-usage
echo ''
sudo journalctl --rotate
echo ''