Skip to content

Instantly share code, notes, and snippets.

View davidlj95's full-sized avatar

David LJ davidlj95

View GitHub Profile
@davidlj95
davidlj95 / luarocks-install.sh
Created June 18, 2024 18:03
LuaJIT + luarocks in macOS with brew
luarocks install --tree=$(brew --prefix)/lib/lua/5.1 luasocket
@davidlj95
davidlj95 / print-renovate-config.sh
Last active June 4, 2024 14:22
Print Renovate configuration
# Local
LOG_LEVEL=debug pnpm dlx renovate \
--platform local \
--print-config true
# GitHub hosted
REPO="user/repo"
LOG_LEVEL=debug pnpm dlx renovate \
--dry-run extract \
--print-config true \
@davidlj95
davidlj95 / http-security-headers-response.http
Last active May 5, 2024 15:48
HTTP response with all security headers for a CSR/SSR/SSG Angular app - davidlj95.com
HTTP/2 200
date: Sun, 05 May 2024 15:39:06 GMT
content-type: text/html; charset=utf-8
cache-control: public, max-age=0, must-revalidate
report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v4?s=ZNcUyO8%2FNm1megeD0GbqGongpd3IiRZ7OizUiPtTDwjeFbtsiQmY%2F0xbwB%2F87Vpm1IK6Oje3JneArNv6fSQad3wC37ZwuqNjIunCyd4nh9p2YX0pLnBTXiM8TafWlw%2Fz"}],"group":"cf-nel","max_age":604800}
nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
vary: Accept-Encoding
cf-cache-status: DYNAMIC
strict-transport-security: max-age=15552000; preload
expect-ct: max-age=86400, enforce
@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>
#