Skip to content

Instantly share code, notes, and snippets.

View RaphaelWimmer's full-sized avatar

Raphael Wimmer RaphaelWimmer

View GitHub Profile
@OrionReed
OrionReed / dom3d.js
Last active April 25, 2024 06:09
3D DOM viewer, copy-paste this into your console to visualise the DOM topographically.
// 3D Dom viewer, copy-paste this into your console to visualise the DOM as a stack of solid blocks.
// You can also minify and save it as a bookmarklet (https://www.freecodecamp.org/news/what-are-bookmarklets/)
(() => {
const SHOW_SIDES = false; // color sides of DOM nodes?
const COLOR_SURFACE = true; // color tops of DOM nodes?
const COLOR_RANDOM = false; // randomise color?
const COLOR_HUE = 190; // hue in HSL (https://hslpicker.com)
const MAX_ROTATION = 180; // set to 360 to rotate all the way round
const THICKNESS = 20; // thickness of layers
const DISTANCE = 10000; // ¯\\_(ツ)_/¯
@matthen
matthen / hello_world.py
Last active April 23, 2024 22:13
Hello world in python, using genetic algorithm
"""Hello world, with a genetic algorithm.
https://twitter.com/matthen2/status/1769368467067621791
"""
import random
import time
from dataclasses import dataclass
from itertools import chain
from typing import Iterable, List
@Toliak
Toliak / shame.py
Last active February 14, 2023 10:16
Python runtime bytecode patch example
import functools
import struct
import types
import dis
def _patch_code(code: types.CodeType):
# Call function with 0 arguments
function_call_bytearray = bytearray(dis.opmap['CALL_FUNCTION'].to_bytes(1, byteorder='little') + b'\x00')

How to make a small tweak to free software

The target audience for this is people who are beginners at software engineering and using linux. A lot of the information here may be obvious or already known to you. The language involved is C but you do not need to know any C to read this tutorial. I used mg to write this blog post. I used vs code to edit the source code.

This post is also available on gopher://tilde.team:70/0/~river/tweak-free-software

If you use a piece of free software and it's 99% perfect but there's just this one thing it does that annoys the hell out of you.. you can in theory just fix it! Here's a look at what doing that is like. Hopefully it inspires you, or you pick up a could tricks on the way!

Step 0: Have a problem

@dajiaji
dajiaji / python_cwt_sample_eudcc_02.py
Last active November 17, 2021 11:50
A simple EUDCC verifier implementation with Python CWT.
import json
import os
import zlib
import requests
from base45 import b45decode
import cwt
from cwt import load_pem_hcert_dsc
#!/usr/bin/env python
import math
import sys
from moviepy.editor import AudioClip, VideoFileClip, concatenate_videoclips
# Get average RGB of part of a frame. Frame is H * W * 3 (rgb)
# Assumes x1 < x2, y1 < y2
@GrantTrebbin
GrantTrebbin / stl-surface.py
Created October 2, 2019 09:15
Generate a 3D model based on a 2D equation
# stl-surface.py
# Generate a 3D model based on a 2D equation
# The model will be rectangular with a flat base. The top surface is based on
# a provided equation in "surface_function". The file name can be set with the
# output_filename variable. The x and y width of the model and the grid spacing
# is defined by the following parameters.
# x_spacing
@bhive01
bhive01 / see3cam_good_np_slicing.py
Created April 16, 2018 02:49
CU40 with Numpy Slicing (efficient for video on Raspberry Pi)
# TESTING HARDWARE
# see3CAM_CU40
# raspberry Pi 3 bf8
# Raspbian Stretch 13-03-2018
# Python 3.5.3
# OpenCV 3.4.1
# load required libraries
import math
import numpy as np
@bhive01
bhive01 / see3cam_test.py
Last active December 17, 2018 16:30
reading images from a see3cam CU40
import math
import numpy as np
import cv2
cam = cv2.VideoCapture(0)
cam.set(cv2.CAP_PROP_FRAME_WIDTH, 1280)
cam.set(cv2.CAP_PROP_FRAME_HEIGHT, 720)
cam.set(cv2.CAP_PROP_CONVERT_RGB, False) # turn off RGB conversion
# cam.set(cv2.CAP_PROP_FOURCC('Y', '1', '6', ''))
@bodil
bodil / fix-my-stupid-folio.service
Created November 24, 2016 15:05
Hacks for Linux kernel glitches on the HP Elitebook Folio G1
[Unit]
Description=HP Elitebook Folio G1 fixes
[Service]
ExecStart=/sbin/fix-my-stupid-folio
[Install]
WantedBy=basic.target