Skip to content

Instantly share code, notes, and snippets.

View ablil's full-sized avatar

ablil

  • 19:22 (UTC +01:00)
View GitHub Profile

Complete Regex cheatsheet

Basic and extended regular expressions are two variations on the syntax of the specified pattern. Basic Regular Expression (BRE) syntax is the default in sed (and similarly in grep). Use the POSIX-specified -E option (-r, --regexp-extended) to enable Extended Regular Expression (ERE) syntax.

characters

case BRE and ERE Perl
any char except newline . .
word [[:alphanum:]] \w
digit [[:digit:]] \d

Partition Encryption

Prerequisites

The package cryptsetup is used to for partition encryption.

fedora: sudo dnf install cryptsetup debian: sudo apt install cryptsetup

Create new partition

Using the tools fdisk on your disk, to create a new partition.

@ablil
ablil / tiktok-swiper.js
Created June 19, 2022 13:39
Swipe Tiktok videos automatically when they finish
function get_next_button() {
return document.querySelector('button[data-e2e="arrow-right"]')
}
function get_current_video() {
return document.querySelector('.tiktok-5uccoo-DivVideoContainer video')
}
function click_next_event(evt) {
evt.target.click()
@ablil
ablil / googelanalytics.md
Created May 10, 2023 09:56
Integrate Google Analytics on Nextjs app
  1. Add env variable to .env file
NEXT_PUBLIC_GA_TRACKING_ID=
  1. Create tracking functions
export const GA_TRACKING_ID = process.env.NEXT_PUBLIC_GA_TRACKING_ID;

export const pageview = (url) => {
@ablil
ablil / devresources.md
Created June 4, 2023 15:57
Dev resources
@ablil
ablil / nested-key-value.js
Created September 1, 2023 08:33
Given a nested object, check if it has a given key/value pair inside of it
function check(obj: any, key: string, value: string): boolean {
const keys = Object.keys(obj)
if (!keys.length) return false;
if ( keys.includes(key) && obj[key] === value ) return true;
const nested = keys.filter(key => typeof obj[key] === 'object')
return nested.some(nestedKey => foo(obj[nestedKey], key, value))
}