Skip to content

Instantly share code, notes, and snippets.

@Bouni
Bouni / ethercat-conf.xml
Created September 13, 2024 11:38
First working draft of a 3 axis linuxcnc setup with Omron 1S servo drives over ethercat
<masters>
<master idx="0" appTimePeriod="1000000" refClockSyncCycles="-1" name="master0">
<slave idx="0" type="EK1110" />
<slave idx="1" type="R88D-1SN01H-ECT" name="x-servo">
<dcConf assignActivate="300" sync0Cycle="*1" sync0Shift="0"/>
<watchdog divider="2498" intervals="1000"/>
</slave>
<slave idx="2" type="R88D-1SN01H-ECT" name="y-servo">
<dcConf assignActivate="300" sync0Cycle="*1" sync0Shift="0"/>
<watchdog divider="2498" intervals="1000"/>
"""Implementation of the Datamodel for the parts list with natural sort."""
import re
import wx
import wx.dataview as dv
BOM_COL = 6
POS_COL = 7
import wx
import wx.dataview as dv
from datamodel import PartListDataModel
import random
class MyFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, title="DataViewCtrl Example with Natural Sort")
import wx
import wx.dataview as dv
import re
import random
def natural_sort_key(s):
"""Return a tuple that can be used for natural sorting."""
return [
int(text) if text.isdigit() else text.lower()
@Bouni
Bouni / GMOD.py
Last active June 13, 2024 07:37
Read SICK FlexiSoft GMOD gateway data using pymodbus
# See https://cdn.sick.com/media/docs/6/86/086/Operating_instructions_Flexi_Soft_Gateways_in_the_Safety_Designer_Configuration_software_de_IM0081086.PDF
# Page 36
from pymodbus.client import ModbusTcpClient as ModbusClient
IP = "192.168.255.3"
PORT = 502
ADDRESS = 1100
REGISTERS = 25
SLAVE_ID = 1
@Bouni
Bouni / nc-transfer.sh
Last active March 19, 2024 13:12
Transfer Nextcloud data to new server
#!/bin/sh
NEW_HOST=new_server
TARGET_FOLDER=/opt/docker/cloud/transfer/
MYSQL_USER=nextcloud
MYSQL_PW=my_secure_db_pw
DATE=`date +"%Y%m%d"`
@Bouni
Bouni / svg2pdf.ps1
Last active November 6, 2023 09:17
Batch convert SVG files to PDF on Windows 11
$files = Get-ChildItem -Name ./*.svg
for ($i=0; $i -lt $files.Count; $i++) {
$newname = ([String]$files[$i]).Replace("svg","pdf")
& "C:\Program Files\Inkscape\bin\inkscape.exe" --actions="export-type:pdf;export-do" --export-filename=$newname $files[$i]
}
@Bouni
Bouni / rainbow.py
Created November 1, 2023 10:35
Generate a list of rainbow colors with n entries
def rainbow_color_stops(n=10, end=2 / 3):
rgb = [hls_to_rgb(end * i / (n - 1), 0.5, 1) for i in range(n)]
hex = [f"#{int(255.0*r):02x}{int(255.0*g):02x}{int(255.0*b):02x}" for r, g, b in rgb]
return hex
@Bouni
Bouni / nc_last_seen.py
Created October 26, 2023 15:13
Hacky python script to get a list uf all Nextcloud users ordered by their last login (for use with docker-compose)
from subprocess import Popen, PIPE
from datetime import datetime as dt
import json
occ = ["docker-compose", "exec", "-u", "www-data", "app", "/var/www/html/occ"]
list_users_cmd = occ + ["user:list", "--output=json"]
with Popen(list_users_cmd, stdout=PIPE) as proc:
users = json.loads(proc.stdout.read().decode("UTF-8"))
@Bouni
Bouni / doco.sh
Created July 25, 2023 13:31
A shell script to handle mutiple docker-compose files easily
#!/bin/sh
case $1 in
"update" )
docker-compose $(find . -maxdepth 2 -name compose.*.yaml -type f -print | sed -e 's/^/-f /') pull --ignore-pull-failures && \
docker-compose $(find . -maxdepth 2 -name compose.*.yaml -type f -print | sed -e 's/^/-f /') up -d;;
"status" )
docker-compose $(find . -maxdepth 2 -name compose.*.yaml -type f -print | sed -e 's/^/-f /') ps -a;;
"lf" )
docker-compose $(find . -maxdepth 2 -name compose.*.yaml -type f -print | sed -e 's/^/-f /') logs -f ${@:2};;