Skip to content

Instantly share code, notes, and snippets.

@dniku
dniku / zmq_error.py
Last active September 23, 2020 08:28
ZMQError: Interrupted system call
import multiprocessing, threading, time, Queue
import zmq
class RPCServer(threading.Thread):
def __init__(self, rpc_address, queue):
super(RPCServer, self).__init__(name="RPC server")
self.queue = queue
self.rpc_address = rpc_address
self.stopped = False
import threading, multiprocessing, time, Queue
from spyne import MethodContext
from spyne.application import Application
from spyne.service import ServiceBase
from spyne.decorator import rpc
from spyne.protocol.msgpack import MessagePackRpc
from spyne.client.zeromq import ZeroMQClient
from spyne.auxproc import process_contexts
from spyne.server.zeromq import ZeroMQServer, ZmqMethodContext
@dniku
dniku / queue_performance.py
Last active August 29, 2015 14:28
Python queue performance
import threading
import Queue
import random, time
import os, psutil
import gevent
import gevent.queue
proc = None
from __future__ import division
import pandas as pd
import datetime
time_format = '%d. %m. %Y %-H:%M'
def from_javatime(time):
return datetime.datetime.fromtimestamp(time // 1000)
def quote(s):
@dniku
dniku / fix_transmission_resume.py
Created June 2, 2015 15:15
how to update paths in transmission's resume files
import os, glob, shutil, bencode
from pprint import pprint
fail_path = 'failed'
def fix_resume(resume_path, old_destination, new_destination, old_incomplete, new_incomplete):
for path in glob.glob(os.path.join(resume_path, '*.resume')):
# print(path)
with open(path, 'r') as f:
try:
@dniku
dniku / mnist_loader_sklearn.py
Created April 13, 2015 21:34
loading mnist and converting it to lmdb
from __future__ import division, print_function
import os
import cv2
import numpy as np
from sklearn.datasets import fetch_mldata
from sklearn.cross_validation import train_test_split
@dniku
dniku / lenet_train_test.prototxt
Last active August 29, 2015 14:19
Lenet caffe description with loading from IMAGE_DATA
name: "LeNet"
layer {
name: "mnist"
type: "Data"
top: "data"
top: "label"
include {
phase: TRAIN
}
data_param {
@dniku
dniku / solver.prototxt
Created April 13, 2015 17:46
Lenet solver which reports more often
# The train/test net protocol buffer definition
net: "lenet_train_test.prototxt"
# test_iter specifies how many forward passes the test should carry out.
# In the case of MNIST, we have test batch size 100 and 100 test iterations,
# covering the full 10,000 testing images.
test_iter: 100
# Carry out testing every 20 training iterations.
test_interval: 20
# The base learning rate, momentum and the weight decay of the network.
base_lr: 0.01
@dniku
dniku / mnist_loader_sklearn.py
Last active August 29, 2015 14:19
Dumping MNIST digits as images in a separate folder
from __future__ import division, print_function
import os
import cv2
import numpy as np
from sklearn.datasets import fetch_mldata
from sklearn.cross_validation import train_test_split
@dniku
dniku / owncloud-cron-crash.log
Created April 6, 2015 11:08
php -f cron.php
PHP Warning: flock() expects parameter 1 to be resource, boolean given in /var/www/localhost/htdocs/owncloud/lib/private/config.php on line 178
PHP Fatal error: Call to a member function getValue() on a non-object in /var/www/localhost/htdocs/owncloud/lib/private/legacy/config.php on line 46