Skip to content

Instantly share code, notes, and snippets.

View jasonrhaas's full-sized avatar
🎯
Consulting @ Data North

Jason Haas jasonrhaas

🎯
Consulting @ Data North
View GitHub Profile
@jasonrhaas
jasonrhaas / app.py
Last active January 30, 2019 22:35
get_tiny_url
@app.route('/', methods=['GET', 'POST'])
def get_tiny_url():
if request.method == 'POST' and request.is_json:
long_url = request.get_json().get('url')
if not long_url:
abort(400)
if not long_url.startswith('http'):
long_url = f'http://{long_url}'
h = blake2b(long_url.encode(), digest_size=20).hexdigest()
app.logger.debug(h)
@app.route('/<tiny_url>', methods=['GET'])
def get_long_url(tiny_url):
if request.method == 'GET':
try:
url_id = short_url.decode_url(tiny_url)
except Exception:
abort(500)
app.logger.debug(url_id)
url = Url.query.filter_by(id=url_id).first()
app.logger.debug(url)
CREATE OR REPLACE FUNCTION pseudo_encrypt(VALUE bigint) returns bigint AS $$
DECLARE
l1 bigint;
l2 bigint;
r1 bigint;
r2 bigint;
i int:=0;
BEGIN
l1:= (VALUE >> 32) & 4294967295::bigint;
r1:= VALUE & 4294967295;
from github import Github
import os
import sys
# First create a Github instance: using an access token
access_token = os.getenv('GITHUB_ACCESS_TOKEN')
g = Github(access_token)
# Select your repo