Skip to content

Instantly share code, notes, and snippets.

View gregbugaj's full-sized avatar

Greg gregbugaj

View GitHub Profile
@gregbugaj
gregbugaj / set-brightness.sh
Created August 15, 2025 19:24
Adjust brightness on all connected monitors : xrandr
#!/bin/bash
# Usage: ./set-brightness.sh 0.7
# Adjust brightness on all connected monitors
# Check if brightness level is provided
if [ -z "$1" ]; then
echo "Usage: $0 <brightness-level>"
echo "Example: $0 0.7"
exit 1
@gregbugaj
gregbugaj / swapspace.sh
Created July 21, 2020 13:59
Check linux swap space
#!/bin/sh
for file in /proc/*/status ; do awk '/VmSwap|Name/{printf $2 " " $3}END{ print ""}' $file; done | sort -k 2 -n -r | less
@gregbugaj
gregbugaj / transitions.cpp
Created October 17, 2017 14:53
Counting transitions in a bit string
template <class T> void bitstr(const T& out) noexcept;
template <class T> int popcnt(const T& val) noexcept;
int main()
{
// Uniform descriptors
// 0000 0000 (0 Transitions : Uniform) 0x0
// 1110 0011 (2 Transitions : Uniform) 0xE3
// 0101 0000 (4 Transitions : NonUniform) 0x50
@gregbugaj
gregbugaj / leponicautil.c
Created September 20, 2017 12:55
Utility for dumping Leptonica Pix data to screen
void dump(PIX* pix)
{
int_t w = pix->w;
int_t h = pix->h;
int_t wpl = pixGetWpl(pix);
l_uint32* data = pixGetData(pix);
l_uint32* line;
printf("\n");
@gregbugaj
gregbugaj / HammingDistance.cpp
Last active September 20, 2017 12:53
Hamming distance calculation
typedef unsigned long int hash_t;
#include <iostream>
#include <bitset>
#include <iostream>
#include <bitset>
#include <climits>
#include "HashDistance.h"
int popcnt(const hash_t& val) noexcept