Skip to content

Instantly share code, notes, and snippets.

Avatar

Justin Israel justinfx

View GitHub Profile
@justinfx
justinfx / tree_widget_drag.py
Created Feb 20, 2020
Capturing the start and end item/index information in a PySide2 QTreeWidget internal drag and drop
View tree_widget_drag.py
"""
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 Jul 14, 2019
Dynamically reading a Protobuf FileDescriptorSet file into Python message classes
View read_proto_desc.py
#!/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 Jun 17, 2019
Minimal Qt example of adding a "virtual row" via a proxy model
View qt_proxy_model.py
#!/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 Jan 31, 2019
cython: test converting py2/3 string objects to C++ std::string
View libtest.cc
#include "libtest.hh"
std::string copy_string(std::string &s) {
std::string s2 = s;
return s2;
}
@justinfx
justinfx / README.md
Last active Jan 11, 2019
Repro of nats-io subscribe queue not evenly load balancing to idle workers
View README.md

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 Jul 9, 2018
An example of a test that causes a badgerdb crash with a misleading error string
View badger_close_test.go
package main
import (
"os"
"testing"
"github.com/dgraph-io/badger"
)
/*
View pipes_test.py
#!/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 Oct 24, 2017
python3 asyncore + threading socket server
View py3_asyncore_server.py
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 Mar 6, 2017
SublimeText 3 - anaconda_go plugin - Workaround for 'fmt on save' bug
View goimports_and_save.py
"""
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.
@justinfx
justinfx / maya_qt_error_decorator.py
Created Jan 12, 2017
A decorator to wrap Qt slots, in Maya, so that exceptions are reported to Script Editor
View maya_qt_error_decorator.py
"""
A decorator to wrap Qt slots, in Maya, so that exceptions are reported to Script Editor
Ref: https://groups.google.com/d/topic/python_inside_maya/xv7DCiocDZA/discussion
justinisrael@gmail.com
"""
#...
import sys
You can’t perform that action at this time.