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
#!/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
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
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
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
#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
#!/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
// 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
# Store | |
class CounterStore extends EventEmitter | |
constructor: -> | |
@count = 0 | |
@dispatchToken = @registerToDispatcher() | |
increaseValue: (delta) -> | |
@count += 1 |
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
class ModelCounter | |
constructor: (@value=1) -> | |
increaseValue: (delta) => | |
@value += delta | |
class ControllerCounter | |
constructor: (opts) -> |