Skip to content

Instantly share code, notes, and snippets.

package jeromq.bugs;
import org.zeromq.ZContext;
import org.zeromq.ZMQ;
import org.zeromq.ZMQ.Socket;
public class BindIssue {
public static void main(String[] args) {
System.out.printf("zeromq v%s\n",ZMQ.getVersionString());
@jason-s
jason-s / samplestruct python
Last active August 29, 2015 13:57
samplestruct.mat
>>> import scipy.io
>>> S=scipy.io.loadmat('samplestruct.mat')
>>> S['foo']
array([[ ([[(array([[1, 2, 3]], dtype=uint8), array([[-1, -2, -3]], dtype=int16)
)]], [[123]])]],
dtype=[('bar', 'O'), ('quux', 'O')])
>>> S['foo']['bar']
array([[ array([[([[1, 2, 3]], [[-1, -2, -3]])]],
dtype=[('tweedledee', 'O'), ('tweedledum', 'O')])]], dtype=object)
>>> S['foo']['bar']['tweedledee']
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# based on
# https://qt.gitorious.org/pyside/pyside-examples/source/060dca8e4b82f301dfb33a7182767eaf8ad3d024:examples/itemviews/simpletreemodel/simpletreemodel.py
############################################################################
##
## Copyright (C) 2005-2005 Trolltech AS. All rights reserved.
##
{%- extends 'html_basic.tpl' -%}
{%- block header -%}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>[{{nb.metadata.name}}]</title>
@jason-s
jason-s / qtableview_completer.py
Created August 25, 2014 21:32
example of QTableView + QCompleter in PySide
from PySide import QtCore, QtGui
from PySide.QtCore import Qt
from PySide.QtGui import QWidget, QTableView, QVBoxLayout, QApplication
def setup_consonants_vowels():
letters = 'abcdefghijklmnopqrstuvwxyz'
vowels = set(['a','e','i','o','u','A','E','I','O','U'])
consonants = set([c for c in (letters + letters.upper()) if not c in vowels])
return (consonants, vowels)
import zmq
import codecs
import logging
logger = logging.getLogger(__name__)
def rot13(s):
return codecs.encode(s,'rot_13')
class Rot13Server(object):
@jason-s
jason-s / png_add_dpi.py
Created October 21, 2014 15:43
Add DPI to PNG files
'''
Copyright 2014 Jason M. Sachs
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
<html>
<head>
<style type="text/css">
div.item {
display: block;
border: 1px solid #888;
border-radius: 5px;
padding: 2px 15px;
}
span.rotated {
import enaml
from enaml.widgets.api import Window, Form, Label, Field, ComboBox
from enaml.stdlib.fields import IntField
from enaml.qt.qt_application import QtApplication
from atom.api import Int, Long, Atom
class Model(Atom):
longvalue = Long()
enamldef Main(Window):
@jason-s
jason-s / hilbertcurve.html
Created December 15, 2014 17:39
Hilbert curve generator using Javascript + SVG
<html>
<head>
<script type="text/javascript">
function createSVG(e)
{
return document.createElementNS("http://www.w3.org/2000/svg",e);
}
function left(v)
{
x = v[0];