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 python3 | |
# coding: utf-8 | |
import argparse | |
import re | |
from uuid import uuid4 | |
from hashlib import sha256 | |
SALT = str(uuid4()).encode() |
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 re | |
import json | |
import asyncio | |
from textwrap import dedent | |
from urllib.parse import urljoin | |
from aiohttp import web | |
async def index(_): | |
return web.Response(text=""" |
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 python3 | |
# -*- coding: utf-8 -*- | |
from __future__ import unicode_literals | |
import argparse | |
import re | |
import os | |
import subprocess |
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
create or replace | |
function romanize_numbers(s text) | |
returns text | |
as $$ | |
select | |
string_agg( | |
m [1] || | |
case when char_length(m [2]) between 1 and 3 | |
then trim(to_char(m [2] :: int, 'RN')) | |
else m [2] |
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 collections import namedtuple | |
def auto_dict(val): | |
# type: (Union[Dict, NamedTuple]) -> Dict | |
""" | |
Transforms named tuples into dict. Does nothing if `val` is already a dict. | |
:param val: a NamedTuple instance or a dict | |
:return: dict version of val | |
""" |
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
# vim: fileencoding=utf-8 tw=100 expandtab ts=4 sw=4 : | |
import requests | |
import time | |
import os | |
token = os.getenv('SLACK_TOKEN') | |
# Delete files older than this: | |
ts_to = int(time.time()) - (3600 * 24 * 30) |
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
/*vim: fileencoding=utf8 tw=100 expandtab ts=4 sw=4 */ | |
/*jslint indent: 4, maxlen: 100, browser: true */ | |
/*globals console, Element*/ | |
(function (exports) { | |
'use strict'; | |
function findTheFucker(root, width, restoreAll) { | |
var fucker; |
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
# vim: fileencoding=utf-8 tw=100 expandtab ts=4 sw=4 : | |
import json | |
import hmac | |
from hashlib import sha256 | |
from uuid import uuid4 | |
from time import time | |
def force_bytes(s): |
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
point = geometry.centroid | |
if point.srid is not None: | |
point.transform(4326) | |
try: | |
tzid = self.filter(zone__contains=point)[0].tzid | |
return tzid, point | |
except IndexError: | |
return None, point |
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 TimeZone(models.Model): | |
objects = TimeZoneManager() | |
zone = PolygonField(spatial_index=True) | |
tzid = models.CharField(max_length=100) |