Skip to content

Instantly share code, notes, and snippets.

View lazerl0rd's full-sized avatar
🌐
Handing DNS so you don't have to.

Diab Neiroukh lazerl0rd

🌐
Handing DNS so you don't have to.
View GitHub Profile
for i in $(find . ! -name '*-keyring*' -name '*.gpg'); do echo "gpg --no-default-keyring --keyring ./$(basename $i .gpg)-keyring.gpg --import $(basename $i)"; echo "gpg --no-default-keyring --keyring ./$(basename $i .gpg)-keyring.gpg --export --output $(basename $i .gpg)-archive-keyring.gpg"; done
@lazerl0rd
lazerl0rd / shellprompt.md
Created September 8, 2021 16:29
The shell prompts I use for my client and server devices.

Client

Normal

export PS1="\[$(tput setaf 2)\]┌──(\[$(tput setaf 4)\]\u@\h\[$(tput setaf 2)\])-[\[$(tput sgr0)\]\w\[$(tput setaf 2)\]]\n└─\[$(tput setaf 4)\]\\$\[$(tput sgr0)\]\[$(tput sgr0)\] "

Root

@lazerl0rd
lazerl0rd / 20-makepkg.hook
Last active April 2, 2024 04:13
A Makepkg configuration for Arch Linux that utilises LLVM and takes optimisation up to eleven.
[Trigger]
Operation = Install
Operation = Upgrade
Type = Path
Target = etc/makepkg.conf
Target = usr/share/makepkg/buildenv/lto.sh
Target = usr/share/makepkg/executable/strip.sh
[Action]
Description = Modifying the Makepkg configuration...
@lazerl0rd
lazerl0rd / urlregex.js
Last active February 22, 2023 21:37
A RegEx to match publicly-accessible HTTP URLs. I cannot guarantee it matches every case, but it matches everything I could think of.
// This snippet was based off https://gist.github.com/dperini/729294 by Diego Perini,
// and is licensed under the MIT license. My additions (notably, the IPv6 regex)
// preserve the same license with the addition that I, Diab Neiroukh, am included in
// the copyright notice. I'd also appreciate it if you could link back to this Gist.
// As usual, here's the copyright notice in full:
// Copyright (c) 2010-2018 Diego Perini
// Copyright (c) 2021 Diab Neiroukh
//
@lazerl0rd
lazerl0rd / cryptorandom.js
Last active January 31, 2022 08:49
cryptoRandom(), a secure alternative to Math.random() utilising the Web Crypto API.
function cryptoRandom() {
const cryptoObj = crypto || window.crypto || window.msCrypto;
const genArray = cryptoObj.getRandomValues(new Uint8Array(7));
let tmpArray = [];
genArray.forEach(function(ele, index) {
tmpArray[index] = ele.toString();
if (ele.toString().length < 3) {
if (((index === 0) && (Math.random() < 0.1)) || (Math.random() < 0.5)) {
tmpArray[index] = ("0" + ele);
@lazerl0rd
lazerl0rd / binexport.ps1
Last active May 19, 2022 11:20
A PowerShell script to easily manage a PATH exportable folder with multiple programs in dedicated sub-folders.
$invocPath = $(split-path $MyInvocation.MyCommand.Path)
ForEach ($i in (Get-ChildItem -Force -Path $invocPath | Where-Object { ($_.Attributes -Match "ReparsePoint") -And ($_.LinkType -Eq "SymbolicLink") -And (-Not $_.PSIsContainer) })) { If ($i.Name -ne "binexport.ps1") { Remove-Item $i.FullName } }
ForEach ($i in (Get-ChildItem -Force -Path $invocPath -Recurse -Include "*.bat", "*.dll", "*.exe", "*.ps1" | Where-Object { $_.Attributes -NotMatch "ReparsePoint" })) { If (( -Join ($invocPath, "\", $i.Name)) -Ne $MyInvocation.MyCommand.Path) { New-Item -ItemType SymbolicLink -Path ( -Join ($invocPath, "\", $i.Name)) -Target $i.FullName | Out-Null } }
# Exceptions
If (Test-Path -Path ( -Join ($invocPath, "\open_a_terminal_here.bat")) -PathType Leaf) { Remove-Item ( -Join ($invocPath, "\open_a_terminal_here.bat")) }
ForEach ($i in (Get-ChildItem -Force -Path $invocPath "restic_*_windows_amd64.exe")) { Move-Item $i.FullName ( -Join ($invocPath, "\restic.exe")) }
If (Test-Path -Path ( -Join ($invocPath, "\scrcpy-s
@lazerl0rd
lazerl0rd / doh-worker.js
Last active March 29, 2021 14:17
Cloudflare Worker DoH Proxy for AdGuard, with an Override for YouTube Restrictions
const skipCache = true
/* START OF {DE,EN}CODERS */
async function b64urlDecode(data) {
return atob((data + '==='.slice((data.length + 3) % 4))
.replace(/-/g, '+')
.replace(/_/g, '/'))
}
@lazerl0rd
lazerl0rd / Swap Information.ps1
Last active March 2, 2021 15:37
A function to report swap usage and certain configurations on Windows.
Function Get-PageFileInfo
{
$compSysResults = Get-CimInstance Win32_ComputerSystem -Namespace 'root\cimv2'
$pageFileResults = Get-CimInstance -Class Win32_PageFileUsage -ComputerName $Computer | Select-Object *
$pageFiles = $pageFileResults.Description
$pageFileCurrentSizes = $([string]$pageFileResults.CurrentUsage).Split(" ")
For ($i = 0; $i -lt $pageFileCurrentSizes.length; $i++)
{
$pageFileCurrentSizes[$i] = $pageFileCurrentSizes[$i] + "MB"
printmerge()
{
echo "Merging \"$@\"..."
}
if [[ -z $BASETAG ]]; do
echo "Please set the tag to merge of this kernel's base via BASETAG env variable."
fi
@lazerl0rd
lazerl0rd / skagen-wearos-smoothme.sh
Last active February 25, 2021 09:55
Remove bloatware from Fossil and Skagen Wear OS smartwatches
#!/usr/bin/env bash
# A shell script to remove bloatware from Fossil and Skagen Wear OS smartwatches.
# Diab Neiroukh - 2/Jul/2020 (Licensed under the GNU GPLv3)
ticApps=(
"com.mobvoi.wear.fitness.aw" \
"com.mobvoi.ticwear.sidewearvoicesearch" \
"com.mobvoi.wear.social.aw" \
"com.mobvoi.wear.account.aw" \
"com.mobvoi.wear.appsservice" \