Skip to content

Instantly share code, notes, and snippets.

@Rahix
Rahix / EdgeLength.FCMacro
Created February 11, 2023 22:45
FreeCAD macro to calculate the cumulative length of all selected edges
# inspired by https://forum.freecad.org/viewtopic.php?t=44309
from PySide import QtCore, QtGui
edges = FreeCADGui.Selection.getSelectionEx()[0].SubObjects
length = sum(e.Length for e in edges)
print(f"Length of selected edges is {length:.2f} mm.")
diag = QtGui.QMessageBox(QtGui.QMessageBox.Information, "Edge Length", f"Length of selected edges is {length:.2f} mm.")
diag.setWindowModality(QtCore.Qt.ApplicationModal)
diag.exec_()
@Rahix
Rahix / profibus_scan.py
Last active October 29, 2022 09:54
Script to scan a PROFIBUS network for all online peripherals using pyprofibus
# SPDX-License-Identifier: GPL-2.0-or-later
from pyprofibus import phy_serial
from pyprofibus import fdl
import pyprofibus
def main():
phy = phy_serial.CpPhySerial("/dev/ttyUSB0")
phy.setConfig(baudrate=phy_serial.CpPhy.BAUD_19200)
phy.debug = 1
@Rahix
Rahix / echoed.c
Last active December 16, 2019 21:00
echoed - A very questionable daemon for converting upper-case and lower-case
/*
* echoed - Pipedeamon which changes to lowercase and uppercase
* Copyright (C) 2019 Harald Seiler
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
@Rahix
Rahix / A_parts.rs
Last active January 19, 2019 20:24
Proof of concept for moveable parts
https://start.duckduckgo.com/// These are our "fake" pins
#[derive(Debug)]
pub struct PA;
#[derive(Debug)]
pub struct PB;
#[derive(Debug)]
pub struct PC;
#[derive(Debug)]
pub struct PD;
@Rahix
Rahix / main.rs
Last active December 29, 2018 13:05
Static and Dynamic Dispatch at the same time
trait Foo {
fn bar(&self);
}
impl Foo for &dyn Foo {
fn bar(&self) {
(*self).bar();
}
}
@Rahix
Rahix / PKGBUILD
Created June 4, 2018 16:13
PKGBUILD for lollypop-transparent
# Maintainer: Dan Beste <dan.ray.beste@gmail.com>
# Contributor: Frederic Bezies < fredbezies at gmail dot com>
# Contributor: Ian Brunelli (brunelli) <ian@brunelli.me>
pkgname="lollypop-transparent"
_gitname="lollypop-transparent"
_gitname_orig="lollypop"
pkgdesc='Lollypop with a transparent background'
pkgver=0.9.304.r573.g20395d12
pkgrel=1
@Rahix
Rahix / 01-rust-thread-affinity.md
Last active September 17, 2024 20:20
Rust demonstration of setting thread affinity with pthread_setaffinity_np

Call this program with -s N to set a specific CPU. Without -s, the thread will have the default affinity.

This program will print out the main threads CPU, the child threads CPU and the child threads affinity after optionally setting it.

@Rahix
Rahix / PKGBUILD
Last active September 8, 2021 19:41
gimp-plugin-vtf PKGBUILD
pkgname=gimp-plugin-vtf
pkgver=1.0+1+g76c40be
pkgrel=1
pkgdesc="VTF GIMP plugin"
url="https://github.com/linux-source-tools/gimp-plugin-vtf"
arch=(x86_64)
license=(unknown)
depends=(gimp)
makedepends=(cmake)
_commit=e351d8eafb7e7af3193d750ef61783e02ad61a8b
@Rahix
Rahix / PKGBUILD
Last active January 10, 2018 20:19
gdk-pixbuf-vtf PKGBUILD
pkgname=gdk-pixbuf-vtf
pkgver=2.1
pkgrel=1
pkgdesc="VTF GDK Pixbuf Loader library"
url="https://github.com/linux-source-tools/gdk-pixbuf-vtf"
arch=(x86_64)
license=(unknown)
depends=(gdk-pixbuf2)
makedepends=(cmake)
_commit=7fb2f837bd54af9296f43573877895d7e90b95fe
@Rahix
Rahix / PKGBUILD-file-roller-vpk
Last active June 5, 2018 10:41
file-roller-vpk archlinux PKGBUILD
pkgname=file-roller-vpk
pkgver=3.28.0+33+g88d3ac6a
pkgrel=1
pkgdesc="File Roller with Valve Pak (VPK) support"
url="https://https://github.com/linux-source-tools/file-roller-vpk"
arch=(x86_64)
license=(GPL)
depends=(gtk3 libarchive file libnotify zip unzip)
makedepends=(intltool itstool docbook-xsl gnome-common git libnautilus-extension)
optdepends=("p7zip: 7z, arj, exe and encrypted zip files support"