Skip to content

Instantly share code, notes, and snippets.

# I was folling this tutorial http://gettechtalent.com/blog/tutorial-real-time-frontend-updates-with-react-serverless-and-websockets-on-aws-iot.html
# but I didn't like the idea of a lambda function just for presigned URL if we already have an API that could handle this
# but... there is no Python package that does ONLY this presigned url generation
# so I decided to "translate" the code of npm package 'aws-signature-v4' (https://git.department.se/department/aws-signature-v4.git) to Python
# probably there are bugs as I only have test it with my specific params.
import urllib.parse
import hmac
import hashlib
from datetime import datetime
import re
from collections import OrderedDict
import requests
import numpy
import matplotlib.pyplot as plot
def compute_list_score(list_id, members_ids):
cards_url = 'https://api.trello.com/1/lists/{}/cards?fields=all&token=[TOKEN]&key=[KEY]'.format(list_id)

Given an array strings, determine whether it follows the sequence given in the patterns array. In other words, there should be no i and j for which strings[i] = strings[j] and patterns[i] ≠ patterns[j] or for which strings[i] ≠ strings[j] and patterns[i] = patterns[j].

Example

For strings = ["cat", "dog", "dog"] and patterns = ["a", "b", "b"], the output should be areFollowingPatterns(strings, patterns) = true; For strings = ["cat", "dog", "doggy"] and patterns = ["a", "b", "b"], the output should be areFollowingPatterns(strings, patterns) = false.

@henocdz
henocdz / aliases.sh
Last active September 20, 2018 14:06
# REACT NATIVE
alias rnlios="react-native log-ios"
# DJANGO
alias djmm="python manage.py makemigrations"
alias djm="python manage.py migrate"
alias djrun="python manage.py runserver 0.0.0.0:8000"
alias pm="python manage.py"
alias pmt="python manage.py test"
@henocdz
henocdz / zip_write_dir.py
Last active September 21, 2018 00:50
Write files from folder recursively into ZIPFile object
def zip_write_dir(zip_fileobj, dir_path, files_prefix=''):
for dirpath, dirnames, dirfiles in os.walk(dir_path):
for dirname in dirnames:
if files_prefix:
dir_prefix = '%s/%s' % (files_prefix, dirname)
else:
dir_prefix = dirname
dir_path = os.path.join(dirpath, dirname)
zip_write_dir(zip_fileobj, dir_path, files_prefix=dir_prefix)
from django.db.models import Sum
from core.services.main.finance import FinanceSvc
from core.models import ShiftAssignment
import arrow
finance_svc = FinanceSvc()
branch_id = 563
month_date = "2019-04-01 00:00"
a_month_date = arrow.get(month_date)