Skip to content

Instantly share code, notes, and snippets.

View cljoly's full-sized avatar
If I’m not answering within 7 days, please ping me again!

Clément Joly cljoly

If I’m not answering within 7 days, please ping me again!
View GitHub Profile
@cljoly
cljoly / ghq.fish
Created June 11, 2023 13:05
Quick and dirty alternative to https://github.com/x-motemen/ghq. It only has the features I care about and is much less robust, but it automatically changes the current directory
function ghq
# Simplified https://github.com/x-motemen/ghq, so that it’s always available
# Reference for git URLs: https://git-scm.com/docs/git-fetch#_git_urls
# * ssh://[user@]host.xz[:port]/path/to/repo.git/
# * git://host.xz[:port]/path/to/repo.git/
# * http[s]://host.xz[:port]/path/to/repo.git/
# * ftp[s]://host.xz[:port]/path/to/repo.git/
# * [user@]host.xz:path/to/repo.git/
set -f url $argv[1]
set -f path
.PHONY: hooks
hooks:
git config --local core.hooksPath $(shell pwd)/.githooks
@cljoly
cljoly / arch-secure-install.md
Created May 2, 2022 09:25 — forked from umbernhard/arch-secure-install.md
Building a Secure Arch Linux Device

Building a Secure Arch Linux Device

Locking down a linux machine is getting easier by the day. Recent advancements in systemd-boot have enabled a host of features to help users ensure that their machines have not been tampered with. This guide provides a walkthrough of how to turn on many of these features during installation, as well as reasoning for why certain features help improve security.

The steps laid out below draw on a wide variety of existing resources, and in places I'll point to them rather than attempt to regurgitate full explanations of the various security components. The most significant one, which I highly encourage everyone to read, is Rod Smith's site about secure boot, which is the most comprehensive and cogent explanation of UEFI, boot managers and boot loaders, and secure boot. Another incredibly useful resources is Safeboot, which encapsulates many of the setup steps below in a Debian application.

@cljoly
cljoly / lua.lua
Created February 28, 2022 07:03 — forked from iagoleal/lua.lua
Properly open lua and fennel required files via gf
local fmt = string.format
-- Iterator that splits a string o a given delimiter
local function split(str, delim)
delim = delim or "%s"
return string.gmatch(str, fmt('[^%s]+', delim))
end
-- Find the proper directory separator depending
-- on lua installation or OS.
@cljoly
cljoly / zram_stats
Created January 15, 2022 22:39
Zram monitoring script
awk '{print FILENAME, "\n", "orig:", $1/1024/1024, "compr:", $2/1024/1024, "ratio:", int($2/$1*100)"%", "\n", "incompressible:", $8, "freed:", $7}' /sys/block/zram*/mm_stat
swapon --show
zramctl
@cljoly
cljoly / break
Last active January 8, 2022 02:15
Open pomodoro hooks
#!/usr/bin/env bash
set -exo pipefail
notify-send -u critical "🍅 break"
makoctl set-mode normal
# dunstctl set-paused false || echo "Error with dunst"
cmus-remote -s
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO15FDh6CWsMacqPXJjoGKzpLWDBbxdGBdRGUhoF0f8F test@key
@cljoly
cljoly / bench.lua
Last active December 10, 2021 15:07
Test Lua performance msgpack vs json
-- Initial JSON created with
-- gh pr list --json additions,assignees,author,baseRefName,body,changedFiles,closed,closedAt,comments,commits,createdAt,deletions,files,headRefName,headRepository,headRepositoryOwner,id,isCrossRepository,isDraft,labels,maintainerCanModify,mergeCommit,mergeStateStatus,mergeable,mergedAt,mergedBy,milestone,number,potentialMergeCommit,projectCards,reactionGroups,reviewDecision,reviewRequests,reviews,state,statusCheckRollup,title,updatedAt,url
-- JSON data are on the first line
local data_json = vim.fn.readfile('/tmp/neovim-prs.json')[1]
local iterations = 10000
local x = os.clock()
local t = os.time()
@cljoly
cljoly / neovim-python-3.10.md
Last active November 28, 2021 13:56
Python 3.10 not properly detected by neovim <=5.1

Termux ships with python 3.10 already, which is not properly detected by neovim stable at the time of writing. A trick is to put pythonx.vim in .config/nvim/autoload/provider/pythonx.vim

@cljoly
cljoly / fan-out_with_context.go
Created August 23, 2021 07:07 — forked from Jguer/fan-out_with_context.go
Fan-Out with Context in Go
package main
import (
"context"
"errors"
"fmt"
"math/rand"
"os"
"os/exec"
"os/signal"