Skip to content

Instantly share code, notes, and snippets.

View diamondburned's full-sized avatar

Diamond diamondburned

View GitHub Profile
@diamondburned
diamondburned / main.go
Last active November 18, 2020 01:52
Arikawa voice playback example
package main
import (
"context"
"log"
"os"
"os/exec"
"os/signal"
"time"
@diamondburned
diamondburned / vol.sh
Created January 17, 2021 01:23
PulseAudio volume control with notifications
#!/usr/bin/env bash
# const
NOTIFICATION_APPNAME="vol.sh"
NOTIFICATION_ID=48741 # dice-roll randomness guaranteed
# notify title subtitle hints? icon? -> void
notify() {
title="$1"
subtitle="$2"
@diamondburned
diamondburned / style.css
Last active January 30, 2021 21:52
Mini cozy mode CSS for Discord
@-moz-document regexp("https://discord.com/channels/.*") {
div[class^="message"][class*="cozyMessage"] img[class^="avatar"] {
width: 1.25rem;
height: 1.25rem;
margin-left: 18px;
}
div[class^="message"][class*="cozyMessage"] {
margin-top: 0;
padding-top: 0;
package main
import (
"flag"
"log"
"os"
"github.com/diamondburned/arikawa/v2/api"
"github.com/diamondburned/arikawa/v2/discord"
)
@diamondburned
diamondburned / USAGE.md
Created June 8, 2021 22:59
Script to scrape all songs in a Spotify playlist
  1. Ctrl+Shift+C
  2. Paste spotex.js in
  3. Scroll all the way up, then scroll down slowly
  4. Once the end is reached, type songs in the console to ensure all songs are present
  5. JS: console.log(JSON.stringify(songs)), right click, Copy Message
  6. Shell: wl-paste | head -n1 | jq > playlist.json
@diamondburned
diamondburned / main.go
Created December 5, 2021 09:52
Script to parse CGOWRAP_PROFILE
package main
import (
"encoding/csv"
"errors"
"io"
"log"
"os"
"strconv"
)
{ pkgs }:
let gtkcord4 = {
src = pkgs.fetchFromGitHub {
owner = "diamondburned";
repo = "gtkcord4";
rev = "0ac19003b75865378b8a36781cb9106741bc603f";
hash = "sha256:13wvbqqskrrczk3q2az18wmj6a7k79alrsnz0v7cijvm1bi1lrvk";
};
bin = pkgs.fetchzip {
@diamondburned
diamondburned / Makefile
Last active October 19, 2022 21:30
atod implementation in x86 nasm compiled from C
atod.asm: _atod.c
gcc -Wall -Os -s -c ./_atod.c
objconv -fnasm _atod.o
# Sanitize the output.
dos2unix _atod.asm
sed -i \
-e 's/;.*$$//' \
-e 's/\.\(LC[0-9]*\)/\1/g' \
-e 's/^default rel//g' \
-e 's/^SECTION \(\.\w*\).*$$/section \1/g' \
@diamondburned
diamondburned / ordmap.go
Created December 1, 2022 09:04
Ordered map for JSON unmarshaling
package ordmap
import (
"bytes"
"encoding/json"
"fmt"
"log"
"strings"
)
@diamondburned
diamondburned / caddyfile.nix
Last active April 5, 2023 07:36
Caddyfile for GitHub redirection with Go modules support
{ config, lib, pkgs, ... }:
let
user = "diamondburned";
go-get-html = pkgs.writeTextFile {
name = "libdb.so-go-get";
text = ''
<!DOCTYPE html>
{{ $path := .OriginalReq.URL.Path }}
{{ $name := $path | splitList "/" | rest | first }}