Skip to content

Instantly share code, notes, and snippets.

View davidlj95's full-sized avatar

David LJ davidlj95

View GitHub Profile
@davidlj95
davidlj95 / make-for-root-guard.ts
Created December 20, 2023 18:31
Angular `makeForRootGuard` helper
import {
FactoryProvider,
InjectionToken,
Optional,
SkipSelf,
Type,
} from '@angular/core'
/**
* Helps to make a `forRoot` guard to ensure a module is not imported
@davidlj95
davidlj95 / dated-files-renamer.sh
Last active September 7, 2023 17:31
File with dates renamer. From (YYYY.MM.DD). From YYYYMMDD. To YYYY-MM-DD. Replaces _ with -
#!/bin/sh
[ $# -eq 0 ] && >&2 echo "❌ No files provided as arguments" && exit 1
NOSPACES_FILE_REGEXP="^([0-9]{4})([0-9]{2})([0-9]{2})(.*)$"
PARENTHESES_FILE_REGEXP="^\(([0-9]{4})\.([0-9]{2})\.([0-9]{2})\)(.*)$"
for filename in "$@";
do
new_filename="$filename"
printf "\"$filename\""
# No spaces
@davidlj95
davidlj95 / gh-repos-with-pages.sh
Last active September 6, 2023 22:26
GitHub repositories with GitHub Pages enabled
#!/bin/sh
repos=$(gh repo list --limit 100 --json nameWithOwner | jq -r '.[].nameWithOwner')
count=0
echo "{"
for repo in $repos; do
has_pages="$(gh api repos/"$repo" --jq '.has_pages')"
echo " \"$repo\": $has_pages,"
if [ "$has_pages" = "true" ]; then
: $((count+=1))
fi
@davidlj95
davidlj95 / seo-tags.html
Last active August 17, 2023 16:46
HTML SEO tags: Jekyll SEO tag generated & @ngaox/seo compatible
<!--
SEO HTML data
The list below is copy/pasted from generated SEO data using Jekyll SEO tag v2.8.0
Next to it if `@ngaox/seo` supports it built-in (✅), can be set via custom meta tags (✅🛠️) or is not supported (❌)
-->
<title>David LJ 🔗 @davidlj95</title> <!-- ✅ -->
<meta property="og:title" content="David LJ 🔗 @davidlj95"/> <!-- ✅ -->
<meta name="author" content="davidlj95"/> <!--✅🛠️ -->
<meta property="og:locale" content="en"/> <!-- ✅🛠️ -->
<meta name="description" content="/dev/random software engineer. Connecting technology &amp; RealLife™"/> <!-- ✅ -->
@davidlj95
davidlj95 / flaixfm-podcast-urls-extractor.js
Last active May 4, 2023 02:21
FlaixFm podcast URL extractor
function getNextButton() {
return document.querySelector('.podcast-pagination .right_arrow');
}
function hasNextButton() {
const nextButtonStyle = window.getComputedStyle(getNextButton());
return nextButtonStyle.opacity !== '0'
}
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
@davidlj95
davidlj95 / fix-paperkey.sh
Created July 2, 2022 03:43
Helps fixing a GPG paperkey using checksums & vim
#!/bin/bash
#
# So you have backed up your GPG key using paperkey, and have scanned it
# using OCR techniques. However, it's not perfect and some checksums do not match
# Some 8s are Bs, 0s are Os... This script will try to spot errors so you
# can compare those lines and fix them
#
# Given a secret key exported using paperkey, tries to decode it.
#
# In case a CRC checksum wrong is found, a vim editor will be opened
@davidlj95
davidlj95 / tickers-kraken.30s.sh
Last active June 28, 2019 01:32
Retrieves Kraken ticker information to be used with argos
#!/bin/sh
# <bitbar.title>Kraken.com price tickers</bitbar.title>
# <bitbar.version>v1.0</bitbar.version>
# <bitbar.author>davidlj95</bitbar.author>
# <bitbar.author.github>davidlj95</bitbar.author.github>
# <bitbar.desc>Last selected tickers from Kraken.com</bitbar.desc>
# <bitbar.image>https://i.imgur.com/iGX2yjR.png</bitbar.image>
# <bitbar.dependencies>jq,curl</bitbar.dependencies>
#
@davidlj95
davidlj95 / github_make_private_by_grep_expression.sh
Created June 13, 2019 22:37
GitHub make private repos whose name matches grep expression
#!/bin/sh
#
# Uses GitHub API to make private all repositories whose name matches the
# given grep expression
#
set -e
# Arguments
REPO_FILTER="$1"
API_BASE_URL="https://api.github.com"
@davidlj95
davidlj95 / pyenv-install.sh
Last active September 10, 2023 04:10
Install pyenv on cygwin
#!/bin/sh
# devel-env are needed to install Python versions
cyg-get.bat bash curl make automake gcc-core gcc-g++ zlib zlib-devel libffi-devel
curl https://pyenv.run | bash
@davidlj95
davidlj95 / tgm
Last active November 7, 2018 21:33
Telegram file sender via CLI
#!/bin/sh
# tgm: TeleGram send Message
# Sends a message via Telegram (using telegram-cli)
# Author: davidlj95
#
# Telegram CLI:
# https://github.com/vysheng/tg
# yay -S telegram-cli-git
# Constants