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 | |
for line in sys.stdin: | |
if line.startswith('"'): | |
index = line.find('"', 1) | |
fields = [line[1:index]]+line[index+2:].split(',') | |
else: | |
fields = line.split(',') |
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 | |
last_k = None | |
last_v = 0 | |
for line in sys.stdin: | |
k, v = line.strip().split('\t') |
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 re | |
import sys | |
started = False | |
for line in sys.stdin: | |
if started: |
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 | |
last_k = None | |
max_v = 0 | |
for line in sys.stdin: | |
k, v = line.strip().split('\t') |
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 | |
for line in sys.stdin: | |
if not line.strip() or line.startswith('Wban'): | |
continue | |
_, k, v = line[:17].split(',', 2) | |
try: |
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 get_visits(groupby): | |
ip_visits = data.groupby(groupby)['ip'] | |
return pd.DataFrame( | |
{'unique_visits': ip_visits.apply(lambda x: len(set(x))), | |
'total_visits': ip_visits.apply(len)}) | |
data['date_day'] = data['date'].apply(datetime.date) | |
visits_by_date = get_visits('date_day') | |
# Redefine with date index to avoid lack of dates. | |
visits_by_date = pd.DataFrame(visits_by_date, |
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 datetime import datetime, timedelta | |
import pandas as pd | |
source = pd.read_csv('data.csv', index_col='uuid', parse_dates=['date']) | |
date_1 = datetime.utcnow() | |
date_0 = date_1 - timedelta(days=30) | |
data = source[(source['date'] > date_0) & (source['date'] < date_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
import os | |
import json | |
from tornado.web import RequestHandler | |
from pygeoip import GeoIP | |
import dateutil.parser | |
from app.models import Visit | |
from app import settings |
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 data, ua, platform, browser, os; | |
data = { | |
page: window.location.pathname.replace(/\/$/, ''), | |
language: navigator.language.slice(0, 2).toUpperCase(), | |
screen_resolution: window.screen.width + 'x' + window.screen.height, | |
screen_dpi: window.devicePixelRatio, | |
is_touch_device: 'ontouchstart' in window || 'onmsgesturechange' in window | |
}; | |
ua = navigator.userAgent.toLowerCase(); |
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/python | |
""" | |
Google translate client | |
usage: python translate.py [-h] [-v] [-ua User-Agent] source_lang target_lang text | |
positional arguments: | |
source_lang | |
target_lang |
NewerOlder