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
;theme prefs | |
;; color-theme | |
; C-u C-x = to get font info at point | |
(require 'color-theme) | |
(setq color-theme-is-global t | |
frame-background-mode 'dark) | |
(load-file (concat dotfiles-dir "themes/blackboard.el")) | |
;;(load-file (concat dotfiles-dir "themes/irblack.el")) | |
;;(load-file (concat dotfiles-dir "themes/naquadah.el")) | |
(color-theme-blackboard) |
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 random | |
import string | |
# Taken from http://stackoverflow.com/questions/3854692/generate-password-in-python | |
def genpwd(length=16): | |
chars = string.letters + string.digits | |
return ''.join(choice(chars) for _ in xrange(length)) | |
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 seo.models import jobListing | |
from directseo.serializers import XMLExtraSerializer | |
def get_data_from_xmlextraserializer(): | |
host = 'find.ibm.jobs' | |
jobs = jobListing.objects.filter(buid__id=2432,country_short='MEX') | |
s = XMLExtraSerializer([{'name':'url', 'type':'CharField'}]) |
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
result_list = [] | |
for facet in facets: | |
if not facet[1]: | |
result_list.append(jobListing.objects.none()) | |
else: | |
pks = (i.pk for i in facet[0].get_sqs()) | |
result_list.append(jobListing.objects.filter(pk__in=pks)) | |
import ipdb | |
ipdb.set_trace() |
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 operator | |
from haystack.query import SearchQuerySet, SQ | |
stuff = ['foo', 'bar', 'baz'] | |
the_filters = reduce(operator.or_, [SQ(tag=tag_name) for tag_name in stuff]) | |
sqs = SearchQuerySet().filter(the_filters) |
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
filters = { | |
"name": data.get('name'), | |
"phone": data.get('phone'), | |
"area_code": data.get('area_code'), | |
"location_city": data.get('location_city'), | |
"location_state": data.get('location_state'), | |
"location_ZIP": data.get('location_ZIP'), | |
} | |
sqs = SearchQuerySet().models(Person) |
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 join [sep coll] | |
(apply str (interpose sep coll))) |
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 requests | |
class Solr(object): | |
def __init__(self, url, decoder=None, auth=None, timeout=60): | |
self.decoder = decoder or json.JSONDecoder() | |
self.auth = auth | |
self.url = url | |
self.scheme, netloc, path, query, fragment = urlsplit(url) | |
self.base_url = urlunsplit((self.scheme, netloc, '', '', '')) | |
netloc = netloc.split(':') |
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
def add_dicts(svs): | |
""" | |
Performs an "add" operation on multiple SavedSearch attribute dictionaries | |
to create a single attribute dictionary object by which we can perform | |
filtering operations between multiple SavedSearch results. | |
""" | |
if not svs: | |
return {} |
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
;; Breaks on [2 3 3 4 5] | |
;; http://www.4clojure.com/problem/53#prob-title | |
(defn subseq- [coll] | |
(partition-by (fn [x] (= 1 (- (second x) (first x)))) | |
(filter #(< (first %) (second %)) | |
(partition 2 1 coll)))) | |
;; Example | |
(def test-vecs [[1 0 1 2 3 0 4 5] [5 6 1 3 2 7] [2 3 3 4 5] [7 6 5 4]]) |