Skip to content

Instantly share code, notes, and snippets.

@NightFeather
NightFeather / rpm.awk
Created April 18, 2024 18:41
I don't know why I made this.
func h2b(pair) { s="0123456789abcdef"; return index(s, tolower(substr(pair,1,1)))*16+index(s, tolower(substr(pair,2,1)))-17; }
func h2d_le(str) { x=0; for(i=length(str)-2;i>=0;i-=2) { x=x*256+h2b(substr(str,i+1,2)) } return x }
func h2d_be(str) { x=0; for(i=0;i<length(str);i+=2) { x=x*256+h2b(substr(str,i+1,2)) } return x }
func h2z(str) { x=""; for(i=0;i<length(str);i+=2) { v=h2b(substr(str,i+1,2)); if(v==0) { break } x=x sprintf("%c", v); }; return x}
func h2bs(str) { x=""; for(i=0;i<length(str);i+=2) { v=h2b(substr(str,i+1,2)); x=x sprintf("%c", v); }; return x}
BEGIN {
EXCLUDED_PACKAGES["gpg-pubkey"]=0
if(!cols) {
cols=108
@NightFeather
NightFeather / ptt-image.user.css
Last active August 10, 2023 16:40
BIGGER embedded image in ptt.cc
/* ==UserStyle==
@name PTT Image Resize
@version 0.0.1
@author Nightfeather
*/
@-moz-document domain("www.ptt.cc") {
.richcontent {
display: flex;
justify-content: center;
align-items: center;
@NightFeather
NightFeather / hololive-fc-firefox-stub.user.js
Last active August 6, 2023 06:02
Stub some constant to make the video viewable on Firefox
// ==UserScript==
// @name Hololive FC Player Firefox Stub
// @namespace Violentmonkey Scripts
// @match https://hololive-fc.com/video/*
// @grant none
// @version 1.0
// @author Nightfeather
// @description 8/6/2023, 1:42:37 PM
// ==/UserScript==
@NightFeather
NightFeather / ptt-recover-embed-image.user.js
Last active August 6, 2023 08:18
把內嵌圖片還原成原圖
// ==UserScript==
// @name PTT 還原內嵌圖
// @namespace Violentmonkey Scripts
// @match https://www.ptt.cc/bbs/*
// @grant none
// @version 1.0
// @author Nightfeather
// @description 8/6/2023, 11:13:01 AM
// ==/UserScript==
@NightFeather
NightFeather / UMR.desktop
Last active April 4, 2023 18:16
just some files helps me starting umr with proper permission seperation through polkit
[Desktop Entry]
Name=UMR GUI
Comment=User Mode Register GUI for AMDGPU
Exec=/usr/local/bin/umrdesktop.sh
Terminal=false
Type=Application
class MMapEntry
attr_reader :addr_range, :permission, :offset, :devnum, :inode, :path
def self.from_procmaps line
addr, perm, offset, devnum, inode, path = line.split
saddr, eaddr = addr.split("-").map { |a| a.to_i 16 }
dev = devnum.split(":").map { |s| s.to_i 16 }
path = path[1..-2].to_sym if path =~ /\[.+\]/
MMapEntry.new saddr..eaddr, perm, offset.to_i(16), dev, inode, path
end
@NightFeather
NightFeather / ricknroll.py
Created March 24, 2022 12:44
Never gonna beep you up.
from RPi import GPIO
import time
mid = 440/(2**(10/12))
notes = dict(zip("C C# D D# E F F# G G# A A# B".split(), [mid*2**(i/12) for i in range(12)]))
speed = 60/114
scores = [
(-1, "A", 1/4),
(-1, "B", 1/4),
#!/usr/bin/env ruby
require "time"
require "optparse"
require "optparse/time"
class Package
@@list = {}
@NightFeather
NightFeather / clip.rb
Last active July 27, 2022 13:39
Some dirty script dumps info in ClipStudioPaint file.
#!/usr/bin/env ruby
require "stringio"
require "tempfile"
require "sqlite3"
module StringConvert
refine String do
def btol endianess = :BE
@NightFeather
NightFeather / open-albert
Created February 4, 2022 11:41
Auto open albert when not running under swaywm.
#!/bin/bash
function retry() {
if [[ $# -lt 3 ]]; then
return 1
fi
limit=$1
shift
timeout=$1