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
from molly.apps.feeds.events import IndexView, Feed | |
from unittest import TestCase | |
class TestMocking(TestCase): | |
def test_mock_count(self): | |
Feed.objects = Mock() | |
feeds = [Feed(url='http://foo.bar'), Feed(url='http://bar.baz')] | |
mock_queryset = Mock(return_value=feeds) | |
mock_queryset.count.return_value = 42 | |
Feed.objects.all = mock_queryset |
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 IdentifierList(list): | |
... def by_namespace(self): | |
... return None | |
... | |
>>> class Locality(): | |
... @property | |
... def identifiers(self): | |
... return IdentifierList(self._identifiers) | |
... @identifiers.setter | |
... def identifiers(self, value): |
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 Old(): | |
... pass | |
... | |
>>> class New(object): | |
... pass | |
... | |
>>> type(Old()) | |
<type 'instance'> | |
>>> type(New()) | |
<class '__main__.New'> |
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
cd ~ | |
sudo apt-get update | |
sudo apt-get install openjdk-7-jre -y | |
wget https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.19.6.tar.gz -O elasticsearch.tar.gz | |
tar -xf elasticsearch.tar.gz | |
rm elasticsearch.tar.gz | |
sudo mv elasticsearch-* elasticsearch | |
sudo mv elasticsearch /usr/local/share |
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
from flask import Blueprint | |
from .helpers import template_or_json | |
from .views import ServiceView, register_mimetype | |
places = Blueprint('places', __name__, template_folder='templates') | |
@places.route('/') | |
@template_or_json('places/search.html') |
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 requests | |
auth = (USER, PASS) | |
for repo in requests.get('https://api.github.com/user/subscriptions', params={'per_page': 100}, auth=auth).json: | |
if repo['name'].startswith('wl-'): | |
requests.delete('https://api.github.com/user/subscriptions/%s/%s' % (repo['owner']['login'], repo['name']), auth=auth) |
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
"slug":"history-of-science", | |
"website":"http://www.mhs.ox.ac.uk/", | |
"lng":-1.255504, | |
"opening_hours":"Tuesday to Friday: 12-5pm; Saturday: 10am-5pm; Sunday: 2-5pm; Monday: Closed", | |
"_links":{ | |
"items":{ | |
"href":"/museums/history-of-science/items/" | |
}, | |
"self":{ | |
"href":"/museums/history-of-science/" |
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 json | |
import urllib2 | |
import os | |
import codecs | |
from urlparse import urlparse | |
from string import Template | |
build_dir = os.environ['TARGET_FOLDER'] |
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
define(['underscore'], function(_) { | |
return { | |
replace: function (images) { | |
// Look for the image in our preloaded images and replace | |
// the path if we find it. | |
var preload = window.preload || {}; | |
_.each(images, function (val, key) { | |
if (_.has(preload, val)) { | |
images[key] = preload[val]; | |
} |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<opml version="1.0"> | |
<head> | |
<title>Programming blogs</title> | |
</head> | |
<body> | |
<outline text="Developer blogs" title="Developer blogs"> | |
<outline type="rss" text="flak rss" title="flak rss" xmlUrl="http://www.tedunangst.com/flak/rss" htmlUrl="http://www.tedunangst.com/flak/"/> | |
<outline type="rss" text="Kamal Marhubi" title="Kamal Marhubi" xmlUrl="http://kamalmarhubi.com/blog/feed.xml" htmlUrl="http://kamalmarhubi.com/"/> |
OlderNewer