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 zigzag_sorted(iterable, key=None): | |
"""It returns list sorted in zigzag. | |
:rtype: generator object (iterator) | |
>>> list(zigzag_sorted([1, 2, 3, 4, 5, 6, 7])) | |
[1, 7, 2, 6, 3, 5, 4] | |
""" | |
i = 0 | |
l = sorted(iterable, key=key) | |
n = len(l) |
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
export const range = (start: number, stop: number, step: number=1) => { | |
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from#Sequence_generator_(range) | |
return Array.from({ length: (stop - start - 1) / step + 1}, (_, i) => start + (i * step)); | |
} | |
export const all = (values: any[]) => { | |
for (let value of values) { | |
if (!value) { | |
return false; | |
} |
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
const { pbkdf2Sync } = require('crypto'); | |
export const validate = (raw, password, len=32) => { | |
const [method, iterations, salt, hash] = password.split('$'); | |
const digest = method.split("_")[1]; | |
return pbkdf2Sync(raw, salt, parseInt(iterations, 10), len, digest).toString('base64') === hash; | |
}; | |
export const make = (raw, iterations, digest="sha256", salt="", len=32) => { | |
if (salt === "") { |
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 json | |
import urllib.request | |
WEBHOOK_URL = "https://hooks.slack.com/services/XXXXXXXXXX/YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY" | |
MESSAGE_TEMPLATE = """<{url}|{message}>""" | |
def lambda_handler(event, context): | |
post(event) | |
return {"statusCode": 200} |
OlderNewer