Skip to content

Instantly share code, notes, and snippets.

import multiprocessing
import os
import time
import Queue
def scoring_function_dummy(jobs, results):
while True:
try:
task = jobs.get(True, 1)
print '%s: working: %s' % (os.getpid(), task)
@chancyk
chancyk / install_dedupe_ubuntu_12.04.txt
Created March 28, 2014 16:47
Successful steps for installing dedupe in a fresh Ubuntu 12.04 docker container.
cd ~
sudo apt-get update
sudo apt-get install wget
wget --no-check-certificate https://raw.github.com/pypa/pip/master/contrib/get-pip.py
python get-pip.py
sudo apt-get install git
mkdir src
cd src
git clone http://github.com/datamade/dedupe
cd dedupe/
@chancyk
chancyk / zope_textindex_profile
Created May 7, 2014 23:59
Profile of zope.index.TextIndex.apply
Line # Hits Time Per Hit % Time Line Contents
==============================================================
66 @profile
67 def apply(self, querytext, start=0, count=None):
68 8734 34597 4.0 0.3 parser = QueryParser(self.lexicon)
69 8734 1622182 185.7 14.1 tree = parser.parseQuery(querytext)
70 8645 2041557 236.2 17.7 results = tree.executeQuery(self.index)
71 8645 12093 1.4 0.1 if results:
72 8645 675324 78.1 5.9 qw = self.index.query_weight(tree.terms())
73
@chancyk
chancyk / dedupe_clustering_behavior.ipynb
Last active August 29, 2015 14:03
Dedupe Clustering Behavior
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@chancyk
chancyk / excel_writer.py
Last active August 24, 2023 00:24
Python context manager for quickly writing tabular data to an Excel worksheet using xlwt or openpyxl.
import os
import re
import tempfile
from subprocess import Popen
from collections import OrderedDict
import xlrd
import xlwt
import xlutils
import openpyxl
@chancyk
chancyk / Sortable-Table.elm
Last active May 23, 2022 19:16
Simple Sortable Table in Elm
import Html exposing (..)
import Html.App as Html
import Html.Attributes exposing (..)
import Html.Events exposing ( onClick )
import Array exposing ( Array )
-- Copied from elm-community/list-extra to remove the 3rd party
-- dependency so that the code can be pasted to: http://elm-lang.org/try
@chancyk
chancyk / contenteditable-error.elm
Created November 11, 2016 16:33
Runtime Error from Clearing a contenteditable DIV
{-| This code will reproduce issue https://github.com/elm-lang/core/issues/749
when the text from either div is cleared.
-}
import Html exposing (text)
import Html.App as App
import Html.Attributes exposing (contenteditable)
import Html.Events exposing (on)
import Json.Decode as Json
@chancyk
chancyk / pyzmq_rpc.py
Last active May 24, 2020 06:39
PyZMQ RPC
"""
LICENSE: MIT
This is an experiment. Use at your own risk.
"""
import sys
import time
import zlib
import pickle
@chancyk
chancyk / threaded_lbbroker.py
Created January 13, 2017 18:45
PyZMQ Threaded Load-Balancing Broker
"""
Threaded Load-balancing Broker
"""
from __future__ import print_function
from threading import Thread
import zmq
@chancyk
chancyk / parsley_sql.py
Last active January 25, 2017 05:41
Python Parsley OMeta SQL Parser
"""
LICENSE
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
DESCRIPTION
This is a prototype, parsley implementation of a subset of a MySQL-like SQL syntax.