Skip to content

Instantly share code, notes, and snippets.

View TheMatt2's full-sized avatar

Matthew Schweiss TheMatt2

View GitHub Profile
'''
This was a project started by Alex that I am fixing some problems with. The logic itself is all Alex's.
Fix Autodesk CAM General LabVolt code to work with LabVolt M600 Mills
This probably requires some generalisation before it works with all setups
Code is heavily commented, but a basic knowledge of regex is required still
This is now less of a hack and an actual work around.
Current features:
@TheMatt2
TheMatt2 / pathtype.py
Last active October 6, 2023 04:25
Python PathType helper type for input validation in argparse for paths.
"""
PathType
A helper type for input validation in argparse for paths.
This provides a convienent way to check the paths type, existance, and
potentially use "-" to reference stdin or stdout.
This class is provided as an alternative to argparse.FileType(), which
does not open the path, only validates it and supports directories.
@TheMatt2
TheMatt2 / walklevel.py
Last active April 13, 2023 22:12
A python function to do an os.walk(), but only to a certain depth. A negative depth indicates full depth.
# MIT License
#
# Copyright (c) 2021 Matthew Schweiss
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@TheMatt2
TheMatt2 / musher
Created February 5, 2018 20:44
Musher is a collection of ffmpeg commands that I in trying to prepare the ffmpeg commands for spaceRAID. Hopefully someone will find this half useful, though it is really just badly commented bits of code. Feel free to use.
#!/bin/bash
#
# Website Links Useful
# https://stackoverflow.com/questions/7362130/getting-video-dimension-from-ffmpeg-i
# https://trac.ffmpeg.org/wiki/Encode/H.264
# https://superuser.com/questions/483232/make-exact-mp4-h264-format-for-uploading-to-youtube
# https://github.com/yihui/animation/issues/74
# https://askubuntu.com/questions/110264/how-to-find-frames-per-second-of-any-video-file
# https://stackoverflow.com/questions/14306205/do-ffmpeg-h264-compression-presets-affect-the-video-quality
# http://www.bugcodemaster.com/article/get-information-video-file-using-ffmpeg
@TheMatt2
TheMatt2 / frame_log.txt
Last active February 5, 2018 21:21
For spaceRAID, this is some of the output from that processing. This is being preserved here for future reference as the format will be changing. Feel free to use, not sure what for though.
Initalizing process_frames.py
Name Read: 'Test Match\n\n' -> Test Match
Time Read: ' \n\n' ('0\n\n' ) -> 0
Name Read: 'Test Match\n\n' -> Test Match
Time Read: ' \n\n' ('0\n\n' ) -> 0
Name Read: 'Test Match\n\n' -> Test Match
Time Read: ' \n\n' ('0\n\n' ) -> 0
Name Read: 'Test Match\n\n' -> Test Match
Time Read: ' \n\n' ('0\n\n' ) -> 0
Name Read: 'Test Match\n\n' -> Test Match
@TheMatt2
TheMatt2 / pygame_clock_test.py
Created July 1, 2018 18:49
A pygame test that looks at the behavior of the pygame.time.Clock.tick() function.
import time
import pygame
FPSCLOCK = pygame.time.Clock()
def test_time():
start = time.time()
for i in range(100000):
x = i + 5
FPSCLOCK.tick(60)
@TheMatt2
TheMatt2 / pool_test.py
Last active July 12, 2018 15:37
A test program to show some oddity's of multiprocessing.pool behavior.
#************ WARNING, this script can create rouge python instances that need to be manually killed. **************
from Tkinter import *
from multiprocessing import Pool
import time
def myfunc(x):
## window = Tk() # Adding this code causes a crash (loudly and I can not explain.)
## lbl = Label(window, text="Thread %d" % x)
## lbl.grid(column=0, row=0)
## window.mainloop()
@TheMatt2
TheMatt2 / golf_island.py
Created August 21, 2018 21:48
This is the full un-golfed code for the entry here: https://codegolf.stackexchange.com/a/171002/81432
L,S,O,R,F=len,set,None,range,frozenset
U,N,J,D,I=S.update,F.union,F.isdisjoint,F.difference,F.intersection
def r(n,a,c):
U(c,P)
if L(I(N(Q[n],C[n]),a))<2:return 1
w=D(P,N(a,[n]));e=S();u=S([next(iter(w))])
while u:n=I(Q[u.pop()],w);U(u,D(n,e));U(e,n)
return L(e)==L(w)
def T(a,o,i,c,k):
s,p,m=a
@TheMatt2
TheMatt2 / check_platform.py
Last active October 31, 2018 02:24 — forked from zhreshold/check_platform.py
Check OS/Python and Cpu Info
"""Diagnose script for checking OS/hardware/python/pip/mxnet.
The output of this script can be a very good hint to issue/problem.
"""
import platform, subprocess, sys, os
def check_python():
print('----------Python Info----------')
print('Version : ' + platform.python_version())
print('Compiler : ' + platform.python_compiler())
print('Build : ' + ', '.join(platform.python_build()))
@TheMatt2
TheMatt2 / atom_shortcuts.md
Last active December 30, 2018 21:32 — forked from zhw12/gist:e2e9665fc446678c0fbfd11a025d15c6
Atom Editor Cheat Sheet