Skip to content

Instantly share code, notes, and snippets.

View justinfx's full-sized avatar

Justin Israel justinfx

View GitHub Profile
@justinfx
justinfx / list_edit.py
Created April 21, 2023 22:26
Qt examples of tracking QListWidget item text edits
"""
"Connect rename command in QListWidget item edit"
https://groups.google.com/g/python_inside_maya/c/lPoWGuXyFsg/m/sLiWOaJgBAAJ
"""
from PySide2 import QtCore, QtGui, QtWidgets
class MyListWidget(QtWidgets.QListWidget):
@justinfx
justinfx / tree_widget_drag.py
Created February 20, 2020 04:45
Capturing the start and end item/index information in a PySide2 QTreeWidget internal drag and drop
"""
https://groups.google.com/d/msg/python_inside_maya/1EzNG_i9Xes/Au-18UaXAwAJ
Capturing the start and end item/index information in a
PySide2 QTreeWidget internal drag and drop
"""
from __future__ import print_function
from PySide2 import QtCore, QtGui, QtWidgets
@justinfx
justinfx / read_proto_desc.py
Created July 14, 2019 06:15
Dynamically reading a Protobuf FileDescriptorSet file into Python message classes
#!/usr/bin/env python
"""
Read a serialized Protobuf FileDescriptorSet that was
generated from the protoc tool, and dynamically generate
the python classes for each message.
"""
import sys
from google.protobuf import descriptor_pb2
from google.protobuf import reflection
@justinfx
justinfx / qt_proxy_model.py
Created June 17, 2019 05:53
Minimal Qt example of adding a "virtual row" via a proxy model
#!/usr/bin/env python
"""
Refs:
"[Maya-Python] Customized display of files/folders in a QTreeView that is using QFileSystemModel."
https://groups.google.com/d/topic/python_inside_maya/TaFm2yNToJ8/discussion
"""
from PySide import QtCore, QtGui
@justinfx
justinfx / libtest.cc
Last active January 31, 2019 20:51
cython: test converting py2/3 string objects to C++ std::string
#include "libtest.hh"
std::string copy_string(std::string &s) {
std::string s2 = s;
return s2;
}
@justinfx
justinfx / README.md
Last active January 11, 2019 04:47
Repro of nats-io subscribe queue not evenly load balancing to idle workers

Build

go build worker.go
go build sender.go

Test

Start gnatsd server and 3 worker processes. Then run test to send 3 messages at once. It is expected that all 3 messages are picked up by 3 idle workers, and this may happen on

@justinfx
justinfx / badger_close_test.go
Created July 9, 2018 22:59
An example of a test that causes a badgerdb crash with a misleading error string
package main
import (
"os"
"testing"
"github.com/dgraph-io/badger"
)
/*
#!/usr/bin/env python
"""
Pipes experiment.
Refs: https://gist.github.com/mottosso/dd59f815025e4d76f453f3555e39558e
"""
import os
import sys
import time
import argparse
@justinfx
justinfx / py3_asyncore_server.py
Created October 24, 2017 11:15
python3 asyncore + threading socket server
import asyncore
import socket
import threading
class ChatServer(asyncore.dispatcher):
def __init__(self, host, port):
asyncore.dispatcher.__init__(self)
@justinfx
justinfx / goimports_and_save.py
Created March 6, 2017 05:55
SublimeText 3 - anaconda_go plugin - Workaround for 'fmt on save' bug
"""
Workaround for https://github.com/DamnWidget/anaconda_go/issues/9
"""
import re
import sublime, sublime_plugin
class GoImportsOnSave(sublime_plugin.EventListener):
"""
Run goimports against Go language syntax documents, on save.
For use in combination with the GoImports SublimeText plugin package.