Skip to content

Instantly share code, notes, and snippets.

View leixingyu's full-sized avatar
👋
Let's Connect!

Xingyu Lei leixingyu

👋
Let's Connect!
View GitHub Profile
@leixingyu
leixingyu / conform.py
Created August 21, 2023 22:56
Conform plain text as Python executable command
def conform(txt):
"""
Conform plain text as Python executable command
this can be useful for whenever we need to get python
as plain text format from a text widget and execute that
for example:
exec(command)
mel.eval('python({})'.format(command))
unreal.PythonScriptLibrary.execute_python_command_ex(command)
@leixingyu
leixingyu / dockableWidget.ui
Created February 8, 2023 18:12
A dockable ui template with menu bar, using QWidget instead of QMainWindow
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QWidget" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>280</width>
<height>600</height>
@leixingyu
leixingyu / server.py
Last active December 25, 2022 16:14 — forked from mdonkers/server.py
Simple Python 3 HTTP server for logging all GET and POST requests
"""
Example usage to get/post data on server from client.py
```
import requests
url = 'http://localhost:8000'
def get(url):
@leixingyu
leixingyu / chatroom.py
Created December 24, 2022 03:34 — forked from tyt2y3/chatroom.py
Simple chatroom in Python, upon BaseHTTPServer and long polling
'''
Simple chatroom
Reference
https://docs.python.org/2/library/threading.html
http://blog.oddbit.com/2013/11/23/long-polling-with-ja/
http://zulko.github.io/blog/2013/09/19/a-basic-example-of-threads-synchronization-in-python/
http://www.laurentluce.com/posts/python-threads-synchronization-locks-rlocks-semaphores-conditions-events-and-queues/
'''
import time
import math
import numpy as np
from transforms3d import *
np.set_printoptions(precision=3)
np.set_printoptions(suppress=True)
@leixingyu
leixingyu / unrealMenu.py
Created September 17, 2022 17:19
Custom Unreal Startup Menu Template
import unreal
def create_menu():
# Get the main ToolMenu of Unreal
menus = unreal.ToolMenus.get()
main_menu = menus.find_menu('LevelEditor.MainMenu')
# Create custom ToolMenu
my_menu = main_menu.add_sub_menu(
import numpy as np
np.set_printoptions(precision=3)
np.set_printoptions(suppress=True)
def change_xform(source_xform, change_of_basis):
"""
Change a transformation matrix from one coordinate to another
@leixingyu
leixingyu / Dock.py
Last active July 16, 2022 15:56 — forked from mottosso/Dock.py
Simple way to dock Qt widgets to Maya 2017+
from builtins import int
from shiboken2 import wrapInstance
from maya import cmds, OpenMayaUI as omui
from Qt import QtWidgets, QtCore
from Qt import _loadUi
def Dock(Widget, show=True):
name = Widget.__class__.__name__
import random
import sys
from time import sleep
from Qt import QtWidgets, QtCore, QtGui
class RunnerSignals(QtCore.QObject):
progressed = QtCore.Signal(int)
messaged = QtCore.Signal(str)
import sys
from time import sleep
from Qt import QtWidgets, QtCore, QtGui
class Worker(QtCore.QObject):
progressed = QtCore.Signal(int)
messaged = QtCore.Signal(str)
finished = QtCore.Signal()