Skip to content

Instantly share code, notes, and snippets.

@smac89
smac89 / journal.log
Last active Jul 16, 2021
KDE plasma crash on external monitor hotplug
View journal.log
-- Journal begins at Sat 2021-06-12 17:25:40 CST, ends at Thu 2021-07-15 23:05:02 CST. --
Jul 15 23:03:06 ArcoB kscreen_backend_launcher[3064]: kscreen.xcb.helper: RRNotify_OutputChange
Jul 15 23:03:06 ArcoB kscreen_backend_launcher[3064]: kscreen.xcb.helper: Output: 677
Jul 15 23:03:06 ArcoB kscreen_backend_launcher[3064]: kscreen.xcb.helper: CRTC: 0
Jul 15 23:03:06 ArcoB kscreen_backend_launcher[3064]: kscreen.xcb.helper: Mode: 0
Jul 15 23:03:06 ArcoB kscreen_backend_launcher[3064]: kscreen.xcb.helper: Rotation: "Rotate_0"
Jul 15 23:03:06 ArcoB kscreen_backend_launcher[3064]: kscreen.xcb.helper: Connection: "Connected"
Jul 15 23:03:06 ArcoB kscreen_backend_launcher[3064]: kscreen.xcb.helper: Subpixel Order: 0
Jul 15 23:03:06 ArcoB kscreen_backend_launcher[3064]: kscreen.xcb.helper: RRScreenChangeNotify
Jul 15 23:03:06 ArcoB kscreen_backend_launcher[3064]: kscreen.xcb.helper: Window: 25165829
@smac89
smac89 / instructions.md
Created May 28, 2021 — forked from matthewjberger/instructions.md
Install a nerd font on ubuntu
View instructions.md

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
smac89 / sparse.md
Created May 16, 2021
Git sparse checkout a folder from specific branch
View sparse.md

The goal

Checkout the llvm folder from the release/11.x branch in https://github.com/llvm/llvm-project

My process

git init llvm-project
cd llvm-project
git remote add origin https://github.com/llvm/llvm-project
git fetch --depth=1
git config core.sparseCheckout true
@smac89
smac89 / egcd.py
Last active Feb 18, 2021
Extended Euclidean Algorithm in Python (Without recurrsion)
View egcd.py
#!/usr/bin/python3
import math
# Taken in part from: https://www.geeksforgeeks.org/python-program-for-basic-and-extended-euclidean-algorithms-2/
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
See: https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm
@smac89
smac89 / post.md
Last active Oct 3, 2020
Xfce Lockscreen with xsecurelock and xscreensaver #linux #xfce
View post.md
  • 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
smac89 / 1. Firefox Tips.md
Last active Sep 8, 2020
Tips for using firefox on Linux #firefox #linux #desktop #tuning
View 1. Firefox Tips.md
@smac89
smac89 / post.md
Created Sep 1, 2020
XFCE Exo remove unused applications #exo #xfce #desktop
View post.md

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
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
smac89 / zsh-lazy.md
Last active Aug 3, 2020
ZSH lazy loading #zsh #lazy
View zsh-lazy.md

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.