Skip to content

Instantly share code, notes, and snippets.

View minrk's full-sized avatar

Min RK minrk

View GitHub Profile
import os
from IPython.frontend.qt.console.rich_ipython_widget import RichIPythonWidget
from IPython.frontend.qt.kernelmanager import QtKernelManager
from IPython.frontend.qt.inprocess_kernelmanager import QtInProcessKernelManager
from IPython.kernel.zmq.ipkernel import Kernel
from IPython.kernel.inprocess.ipkernel import InProcessKernel
from IPython.lib import guisupport
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import json, time, threading
import zmq
from zmq.eventloop import ioloop, zmqstream
class Logger( threading.Thread ):
def __init__( self, *args, **kwargs ):
threading.Thread.__init__( self )
self.rtrSocket = None
self.stream = None
@minrk
minrk / gist:3213317
Created July 31, 2012 03:43 — forked from spenthil/gist:3211707
pyzmq: ioloop in separate thread
import zmq
from zmq.eventloop import zmqstream, ioloop
import threading
import logging
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger()
# run ioloop in separate thread
def threaded_loop():
from IPython.frontend.qt.console.qtconsoleapp import IPythonQtConsoleApp
a = IPythonQtConsoleApp()
a.initialize()
# load the sympyprinting extension in the kernel before starting
a.kernel_manager.shell_channel.execute("%load_ext sympyprinting", silent=True)
a.start()
"""
A test forking server
To start a single kernel by forking, do::
python -i testfork.py
The kernel object will be in the ``a`` variable. When you close the
python session, the forked kernel will be killed.
"""
@minrk
minrk / ZeroMQ-XPUB.py
Created April 3, 2012 23:24 — forked from m0sa/ZeroMQ-XPUB.py
Example of the ZeroMQ XPUB socket, that shows how the producer can be controlled by the number of subscribers
import thread
import time
import zmq
# global zmg context
context = zmq.Context()
endpoint = "tcp://*:8888"
# the subscriber thread function
def subscriber(name, address, cnt, subscriptions):
@minrk
minrk / function_lengths.py
Created January 9, 2012 03:32 — forked from wesm/function_lengths.py
Count all function lengths under a directory
import os
import sys
import numpy as np
import matplotlib.pyplot as plt
from pandas import DataFrame
from pandas.util.testing import set_trace
dirs = []
# override ioloop.IOLoop with zmq's IOLoop
import sys
import tornado.ioloop
from zmq.eventloop import ioloop
tornado.ioloop.IOLoop = ioloop.IOLoop
import trombi
loop = ioloop.IOLoop.instance()
# check that tornado's ioloop instance is actually zmq's
@minrk
minrk / zmq_cli.py
Created January 17, 2011 08:34 — forked from amacleod/zmq_cli.py
#!/usr/bin/python
"""
zmq_cli - 0MQ Server interruptability test case, client module.
"""
import zmq