Skip to content

Instantly share code, notes, and snippets.

View jomifepe's full-sized avatar
:shipit:

José Pereira jomifepe

:shipit:
View GitHub Profile
@jomifepe
jomifepe / BottomNavigationBehavior.java
Created February 15, 2019 17:42
BottomNavigationView hiding behavior with snackbar
package com.jomifepe.addic7eddownloader.ui.behavior;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.TimeInterpolator;
import android.content.Context;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
@jomifepe
jomifepe / karabine_complex_rules.json
Last active July 7, 2022 11:48
MacOS Karabiner - Ducky One 2 Skyline
{
"title": "Portuguese Layout Fixes ({}, \\|, ~^, ºª, +*)",
"rules": [
{
"description": "Swap Command <-> Control (MANDATORY FOR ALL THE RULES)",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "left_control"
@jomifepe
jomifepe / mountUnmountDriveByLabel.bat
Last active June 12, 2021 15:25
Allows you to mount and unmount drives in Windows by its label
@echo off
setlocal ENABLEDELAYEDEXPANSION
set label=VOLUME_LABEL_HERE
set letter=VOLUME_LETTER_HERE
set dpvns="%TEMP%\dpvn.txt"
set dprls="%TEMP%\dprl.txt"
echo list volume>%dpvns%
@jomifepe
jomifepe / getPrefixedStringsAsUnion.js
Last active June 12, 2021 15:23
Simple function that looks for unique words prefixed by something and prints them sorted as a TypeScript union
/**
* Simple function that looks for unique words prefixed by something and prints them sorted as a TypeScript union
* Usage: getPrefixedNamesAsUnion(`.icon-alert{color: white}.icon-arrow{color: red}`, '.icon-');
* Output: 'alert' | 'arrow'
*/
getPrefixedStringsAsUnion = (str, prefix) => {
const escapedPrefix = prefix.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
const matches = [...str.matchAll(RegExp(`(?<=${escapedPrefix})[a-zA-Z0-9-_]+`, 'g'))].map((s) => s[0]);
const sortedUniqueStrings = [...new Set(matches)].sort((a, b) => a.localeCompare(b));
@jomifepe
jomifepe / getHtmlColorsAsUnion.js
Last active June 12, 2021 15:23
Simple script to get all HTML colors from w3schools as a TypeScript union (https://www.w3schools.com/colors/colors_names.asp)
// Paste it on the console, while in: https://www.w3schools.com/colors/colors_names.asp
const colors = [...document.querySelectorAll('.colornamespan')].map((el) => el.textContent.toLowerCase())
const union = [...colors].reduce((acc, name) => `${acc}| '${name}'\n`, '');
console.log(union);
@jomifepe
jomifepe / getHtmlColorsAsEnum.js
Last active June 12, 2021 15:24
Simple script to get all HTML colors from w3schools as a TypeScript enum (https://www.w3schools.com/colors/colors_names.asp)
// Paste it on the console, while in: https://www.w3schools.com/colors/colors_names.asp
const colors = [...document.querySelectorAll('.colornamespan')].map((el) => el.textContent.toLowerCase())
const enumString = 'export enum HtmlColor {\n' + colors.map((color) => `\t${color} = '${color}'`).join(',\n') + ',\n}';
console.log(enumString);
@jomifepe
jomifepe / youtube-blocklist
Last active January 24, 2022 23:12
Youtube Blocklist
2mdn.net
2975c.v.fwmrm.net
ad-g.doubleclick.net
ad.doubleclick.net
ad.mo.doubleclick.net
ad.youtube.com
ads.doubleclick.net
ads.youtube.com
adservice.google.com
analytic-google.com
@jomifepe
jomifepe / 0-typescript-react-node-snippets.md
Last active September 28, 2023 23:51
TypeScript, React & Node Snippets

TypeScript, React & Node snippets.