Skip to content

Instantly share code, notes, and snippets.

smac89 /
Created May 28, 2021 — forked from matthewjberger/
Install a nerd font on ubuntu

1.) Download a Nerd Font

2.) Unzip and copy to ~/.fonts

3.) Run the command fc-cache -fv to manually rebuild the font cache

smac89 /
Created May 16, 2021
Git sparse checkout a folder from specific branch

The goal

Checkout the llvm folder from the release/11.x branch in

My process

git init llvm-project
cd llvm-project
git remote add origin
git fetch --depth=1
git config core.sparseCheckout true
smac89 /
Last active Feb 18, 2021
Extended Euclidean Algorithm in Python (Without recurrsion)
import math
# Taken in part from:
def gcdExtended(a, b):
Calculates the GCD of the two given numbers, as well as the coefficients x and y
such that ax + by = gcd(a,b). This is useful in cryptography
smac89 /
Last active Oct 3, 2020
Xfce Lockscreen with xsecurelock and xscreensaver #linux #xfce
  • Install both xscreensaver and xsecurelock using your package manager

  • Make sure xscreensaver is not set to lock the screen or to manage the display. Xfce aleady does all those, so there is no need to enable it again.

  • Also make sure that the xscreensaver daemon is not autostarted. Not doing this may result in the screen not being locked.

  • Set the following environmental variables (in ~/.xprofile or ~/.xsession) for xsecurelock:

    # xsecurelock options
    export XSECURELOCK_SAVER=saver_xscreensaver
smac89 / 1. Firefox
Last active Sep 8, 2020
Tips for using firefox on Linux #firefox #linux #desktop #tuning
View 1. Firefox
smac89 /
Created Sep 1, 2020
XFCE Exo remove unused applications #exo #xfce #desktop

Clearing old applications from xfce exo

In order to find out where exo reads desktop applications from, I had to run the application from my terminal using the command:

strace exo-preferred-applications 2>&1 | grep 'openat.*\.desktop'

This allowed me to identify two folders where exo reads preferred applications from:

smac89 / jwt.mjs
Last active Aug 5, 2020
Learning how JWT works
View jwt.mjs
import crypto from 'crypto';
import assert from 'assert';
const header = {"alg":"HS256","typ":"JWT"};
const payload = {"loggedInAs":"admin","iat":1422779638};
const unsignedToken = Buffer.from(JSON.stringify(header)).toString('base64') +
'.' + Buffer.from(JSON.stringify(payload)).toString('base64');
const hmac = crypto.createHmac('sha256', 'secretkey');
smac89 /
Last active Aug 3, 2020
ZSH lazy loading #zsh #lazy

The following is a function I use in my .zshrc file to achieve some form of lazy evaluation.

local function lazy_load() {
    local -xr thunk="$(cat)"
    # (u) removes duplicates
    local -xr triggers=(${(u)@})
    # Only if length of triggers is greater than zero
    # otherwise the function will immediately execute.
smac89 / Unbound
Last active May 30, 2020
Create systemd timer from simple command
View Unbound

To create the timer described here

systemd-run --on-calendar='*-*-01 12:00:00' --unit='unbound-root-hints' \
--remain-after-exit --description='Update root hints for unbound' --property='Type=exec' \
--property='' --timer-property='Persistent=true' \
--timer-property='RandomizedDelaySec=2s' --timer-property='AccuracySec=1us' \
/usr/bin/curl -o /etc/unbound/root.hints