Skip to content

Instantly share code, notes, and snippets.

View AlexTMjugador's full-sized avatar
🐰
Likely going down a rabbit hole to get a neat thing

Alejandro González AlexTMjugador

🐰
Likely going down a rabbit hole to get a neat thing
View GitHub Profile
@AlexTMjugador
AlexTMjugador / countFileNames.c
Last active April 14, 2018 21:55
Retrieves the number of files that the user has selected in a window opened by the GetOpenFileName Win32 C API function. It assumes that the OFN_EXPLORER and OFN_ALLOWMULTISELECT flags are set.
size_t FilesSelected(OPENFILENAME ofn, size_t bufferSize)
{
// ofn.lpstrFile format:
// - If the user picks one file: folder\file\0\0
// - If the user picks several files: folder\0file1\0file2\0fileN\0\0
// This function assumes that input parameters are valid and is used just after GetOpenFileName returns with success.
size_t toret = 0;
BOOL bBufferEnd = FALSE;
@AlexTMjugador
AlexTMjugador / autoconfigurar-backend-glx
Last active August 11, 2019 18:40
Un script y servicio de SystemV que configuran automáticamente el backend GLX a usar, teniendo en cuenta el adaptador gráfico que se está usando en mi portátil. Se asume que el paquete update-glx está disponible.
#!/bin/sh
# Sale del script mostrando un mensaje de error, con un determinado
# código de error.
salirConError() {
printf '\n'
echo "! $1" 1>&2
codigoError=$2
if [ -z "$codigoError" -o $codigoError -eq 0 ]; then
@AlexTMjugador
AlexTMjugador / comandos-control-volumen.sh
Last active August 2, 2019 18:00
Estos comandos, al ser ejecutados cuando se pulsa una tecla de control de volumen del teclado, restauran su funcionalidad en un entorno de escritorio de X compatible (p. ej. XFCE).
sh -c 'pactl set-sink-mute 0 toggle && ([ $(pactl list sinks | sed -n "/Mute: .*$/{s/^[[:space:]]*Mute: //;p};/^Sink #1$/q") = "no" ] && notify-send "Control de volumen" "Sonido no silenciado." --icon=audio-volume-medium || notify-send "Control de volumen" "Sonido silenciado." --icon=audio-volume-muted)'
sh -c 'pactl set-sink-volume 0 -2% && notify-send "Control de volumen" "Bajado volumen en un 2%." --icon=audio-volume-low'
sh -c 'pactl set-sink-volume 0 "+2%" && notify-send "Control de volumen" "Incrementado volumen en un 2%." --icon=audio-volume-high'
@AlexTMjugador
AlexTMjugador / parche-cryptsetup.patch
Created August 6, 2019 18:06
Arregla un retraso excesivo del apagado de un sistema Debian con sysvinit que ocurre cuando el sistema de ficheros raiz es un LV encriptado.
--- /usr/lib/cryptsetup/cryptdisks-functions 2019-08-06 19:59:34.836001686 +0200
+++ /usr/lib/cryptsetup/cryptdisks-functions-new 2019-08-06 19:59:19.824001638 +0200
@@ -186,6 +186,13 @@
log_action_end_msg 0
}
_do_stop_callback() {
+ # No intentar detener el volumen encriptado que contiene un LV
+ # donde está montado /. Como / no se puede desmontar, el LV no se
+ # puede desactivar limpiamente, y tampoco se puede parar el volumen
+ # encriptado. Lo importante es que el sistema de ficheros se
@AlexTMjugador
AlexTMjugador / 99-sony-laptop
Created August 11, 2019 18:44
A script to configure the keyboard backlight and thermal control of a Sony laptop when pm-powersave is invoked. The laptop must be supported by the Linux sony-laptop driver.
#!/bin/sh
. "$PM_FUNCTIONS"
case "$1" in
true)
# Disable keyboard backlight, and set thermal control to silent
echo 0 > /sys/devices/platform/sony-laptop/kbd_backlight
echo silent > /sys/devices/platform/sony-laptop/thermal_control;;
false)
@AlexTMjugador
AlexTMjugador / 00-coolbits.conf
Created April 12, 2020 22:04
X server configuration for unlocking GPU fan control, voltage settings, clock settings and more in the nvidia-settings application. For more information, see https://download.nvidia.com/XFree86/Linux-x86_64/440.64/README/xconfigoptions.html#Coolbits.
Section "Device"
Identifier "nvidia"
Driver "nvidia"
Option "Coolbits" "31"
EndSection
@AlexTMjugador
AlexTMjugador / PackSquashIntegrationExample.java
Last active June 16, 2023 19:50
Toy example that shows how to integrate PackSquash in a Java application.
package io.github.alextmjugador;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.ProcessBuilder.Redirect;
import java.nio.charset.StandardCharsets;
@AlexTMjugador
AlexTMjugador / badapple.js
Last active June 8, 2021 09:21
Bad Apple in Moovi (Moodle)
/**
* The Bad Apple video URL. It will be used in the "src" attribute of the <video> element.
*/
var videoSrc = "http://127.0.0.1:8000";
/**
* Whether to show debug data or not.
*/
var debug = false;
@AlexTMjugador
AlexTMjugador / dataset-download.py
Last active September 2, 2021 18:44
Freesound API Python script to download original, user-submitted sound files. Uses OAuth2 authentication without a web server.
#!/usr/bin/python3
from freesound import FreesoundClient
from pyrate_limiter import Limiter, RequestRate, Duration
import requests
import fileinput
import os
CLIENT_ID = os.environ["CLIENT_ID"]
@AlexTMjugador
AlexTMjugador / PackSquash CLA 1.0.md
Last active November 21, 2021 21:20
Contributor License Agreement (CLA) for PackSquash, version 1.0.

PackSquash Contributor License Agreement (CLA) — Version 1.0

Thank you for your interest in contributing to PackSquash ("We" or "Us").

This contributor agreement ("Agreement") documents the rights granted by contributors to Us. To make this document effective and take your Contribution into consideration, please approve it via our CLA assistant. This is a legally binding document unless explicitly noted otherwise, so please read it carefully before agreeing to it. The Agreement may cover more than one software project managed by Us.

0. Human-Readable Summary

This section has no legal value and is provided as an easier to read expression of some key terms of the Agreement. Only the next sections define the legally binding terms of the Agreement.