Skip to content

Instantly share code, notes, and snippets.

View Sardonyx001's full-sized avatar
🌻
pondering

jam Sardonyx001

🌻
pondering
View GitHub Profile
@Sardonyx001
Sardonyx001 / conform.lua
Created November 13, 2024 04:56
Caddyfile formatter for neovim
return {
{
"stevearc/conform.nvim",
opts = {
formatters_by_ft = {
["_"] = { "caddy_fmt" },
},
formatters = {
caddy_fmt = {
@Sardonyx001
Sardonyx001 / fetch-repo-topics.sh
Created October 9, 2024 02:25
Fetch a github repo's topic tags
#! /usr/bin/env bash
# if you have gh and jq installed
gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/OWNER/REPO/topics \
| jq -r '.names[]'
@Sardonyx001
Sardonyx001 / coffeeware
Last active October 8, 2024 10:39 — forked from q3w3e3/monsterware
/*
* ------------------------------------------------------------
* "THE COFFEEWARE LICENSE" (Revision 03):
* <author> wrote this code. As long as you retain this
* notice, you can do whatever you want with this stuff. If we
* meet someday, and you think this stuff is worth it, you can
* buy me a coffee in return.
* ------------------------------------------------------------
*/
@Sardonyx001
Sardonyx001 / waifu.sh
Created August 9, 2024 21:45
Grab a random waifu jpg from waifu.im
curl -s 'https://api.waifu.im/search?is_nsfw=false&included_tags=waifu' \
| jq '.images.[].url'
# Tags:
# waifu
# maid
# marin-kitagawa
# mori-calliope
# raiden-shogun
# selfies
@Sardonyx001
Sardonyx001 / waifu.sh
Created August 9, 2024 20:21
Grab a random anime girl photo and display it in the terminal
curl -s https://api.waifu.pics/sfw/waifu \
| jq '.url' \
| xargs wget -nv 2>&1 \
| perl -npe 's/.*"([^"]+)".*/$1/' \
| xargs wezterm imgcat
@Sardonyx001
Sardonyx001 / sed.sh
Last active July 15, 2024 03:18
Sed cheatsheet
# Removes all lines containing `string` from input.txt and prints the result to STDIN
sed '/string/d' input.txt
# Overwrites the file with the modification
sed '/string/d' input.txt > input.txt
# Overrite inplace (Doens't work wth GNU sed, only MacOS & BSD sed)
sed -i '' '/string/d' input.txt
# GNU sed version
sed -i '/string/d' input.txt
@Sardonyx001
Sardonyx001 / suffix_tree.py
Last active July 14, 2024 16:19
Generate suffix tree of a given string
from graphviz import Digraph
import argparse
class TreeNode:
def __init__(self):
self.children = {}
self.indexes = []
@Sardonyx001
Sardonyx001 / foo.sh
Last active July 13, 2024 21:06
Get all media urls from a 4chan thread
curl https://a.4cdn.org/[board]/thread/[thread].json \
| jq '
.posts[]
| if .tim != null then [.tim, .ext] else empty end
| map(tostring)
| "https://i.4cdn.org/[board]/" + .[0] + .[1]'
# Replace [board] and [thread] with board name and thread id respectively
# Output:
# "https://i.4cdn.org/w/1716958855504120.png"
@Sardonyx001
Sardonyx001 / 4get.fish
Created July 13, 2024 20:49
Fish shell function to download all pictures in a 4chan thread
function 4get -a THREADURL -a OUTPUTDIR --description 'Get all the pictures in a 4chan thread'
if string-empty $THREADURL
echo "Must provide a thread URL"
return
end
if string-empty $OUTPUTDIR
set OUTPUTDIR "."
end
mkdir -p $OUTPUTDIR
@Sardonyx001
Sardonyx001 / layout.tsx
Created January 13, 2024 17:50
Use LINE Seed font in Nextjs
import localFont from 'next/font/local'
// path -> "src/app/"
const lineSeedSans = localFont({
src: [
{
path: './LINESeedSans_W_Bd.woff2',
weight: '700',
style: 'bold',
},