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
# -*- coding: utf-8 -*- | |
""" | |
amazon_sender.py | |
~~~~~~~~ | |
Python helper class that can send emails using Amazon SES and boto. | |
The biggest feature of this class is that encodings are handled properly. | |
It can send both text and html emails. | |
This implementation is using Python's standard library (which opens up for a lot more options). |
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
// For more information about this check: http://amix.dk/blog/post/19677 | |
ScriptCommunicator = { | |
sourceJavaScript: function(uri, on_success, on_error) { | |
var xhr = ScriptCommunicator.createCORSRequest('GET', uri); | |
if(xhr) { | |
xhr.onload = function() { | |
eval(xhr.responseText); |
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
#!/usr/bin/env python | |
""" | |
fix_s3_cache_headers | |
~~~~~~~~ | |
Updates S3 objects with new cache-control headers. | |
Usage:: | |
python fix_cloudfront.py <bucket_name> <keys>* |
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
#Rewritten code from /r2/r2/lib/db/_sorts.pyx | |
from math import sqrt | |
def _confidence(ups, downs): | |
n = ups + downs | |
if n == 0: | |
return 0 |
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
#Rewritten code from /r2/r2/lib/db/_sorts.pyx | |
from math import sqrt | |
def _confidence(ups, downs): | |
n = ups + downs | |
if n == 0: | |
return 0 |
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
Score = (P-1) / (T+2)^G | |
where, | |
P = points of an item (and -1 is to negate submitters vote) | |
T = time since submission (in hours) | |
G = Gravity, defaults to 1.8 in news.arc |
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
#!/usr/bin/env python | |
""" | |
fix_s3_cache_headers | |
~~~~~~~~ | |
Updates S3 objects with new cache-control headers. | |
Usage:: | |
python fix_cloudfront.py <bucket_name> <keys>* |
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
@pytest.yield_fixture | |
def v5_api_data(): | |
with resources.project_ctx() as project, \ | |
resources.item_ctx() as task1, \ | |
resources.item_ctx() as task2, \ | |
resources.item_ctx() as in_history: | |
with resources.note_ctx(item_id=task1.id) as note_task_1,\ | |
resources.note_ctx(item_id=in_history.id) as note_task_3: |
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
// JavaScript that solves http://regex.alf.nu/ | |
// Run in Chrome or Firefox console | |
// Enjoy ;-) | |
// Some people, when confronted with a problem, think | |
// “I know, I'll use regular expressions.” | |
// Now they have two problems. | |
for(var lvl in levels) { | |
var fn = function(lvl) { |
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
// JavaScript that solves http://regex.alf.nu/ | |
// Run in Chrome or Firefox console | |
// Enjoy ;-) | |
// Some people, when confronted with a problem, think | |
// “I know, I'll use regular expressions.” | |
// Now they have two problems. | |
for(var lvl in levels) { | |
var fn = function(lvl) { |
OlderNewer