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
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
from bitmapist import cohort | |
html_form = cohort.render_html_form( | |
action_url='/_Cohort', | |
selections1=[ ('Are Active', 'user:active'), ], | |
selections2=[ ('Task completed', 'task:complete'), ] | |
) | |
print html_form |
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 bitmapist import cohort | |
dates_data = cohort.get_dates_data(select1='user:active', | |
select2='task:complete', | |
select3=None, | |
time_group='days') | |
html_data = cohort.render_html_data(dates_data, | |
time_group='days') |
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) { |
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 |