Skip to content

Instantly share code, notes, and snippets.

View valsdav's full-sized avatar

Davide Valsecchi valsdav

View GitHub Profile
import multiprocessing as mp
def multiprocessor_generator(iterable, heavy_processing, input_queue_size=10, output_queue_size=20, nworkers=2):
def gen_to_queue(input_q, iterable):
# This function simply consume our generator and write it to the input queue
for it in iterable:
input_q.put(it)
for _ in range(nworkers): # Once generator is consumed, send end-signal
input_q.put(None)

Keybase proof

I hereby claim:

  • I am valsdav on github.
  • I am valsdav (https://keybase.io/valsdav) on keybase.
  • I have a public key ASBY_TBzLQN4P2VX59S150DXCiLE_G9mmrEMrO-Qxdrpqgo

To claim this, I am signing this object:

@valsdav
valsdav / latex_commands_parser.py
Last active January 7, 2016 23:28
Utility functions to manipulate LaTeX commanda
### UTILITY FUNCTIONS ###
from string import *
import re, string,json
'''This function remove a command like \command{content}
even if it contains nested brakets. If delete_content=False it leaves
the content of the command without the command, otherwise it deletes all'''
def remove_command_greedy(tex,command,delete_content=False):
result=''
tokens = tex.split(command)