This file contains hidden or 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 fetch-page-title (&rest args) | |
(let* ((page-tree (libxml-parse-html-region (point-min) (point-max))) | |
(titles (dom-by-tag page-tree 'title)) | |
(url (cadr args)) | |
(target-buffer (nth 1 (cdr args))) | |
(target-point (nth 2 (cdr args)))) | |
(message "URL: %s" url) | |
(if (null titles) (error "Title not found on page") | |
(save-excursion | |
(switch-to-buffer target-buffer) |
This file contains hidden or 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 say_hello(): | |
print("Hello world from Cython!") |
This file contains hidden or 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 build_book_inventory(book_ids, shops): | |
shop_labels = [shop['label'] for shop in shops] | |
book_list = Persistency.books_table.read( | |
shops=shop_labels, | |
books=book_ids) | |
inventory = {} | |
for book_item in book_list: | |
shop_label = book_item['shop_label'] | |
cell_label = book_item['cell_label'] | |
book_id = book_item['book_id'] |
This file contains hidden or 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
processor_spec: | |
to_dict: | |
- "My name is {name} and I'm {age:d} years old." | |
port: 8888 | |
address : '0.0.0.0' | |
indexer_config: | |
host: localhost | |
port: 9200 |
This file contains hidden or 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 socket | |
import json | |
from tornado.testing import AsyncTestCase, gen_test | |
from tornadoes import ESConnection | |
from tornado.iostream import IOStream | |
from SampleService import MainHandler | |
class SampleServiceTests(AsyncTestCase): |
This file contains hidden or 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
function nukebranch () { | |
BRANCH=`git rev-parse --abbrev-ref HEAD` | |
if [ $BRANCH == 'master' ]; then | |
echo "Refusing to delete master" | |
else | |
(git push origin --delete $BRANCH || true) && git checkout master && git branch -d $BRANCH | |
fi | |
} |
This file contains hidden or 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
product = Product(color='red', size='small', weight='light') | |
pq = BasicProductQuery(color='red') | |
assert product in pq | |
assert product not in ~pq | |
SmallAndLight = BasicProductQuery(size='small') & BasicProductQuery(weight='light') | |
assert product in SmallAndLight | |
SmallAndLightOrNotRed = SmallAndLight | ~BasicProductQuery(color='red') | |
product2 = Product(size='big', color='blue', weight='heavy') |
This file contains hidden or 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 Product(object): | |
def __init__(self, color, size, weight): | |
self.color, self.size, self.weight = color, size, weight | |
class CombinableQueryMixin(object): | |
def __and__(self, other): | |
return CompoundQuery(self, other, anded=True) |