Created
March 29, 2017 12:40
-
-
Save tripleee/307c0f5981b38e056e51cd3656716549 to your computer and use it in GitHub Desktop.
Average deletion time from Metasmoke JSON dump
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 | |
import sys, json | |
from datetime import datetime, timedelta | |
with open(sys.argv[1], 'r') as input: | |
j = json.load(input) | |
deleted = list() | |
alive = list() | |
for i in j: | |
if 'deleted_at' in i and i['deleted_at'] is not None: | |
for k in ['created_at', 'deleted_at']: | |
i['epoch_' + k] = datetime.strptime(i[k].split('.')[0], | |
'%Y-%m-%dT%H:%M:%S') | |
delta = i['epoch_deleted_at'] - i['epoch_created_at'] | |
i['lived'] = delta.total_seconds() | |
deleted.append(i) | |
else: | |
i['alive'] = True | |
alive.append(i) | |
print("alive: {0}".format(len(alive))) | |
print("dead: {0}".format(len(deleted))) | |
print("average lifespan: {0}".format(sum([x['lived'] for x in deleted])/len(deleted))) | |
print("") | |
# These are actually probably deleted, just not in Metasmoke's database (it stops looking after a while) | |
for a in alive: | |
print("{0} https://{1}".format(a['created_at'], a['link'])) |
For Graphics Design, as of a bit earlier today, 7 "alive" (which were actually all deleted) and average lifespan for the rest 183.405376344 seconds.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://metasmoke.erwaysoftware.com/search?body=&commit=Search&feedback=&feedback_filter=tp&reason=&site=68&title=&user_rep_direction=%3E%3D&user_reputation=0&username=&utf8=%E2%9C%93&why= displays recent spam with "true positive" (i.e. not false positive, categorization mistake, vandalism etc) feedback on GD. The footer of the page contains a link where you can get the first 100 results as JSON: https://metasmoke.erwaysoftware.com/search.json?body=&commit=Search&feedback=&reason=&site=68&title=&user_rep_direction=%3E%3D&user_reputation=0&username=&utf8=%E2%9C%93&why=