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 search(request): | |
search_form = SearchForm(request.GET) | |
if search_form.is_valid(): | |
data = form.cleaned_data | |
search_results = watson.filter(Issue, data["q"]).filter( | |
date__gte = data["start_date"], | |
date__lte = data["end_date"], | |
item__name = data["item_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
.spinner-count { | |
&:after { | |
content: "servings"; | |
} | |
} | |
&.spinner-count-1 { | |
.spinner-count { | |
&:after { | |
content: "serving"; | |
} |
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
/** | |
* LESS stylesheet loader. | |
*/ | |
define([ | |
"module", | |
"text" | |
], function( | |
module, | |
text |
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 tempfile, re, codecs | |
from contextlib import closing | |
from functools import partial | |
RE_UNICODE_CONDOM = re.compile(u"[^\x09\x0A\x0D\x20-\uD7FF\uE000-\uFFFD]") | |
MEMORY_BUFFER_SIZE = 1024 * 1024 # 1M | |
CHUNK_SIZE = 1024 * 512 # 0.5M |
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
return not any ( | |
frozenset(permissions_grant).difference(chain.from_iterable( | |
parent_permissions_grant | |
for parent_model_grant, parent_permissions_grant | |
in parent_scope | |
if all( | |
parent_model_grant_part == model_grant_part | |
for model_grant_part, parent_model_grant_part | |
in izip_longest( | |
model_grant, |
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
-----BEGIN PGP PUBLIC KEY BLOCK----- | |
Version: GnuPG/MacGPG2 v2.0.19 (Darwin) | |
mQENBE228RIBCACuc/n1SvMxe7RQWrgOK4Hi1Pn8K9KcZNy0j+kmk319/W8GiqAC | |
qOKMcVIl+KA4zBy7KwCUkkEFUEJn4OwQky9NIyAJw7djyWkkMAAGSqvRWrbt+TF4 | |
AOje8EHJTF5r+4tytLRAHl7sRAHkBWdvPJKp5I9KLjbDu55q65dj8Gkjd0lKxk5n | |
b5IDTn5p3tx82j+DokdJ8YnmGq4fXtG6oUmi+EXlKV24Jo3+mlrNo3MKBMMQekuO | |
WJLhldnJiapnkaadDKqpiJ+7thPoemou4qizqxHaSZCmThegNzA+kP9sseM1YDk5 | |
kcy2xvxQu77BMpZ3s2zc2vviDY4S9/WMIRWnABEBAAG0HERhdmUgSGFsbCA8ZGF2 | |
ZUBldGlhbmVuLmNvbT6JATsEEwECACUCGy8GCwkIBwMCBhUIAgkKCwQWAgMBAh4B |
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 | |
win_on_switch = 0 | |
win_on_stay = 0 | |
for _ in xrange(100000): | |
prize_box = random.randint(0, 2) | |
print "Prize is in box", prize_box | |
initial_choice_box = random.randint(0, 2) | |
print "You choose box", initial_choice_box |
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
var fs = require("fs"); | |
var path = require("path"); | |
// TODO: Code block should be indented compared to previous line? | |
module.exports = function(modulePath) { | |
// Parse the module name. | |
var moduleName = path.basename(modulePath, ".js"); | |
// Load the contents. | |
var contents = fs.readFileSync(modulePath); |
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
# This defines a 10 megabyte cache for the proxy service, and needs to live | |
# outside of the virtual host configuration. Adjust the path according to | |
# your environment. | |
proxy_cache_path /var/cache/nginx/twitter_api_proxy levels=1:2 keys_zone=twitter_api_proxy:10m; | |
# The virtual host configuration. | |
server { | |
# If your want to secure your proxy with SSL, replace with the appropriate SSL configuration. | |
listen 80; |
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 itertools import izip_longest | |
from watson.registration import SearchEngine, _bulk_save_search_entries | |
def grouper(n, iterable, fillvalue=None): | |
"Collect data into fixed-length chunks or blocks" | |
args = [iter(iterable)] * n | |
return izip_longest(fillvalue=fillvalue, *args) | |
for engine_slug, search_engine in SearchEngine.get_created_engines(): | |
registered_models = search_engine.get_registered_models() |