Skip to content

Instantly share code, notes, and snippets.

@xznhj8129
xznhj8129 / Varset_FROM_JSON.FCMacro
Created August 23, 2025 19:34
FreeCAD Varset JSON Import/Export
import FreeCAD as App, FreeCADGui as Gui
import json, ast, pathlib
# ---------- helpers ----------
def set_expr(obj, prop, expr):
if hasattr(obj, "setExpression"):
obj.setExpression(prop, expr)
else:
ee = getattr(obj, "ExpressionEngine", None)
if ee and hasattr(ee, "setExpression"):
@xznhj8129
xznhj8129 / VarsetExportCSV.FCMacro
Last active August 5, 2025 18:36
FreeCAD Import/Export Varset to and from CSV
import FreeCAD as App, FreeCADGui as Gui
import csv, ast, pathlib, re
# ---------- helpers ----------
def expr_map(obj):
ee = getattr(obj, "ExpressionEngine", None)
if not ee:
return {}
try:
return dict(ee)
@xznhj8129
xznhj8129 / ali_opflow.py
Created May 25, 2025 13:16
Aliexpress E88 drone Optical Flow module protocol reverse engineering
#!/usr/bin/env python3
import serial
import time
import struct
# ------------------
# Configuration
# ------------------
SERIAL_PORT = '/dev/ttyUSB0'
@xznhj8129
xznhj8129 / yt-playlist-scrape.py
Last active February 5, 2021 22:00
Youtube playlist extractor
#!/usr/bin/python3
from bs4 import BeautifulSoup
import easygui, traceback, os
#fuck youtube and fuck goolag
#go on your full playlist page and scroll to the bottom, then open element inspector and copy the segment"<div id="contents" class="style-scope ytd-playlist-video-list-renderer">"
#paste it into the box and choose a filename
#it saves even deleted videos so they can be recovered with the internet archive
#sometimes easygui fails when videos have special characters and emojis so you have to put the html in a text file
entry = easygui.boolbox('Enter HTML in easygui?')
@xznhj8129
xznhj8129 / utils3.py
Created November 17, 2017 01:39
utils3
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import base64,hashlib,binascii,random,subprocess,time,os,urllib.request,urllib.error,urllib.parse
def Exec(cmde):
if cmde:
execproc = subprocess.Popen(cmde, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
cmdoutput = execproc.stdout.read() + execproc.stderr.read()
return cmdoutput