This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns spazzerr.db | |
(:require [clojurewerkz.elastisch.rest :as esrest] | |
[clojurewerkz.elastisch.rest.index :as esindex] | |
[clojurewerkz.elastisch.rest.document :as esdoc] | |
[clojurewerkz.elastisch.query :as esq])) | |
(def mapped-type "file") | |
(def music-mapping {mapped-type {:properties | |
{:canonical-path {:type "string" :store "yes" :index "not_analyzed"} | |
:last-modified {:type "date", :store "yes"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn do-scan [initial-dir] | |
(dorun | |
(map prn (map :canonical-path | |
(filter identity | |
(map upsert-file-doc | |
(map file-data | |
(supported-files-seq initial-dir)))))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from concurrent.futures import as_completed, ThreadPoolExecutor | |
import random | |
import time | |
def do_some_work(work_input): | |
result = random.choice(range(1,2)) | |
print("sleeping for %s (%s)" % (result, work_input)) | |
time.sleep(result) | |
return (result, work_input) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import random | |
from timeit import timeit | |
try: | |
LISTSIZE = int(sys.argv[1]) | |
except IndexError: | |
LISTSIZE = 100 | |
SETUP = "import random;LISTSIZE=%s;expected_range = range(LISTSIZE);mydata = expected_range[:];mydata.pop(random.choice(xrange(1, len(mydata))))" % LISTSIZE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; example preferences file that I use when editing python projects | |
;; I typically invoke emacs like so... | |
;; $ cd ./to/the/project | |
;; $ emacs -l preferences.el ./ & | |
(setq tw-test-project-dir (file-truename "")) ;; absolute path to this directory | |
(setq bin-dir (concat tw-test-project-dir "/bin")) ;; absolute path to the bin directory | |
(setq tw-test-flags "--failfast") ;; test flags to pass to the test runner | |
(setq tw-test-runner (concat bin-dir "/" "manage_dev.py test ysn")) ;; the test runner(command to run unit tests) | |
(setq tw-project-dir (concat tw-test-project-dir "/src/ysn" )) ;; absolute path to the project src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [1]: import logging | |
In [2]: from webobtoolkit import client | |
In [3]: logging.basicConfig(level=logging.INFO) | |
In [4]: URL = "http://safeway.inserts2online.com/I2O_MainFrame.jsp"; qs="pageNumber=1&drpStoreID=1954&adId=49062&adPath=SafewaySafeway05292013NorcalWeeklyAd" | |
In [5]: c = client.Client(client.client_pipeline(logging=True, log_level="INFO")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
contains decorators for pyramid to discover and add various things to the registry, primarily the service decorator | |
""" | |
import venusian | |
from repoze.lru import lru_cache | |
from zope.interface import implements, Interface, Attribute, classImplements | |
import pyramid | |
from pyramid import testing | |
from pyramid import view | |
import unittest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sqlalchemy as sa | |
from sqlalchemy.ext.declarative import declarative_base, declared_attr | |
class HookEventHandler(object): | |
""" | |
registers itself with the mapper for whatever event name passed in | |
looks for corresponding event_name attribute on target and calls | |
it if it exists | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""play with venusian until you have a decorator that registers | |
classes with request.registry["service"] """ | |
import unittest | |
import venusian | |
from pyramid.config import Configurator | |
class service(object): | |
def __init__(self, name): | |
self.name = name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import zmq | |
import random | |
from multiprocessing import Process | |
import logging | |
logging.basicConfig(level=logging.INFO) | |
class ServerProcess(Process): | |
def run(self): | |
import time |