Skip to content

Instantly share code, notes, and snippets.

View israelss's full-sized avatar
📚
Learning 📚

Israel Sant'Anna israelss

📚
Learning 📚
View GitHub Profile
@israelss
israelss / keyindicator
Created February 7, 2017 03:34
Script to display [Caps/Num/Scroll]Lock on Polybar
#! /usr/bin/env bash
#
# Copyright 2016 Israel Sant'Anna <israelsantanna at gmail dot com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@israelss
israelss / range.js
Created May 29, 2017 16:45 — forked from Woodsphreaker/range.js
range.js
const range = (start = 0, end = 1) => Array.from({"length": (end + 1) - start})
.map((_, i) => start + i);
console.log(range(-10, 10)); // [ -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
@israelss
israelss / One-liner npm package inspector
Created March 27, 2022 20:30
Find out what will be published to npm in a package without actually publishing it
if you want to find out what files npm will publish into the tarball without actually publishing, you can use this little one-liner:
npm pack && tar -xvzf *.tgz && rm -rf package *.tgz
Found @ https://medium.com/@jdxcode/for-the-love-of-god-dont-use-npmignore-f93c08909d8d in 2022-03-27
@israelss
israelss / resetIdSequence.sql
Last active September 16, 2022 21:04
Reset and fill Postgres id sequence
-- Reset sequence to 1
ALTER SEQUENCE table_name_id_seq RESTART WITH 1;
-- Fill all entries with sequence
UPDATE table_name SET id=DEFAULT;
-- Ref: https://stackoverflow.com/questions/4678110/how-to-reset-sequence-in-postgres-and-fill-id-column-with-new-data
@israelss
israelss / getScrolledParent.ts
Created September 16, 2022 21:03
Find and return scrolled parent of a HTML element
export const getScrolledParent = (el: HTMLElement | null): HTMLElement | null => {
if (el === null || el.parentElement === null) return null
if (el.parentElement.scrollTop > 0) return el.parentElement
return getScrolledParent(el.parentElement)
}
@israelss
israelss / redis-clear
Created February 3, 2023 15:49 — forked from dimasch/redis-clear
Clear a redis cache in Docker
docker exec -it container-name redis-cli FLUSHALL
@israelss
israelss / git_log.sh
Created July 10, 2023 21:29
Script para listar os últimos commits (por padrão último dia até o momento da execução) de todos os projetos em um diretório especificado
#! /bin/bash
# Salve este arquivo e não esqueça de dar permissão de execução:
# chmod +x ./git_log.sh
IFS=$'\n'
today=$(date '+%Y-%m-%d %H:%M:%S')
days=1
projectsDir=$HOME/Projetos # Substitua pelo seu diretório de projetos ou use a flag -p para especificar outro diretório
username=$(git config user.name)
@israelss
israelss / clear-branches.sh
Created July 10, 2023 21:38 — forked from dchueri/clear-branches.sh
Clear Local Branches Script
echo "Starting..."
branch=$1
delete()
{
echo "Deleting branches..."
git branch --list | \
egrep --invert-match "($branch|\*)" | \
xargs git branch -D
echo "Done!"
}
@israelss
israelss / rotate_desktop.sh
Created July 28, 2023 14:51 — forked from mildmojo/rotate_desktop.sh
Script to rotate the screen and touch devices on modern Linux desktops. Great for convertible laptops.
#!/bin/bash
#
# rotate_desktop.sh
#
# Rotates modern Linux desktop screen and input devices to match. Handy for
# convertible notebooks. Call this script from panel launchers, keyboard
# shortcuts, or touch gesture bindings (xSwipe, touchegg, etc.).
#
# Using transformation matrix bits taken from:
# https://wiki.ubuntu.com/X/InputCoordinateTransformation
@israelss
israelss / README.md
Created July 2, 2024 15:55 — forked from gampleman/README.md
Algorithm to find a short unique CSS selector from an arbitrary node

This algorithm when passed a DOM node will find a very short selector for that element.