Skip to content

Instantly share code, notes, and snippets.

View nikp123's full-sized avatar
🎯
university does like to bother me a lot

nikp123 nikp123

🎯
university does like to bother me a lot
View GitHub Profile
@nikp123
nikp123 / hypo.sh
Last active July 4, 2024 15:38
Show *hypo*thetical filesystem changes by a command ;) before running it on a live system
#!/usr/bin/env sh
#
# Script by: github.com/nikp123
#
# Distributed under the terms of the MIT license
#
# The command requires ROOT despite the usage of fuse-overlayfs
# I look forward to fixing this in the future.
# You NEED the following commands already installed on your system:
# https://github.com/kmxz/overlayfs-tools/tree/master
@nikp123
nikp123 / morse.c
Created February 11, 2024 20:59
Morse code on a ThinkPad sleep status LED
/*
Original code by Matthew Herbst - Last updated 7/21/2013
ThinkPad adaptation by nikp123 - 28/12/2023
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
@nikp123
nikp123 / printsir_guide.md
Created January 21, 2024 18:00
How to set up an old Edimax PrintSir (PrintServer 10/100) from the 90s

First things first, the device looks something like this so you don't have to assume for which device this guide is for: image

This device was manufactured by Edimax in the 90s and it just so happens to work well with even ancient printers like the HP 5L. The real device's name is: PrintSir 1P/9E and it has a unique PS-something name. Do not google that as it unique per each unit (I think).

As this device is old I am assuming you found it either on Ebay, Flea Market or the local dump and want to make use of it. This is quite a problem because those can be password locked. Thankfully mine wasn't but it had some network settings I had to get rid of.

However this might not be your case and I'll list how you'd use it depending on what network settings the last owner left it on.

@nikp123
nikp123 / run_command_on_display_or_lid_change_linux.c
Created February 26, 2022 13:28
This gist is intended to be used with autorandr on X11 to automatically switch monitors when some display change event occurs
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/extensions/Xrandr.h>
#include <unistd.h>
@nikp123
nikp123 / photoshop_pallete_to_imagemagick_args.py
Created August 16, 2021 22:27
Get the difference between two photoshop pallete files and generates a Imagemagick conversion list
#!/usr/bin/env python3
from codecs import encode
import sys
def act_to_list(act_file):
with open(act_file, 'rb') as act:
raw_data = act.read() # Read binary data
hex_data = encode(raw_data, 'hex') # Convert it to hexadecimal values
total_colors_count = (int(hex_data[-7:-4], 16)) # Get last 3 digits to get number of colors total
misterious_count = (int(hex_data[-4:-3], 16)) # I have no idea what does it do
@nikp123
nikp123 / Armbian USB gadget guide.md
Created August 3, 2021 10:04
How to make a USB gadget on Armbian Linux

This guide will include a step-by-step guide on how to set up an board running Armbian to act as a gadget device (similar to how it's been advertized with the Pi Zero)

Prerequisites

You will need a:

  • Armbian supported board with an OTG port
  • A temporary spare monitor, USB keyboard and display cable (or serial, if you'd like that instead)
// input vertex
attribute vec4 pos;
// foreground color
uniform vec4 color;
// screen width and height
uniform vec2 u_resolution;
// projection matrix precalculated by XAVA
@nikp123
nikp123 / post_frag_soft.glsl
Created July 16, 2021 06:43
Soft-shadows XAVA post-render shader
precision mediump float;
varying vec2 v_texCoord;
uniform sampler2D s_texture;
const float pi = 3.14159265f;
const float check_steph = 0.00125;
const float check_stepv = 0.005;
@nikp123
nikp123 / mbr_parser.c
Created July 1, 2021 13:30
MBR partitioned disk parser
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <stdint.h>
#include <sys/types.h>
#include <math.h>
#define MAX_PATH 255
@nikp123
nikp123 / init_window.c
Created May 16, 2021 11:10
Updated "ugly" EGL wayland example to support XDG
// gcc -o test init_window.c -I. -lwayland-client -lwayland-server -lwayland-client-protocol -lwayland-egl -lEGL -lGLESv2
#include <wayland-client-core.h>
#include <wayland-client.h>
#include <wayland-server.h>
#include <wayland-client-protocol.h>
#include <wayland-egl.h> // Wayland EGL MUST be included before EGL headers
#include "xdg-shell-client-protocol.h"
#include "init_window.h"