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
(custom-set-variables | |
'(auto-save-file-name-transforms (quote ((".*" "~/.emacs.d/autosaves/\\1" t)))) | |
'(backup-directory-alist (quote ((".*" . "~/.emacs.d/backups/"))))) | |
;; create the autosave dir if necessary, since emacs won't. | |
(make-directory "~/.emacs.d/autosaves/" t) |
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 __set__(self, instance, value): | |
"""Descriptor for assigning a value to a field in a document. | |
""" | |
if isinstance(self.field, EmbeddedDocumentField) and: | |
list_of_docs = list() | |
for doc in value: | |
if isinstance(doc, dict): | |
doc_obj = self.field.document_type_obj(**doc) | |
doc = doc_obj | |
list_of_docs.append(doc) |
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
Inside of PDB | |
(Pdb) x = ifilterfalse(lambda field: isinstance(field, int), [1,2]) | |
(Pdb) list(x) | |
*** Error in argument: '(x)' | |
In normal repl | |
>>> x = ifilterfalse(lambda field: isinstance(field, int), [1,2]) |
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
(defun show-fly-err-at-point () | |
"If the cursor is sitting on a flymake error, display the | |
message in the minibuffer" | |
(interactive) | |
(let ((line-no (line-number-at-pos))) | |
(dolist (elem flymake-err-info) | |
(if (eq (car elem) line-no) | |
(let ((err (car (second elem)))) | |
(message "%s" (fly-pyflake-determine-message err))))))) |
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
if self.headers['METHOD'] == 'JSON': | |
self.data = json.loads(body) | |
else: | |
self.data = {} | |
# populate arguments with QUERY string | |
self.arguments = {} | |
if 'QUERY' in self.headers: | |
query = self.headers['QUERY'] |
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
class APIableMixin(object): | |
def __init__(self, brubeck=None, queryset=None): | |
#create class with self as model and queryset to pull them | |
#register new class to routes | |
#register itself with brubeck's manafest | |
class AutoAPIBase(JSONMessageHandler): | |
def __init__(self, queryset): |
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
#one url to rule them all | |
url = foo/(P?<item_ids>[\d;]*) # note star - so foo/ matches | |
class somekindofhandler(handlerthing): | |
def get(self, item_ids=None): | |
if ';' in item_ids: | |
return do_collection_logic | |
elif item_ids != "": | |
return do_single_logic | |
else: |
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
option 1: | |
url_dicts, url_args = url_check.groupdict(), url_check.groups() | |
if url_dicts: | |
do_thing(**url_dicts) | |
else: | |
do_thing(*url_args) | |
option 2: |
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
package main | |
import ( | |
"log" | |
"os" | |
"sync" | |
"time" | |
) |
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
package main | |
import ( | |
"log" | |
"os" | |
"sync" | |
"time" | |
) | |
var logger = log.New(os.Stdout, "", 0) |
OlderNewer