Skip to content

Instantly share code, notes, and snippets.

@madacol
madacol / README.md
Last active September 15, 2024 07:46
Weighted Shuffle script for cmus (C* Music Player)

Weighted Shuffle for cmus

This script adds weighted shuffle functionality to cmus (C* Music Player). It prioritizes songs based on a score that you assign to them on the fly.

How It Works

The script attaches to cmus via the status_display_program option to keep track of the songs played. Each time a track transition occurs, a new song is picked by weighted shuffle (weight is calculated as 2 ** score) and added to the queue. When shuffling, songs with higher scores have an exponentially higher probability of being played.

The script provides special commands to increase or decrease the score of the current song and to play the previous song:

You use gdbus directly to send notifications

gdbus call \
        --session \
        --dest org.freedesktop.Notifications \
        --object-path /org/freedesktop/Notifications \
        --method org.freedesktop.Notifications.Notify \
        "App_name" 0 "audio-headphones" "Title" "Message" '[]' '{}' 5000 \
    | sed -E 's/.uint32 ([0-9]+).*/\1/' \
@madacol
madacol / Actas-md5-checksum.txt
Created August 23, 2024 19:56
MD5 checksum de las 25073 actas que hay en https://static.resultadosconvzla.com/
This file has been truncated, but you can view the full file.
8bb177620780c83cf01f2f5dc6945024 ./EDO. AMAZONAS/MP. ATURES/PQ. LUIS ALBERTO GOMEZ/Centro 220102026/AG8A003216_993716_2024-07-29-0001.jpg
aab37cdf48c644e164126a30dd7d42ea ./EDO. AMAZONAS/MP. ATURES/PQ. LUIS ALBERTO GOMEZ/Centro 220102026/AG8A003216_626765_2024-07-29-0001.jpg
e1e39090df3616755f969dc1467ae7b1 ./EDO. AMAZONAS/MP. ATURES/PQ. LUIS ALBERTO GOMEZ/Centro 220102028/AG8A003216_567523_2024-07-29-0001.jpg
7468ad1f50ad7a1f0978007bfcf561b7 ./EDO. AMAZONAS/MP. ATURES/PQ. LUIS ALBERTO GOMEZ/Centro 220102021/AG8A003216_691959_2024-07-29-0001.jpg
b98aa60335336c585ca8d7cffc8374c1 ./EDO. AMAZONAS/MP. ATURES/PQ. LUIS ALBERTO GOMEZ/Centro 220102024/AG8A003216_883940_2024-07-29-0001.jpg
50da336fe3d4141f36238da8657478c1 ./EDO. AMAZONAS/MP. ATURES/PQ. LUIS ALBERTO GOMEZ/Centro 220102003/AG8A003216_276557_2024-07-29-0001.jpg
7f26f88e5fa8b0136f5eecfca0f2fa78 ./EDO. AMAZONAS/MP. ATURES/PQ. LUIS ALBERTO GOMEZ/Centro 220102003/AG8A003216_721678_2024-07-29-0001.jpg
const http = require('http');
const server = http.createServer((req, res) => {
const filename = req.url.split("/").pop();
const newUrl = `https://static.resultadosconvzla.com/${filename}`;
console.log(`Redirecting to ${newUrl}`);
res.writeHead(302, { 'Location': newUrl });
151515_365185_2024-07-29-0040.jpg: FAILED
653905_571785_2024-07-29-0001.jpg: FAILED
050518_212567_2024-07-28-0001.jpg: FAILED
1722286142083.jpg: FAILED
653905_052403_2024-07-29-0002.jpg: FAILED
653905_368884_2024-07-29-0002.jpg: FAILED
653905_481968_2024-07-29-0001.jpg: FAILED
653905_669741_2024-07-29-0003.jpg: FAILED
653905_723484_2024-07-29-0002.jpg: FAILED
653421_022596_2024-07-28-0015.jpg: FAILED
@madacol
madacol / nlsh.zsh
Last active October 21, 2024 23:27
zsh script, that ask `llm` for a shell command, and puts it in the edit buffer, ready to execute or edit.
#!/bin/zsh
# This script needs to be sourced in a zsh shell instead of being executed
# To do so, set an alias in your shell:
# alias '??'='source $HOME/.local/bin/nlsh.zsh'
# Then you can use the `??` command from any zsh shell like this:
# ?? extract the content of ./file.zip in the current directory
echo "$@" \
| llm -s 'Your task is to output oneliner shell commands.
@madacol
madacol / chatGPT to markdown.js
Last active May 31, 2023 16:45
Converts chatGPT conversations to markdown, you can even use it as a bookmarklet. Adapted from this one https://www.reddit.com/r/ChatGPT/comments/11h50jl/chatgpt_conversation_to_markdown_bookmarklet/
javascript: (function () {
var odd = document.querySelectorAll(".group.w-full:nth-child(odd) .items-start");
var even = document.querySelectorAll(".group.w-full:nth-child(even)");
if (odd.length === 0 || even.length === 0) {
alert("Failed to find expected html elements.\nIs this a chat.openai.com/chat/ page?");
return;
}
if (odd.length != even.length) {
alert("count mismatch");
@madacol
madacol / spreadsheet.html
Last active March 22, 2022 07:42
Simple javascript spreadsheet
<!DOCTYPE html>
<html>
<head>
<script>
/**
* This is a modified version of the spreadsheet below ↓ to allow editing while receiving realtime changes
* https://github.com/xem/sheet/blob/gh-pages/full-commented.html
*/
// Sheet!
<?xml version="1.0" encoding="UTF-8"?>
<gamecontroller configversion="19" appversion="2.23">
<!--The SDL name for a joystick is included for informational purposes only.-->
<sdlname>Logitech Dual Action</sdlname>
<!--The GUID for a joystick is included for informational purposes only.-->
<guid>030000006d04000016c2000010010000</guid>
<profilename>main</profilename>
<names/>
<sets>
<set index="1">
@madacol
madacol / padron_reducido_to_SQL.sh
Last active September 16, 2019 16:30
Transform padron reducido to SQL
gzip -c -d ~/Downloads/padron_reducido_ruc.zip | tail -n+2 | iconv -f ISO-8859-1 -t UTF-8//TRANSLIT | sed -E -e "s/'/''/g" -e "s/\|$/')/g" -e "s/^/,('/g" -e "s/([^\\\\])(\\\\\\\\)*\|/\1\2','/g" -e "1~100000 s/^,/;insert into consulta_ruc (idruc, razon_social, estado_contri, domicilio, ubigeo, via, nombre_via, zona, tipo_zona, numero, interior, lote, departamento, mazana, kilometro) values /g" -e "1 s/^;//g" -e "$ s/$/;/g"