Skip to content

Instantly share code, notes, and snippets.

@CRImier
CRImier / fixshit.py
Last active October 27, 2023 09:55
Reconstruct a Notepad++ session using an existing session.xml file (without entries or with entries but outdated) and contents of the 'backup' folder with your drafts. named fixshit because I was very displeased when I lost my session and the backup was pretty old. need to set up a cron job fr.
# run this in the Notepad++ profile directory
# changing these variables is left as an exercise to the reader
# please, do backups of the session.xml
# and of the Notepad++ profile directory too
# just remember that the backups folder might contain sensitive data cuz it has all your drafts in it
# also, install lxml library for this to work
backup_dir = 'backup'
@CRImier
CRImier / monitor-pc.sh
Last active August 8, 2023 08:30
monitor-pc : tmux script for watching over ur compooter
#!/bin/bash -eux
cd $HOME
tmux new-session \; \
split-window -v \; \
send-keys ' htop' C-m \; \
split-window -v \; \
send-keys ' top' C-m \; \
split-window -h -p 60 \; \
select-pane -t 1 \; \
split-window -h \; \
def d5ify(str):
h = '0123456789abcdef'
a = len(h)>>--3 # >:3
b = int(h[a]+h[-1+a*(a+1)], a**(a+1)*a)
y = []
for _, c in enumerate(str):
if len(str) <= _+a: break
if c == chr(b):
x, z = str[_+a-1:_+a+1].lower()
if x in h and z in h:

rank by height:

  1. mid (mid-mount)
  2. flat (flat mount, non-angled insertion)
  3. low
  4. med
  5. tall

low, med and tall are likely angled insertion - I don't check that, but it's reasonable to assume. The lines between low, med and tall are blurred, don't expect consistency - look for specific height values if you need them (and make a PR if you can, I'd appreciate it!) For mid-mount, smd+tht means inner row pins are THT - otherwise, inner row pins are SMD, which might be noticeably harder to rework.

search was done on 21.06.22, updated on 20.09.22

I used pictures for reference, picture-less connectors were not investigated

Plugs (to be used with a drive)

  • vertical data+power smd sas plug link
  • vertical data+power smd sas plug link
  • vertical data+power smd sas plug link
  • same partnumber as previous one, different listing link
  • horizontal data+power smd u.2 plug link

Hey! If you're getting this link, this means I would like to deliver a physical thing to you. I usually use our postal service for that, it tends to be way cheaper than airline tickets back and forth - typically. Here are the requirements to get the thing delivered to you. I wrote them down because I've went through the "here are the options and requirements" song and dance with others before, and I wouldn't like to rehash it all the time, or forget something that you could make use of.

TL;DR?

Here's the address info I'll need to get the package to you. It can be your work address, a friend's address, or a relative's address too - I don't care.

  • Full or partial name (could be fake, see below)
  • Address: street, house, [apartment]
  • City, Country
  • Postcode
@CRImier
CRImier / listen_keys.py
Created November 16, 2021 04:59
Software that shows you all input events. apt install python3-evdev .
#!/usr/bin/sudo /usr/bin/python3
from evdev import InputDevice, list_devices, categorize, ecodes
from time import sleep
import threading
def listen_for_events(dev):
for event in dev.read_loop():
#if event.type == ecodes.EV_KEY:
print (dev.name, ": ", str(categorize(event)))
@CRImier
CRImier / hexdump.py
Created August 24, 2021 17:21
i2cdetect-style hexdump in Python
def hexdump(data=None, col_width=16):
#This function follows the i2cdump output format, as it's the most readable out there
if data is None: data = d
# character conversion function
conv = lambda x: chr(x) if x in range(0x20, 0x7f) else '.'
# getting row count
row_count = ceil(len(data)/col_width)
max_row_num_len_hex = len(hex(row_count)[2:])
# first line - header
hex_digits = [hex(i)[2:] for i in range(16)]
@CRImier
CRImier / smbus_eeprom_16bit.py
Last active September 8, 2023 19:01
Read and write 8-bit and 16-bit EEPROM using Python's smbus and smbus2 libraries respectively
"""This code works with both 24c02 and 24c16 (though you'll want to also iterate through addresses for using a 24c16 fully):"""
from smbus import SMBus
from math import ceil
def write_to_eeprom(bus, address, data, bs=16):
"""
Writes to an EEPROM. Only supports starting from 0x00, for now.
(to add other start addresses, you'll want to improve the block splitting mechanism)
Will raise an IOError with e.errno=121 if the EEPROM is write-protected.
# This code is available on 192.168.88. :8000 (you can download it using your web browser)
# All examples are written to work on Python 3
#########################################################
# Basic syntax, "while" and "if"
#########################################################
# REPL works well as a simple calculator
2+2*2
# Answer: 6