Skip to content

Instantly share code, notes, and snippets.

View ungive's full-sized avatar

Jonas van den Berg ungive

View GitHub Profile
@ungive
ungive / main.go
Created December 2, 2021 22:53
external monitor brightness control
package main
import (
"errors"
"fmt"
"log"
"math"
"os"
"os/exec"
"strconv"
@ungive
ungive / brightness.py
Last active April 16, 2020 13:50
Regulate your screen brightness live with a simple zenity slider. Made this script because the built-in slider in Manjaro's task bar doesn't work on my older iMac and I don't want to put too much effort into fixing it. Based on this script: https://gist.github.com/ViktorNova/a13c6613dd365b2c67b0 NOTE: Check line 60 for window positioning
#!/usr/bin/python3
import sys, subprocess, os, time
from subprocess import PIPE, Popen
from threading import Thread
from queue import Queue, Empty
import atexit
dir_path = os.path.dirname(os.path.realpath(__file__))
lockfile=os.path.join(dir_path, '.brightness-lock~')
#!/usr/bin/python3
import sys, subprocess, os
from subprocess import PIPE, Popen
from threading import Thread
from queue import Queue, Empty
def enqueue_output(out, queue):
for line in iter(out.readline, b''):
queue.put(line)
""" Disclaimer: This is just pseudocode that's really similar to Python.
"""
# Generiere ein Spielfeld. Hierbei ist `n` die Seitenlänge
# (das Feld ist quadratisch) und `b` die Anzahl der Minen.
field = Field(n, b)
# - `startFields` ist eine Liste mit allen möglichen Startfeldern. [1]
# - `solvedFields` ist eine Liste mit Lösungen für alle Felder `startFields`.
# Bis zu diesem Punkt werden sie nur mit den Regeln der Logik gelöst. [2]
@ungive
ungive / strncmp_fast.c
Last active June 6, 2017 20:55
Optimised string comparison.
#include <stddef.h>
#include <stdint.h>
int strncmp_fast(const char *str1, const char *str2, size_t size)
{
typedef uint_fast32_t word_t;
int blocks = size >> 2;
if (size > sizeof(word_t)) {
word_t *word1 = (word_t *)str1;