Skip to content

Instantly share code, notes, and snippets.

View gyfis's full-sized avatar
:shipit:
pushing code to production

Tomáš Hromada gyfis

:shipit:
pushing code to production
View GitHub Profile
async function ddProgress() {
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
function clearAllTimeouts() {
let id = window.setTimeout(function() {}, 0);
while (id--) {
window.clearTimeout(id);
}
}
96989,433311,1627877,1706969,2611409,2825389,13486066,13486217,13487610,13503652,13507756,13507757,13507802,13507803,13509753,13511180,13511548,13515785,13518955,13519383,13519433,13519466,13521829,13523310,13527780,13970692,13971400,13972379,13975473,13975474,13977901,13977902,13977934,13981651,13983445,13983480,13983481,13983528,13984806,13984806,13985913,13990838,13992376,13994531,13995143,13996157,13999377,13999982,14003942,14003968,14003993,14005391,14007308,14010777,14010778,14010785,14010786,14021254,14021518,14024836,14024837,14027405,14032502,15380368,15386449,15387410,15390571,15391640,18114403,18115678,18115815,18116282,18116366,18122343,18122344,18122407,18361552,18371859,18616306,18616375,18616492,18617529,18617924,18623112,18623114,18623686,18625017,18625393,18626308,18626813,18626934,18631994,18632560,18641656,18643580,18646327,18646340,18650594,18650594,18650596,18650600,18650769,18650769,18651341,18654708,18655538,18656664,18656956,18658511,18658511,18658517,18658519,18658519,18658914,1866038
@gyfis
gyfis / weighted_random_sampling.md
Created November 1, 2019 09:36 — forked from O-I/weighted_random_sampling.md
[TIx 8] Weighted Random Sampling in Ruby

One of the many reasons I love working with Ruby is it has a rich vocabulary that allows you to accomplish your goals with a minimal amount of code. If there isn't a method that does exactly what you want, it's usually possible to build an elegant solution yourself.

Let's take the example of simulating the rolling of a die.

We can represent a die as an array of its faces.

die = [*?⚀..?⚅]
# => ["⚀", "⚁", "⚂", "⚃", "⚄", "⚅"]
@gyfis
gyfis / api.js
Last active January 18, 2019 10:48
Path parameters inconsistency - SAM
// hello_world/api.js
exports.lambdaHandler = async (event, context) => {
return {
'statusCode': 200,
'body': JSON.stringify(event)
}
};
// 127.0.0.1:3000/test/users/3/file/Desktop%2Fphotos%2Fcat.png
// output -> local_response.json
import numpy as np
def split_price(split, warehouse_prices, warehouse_min_price, freight_cost):
price_per_warehouse = list(map(lambda row: sum(row[0] * row[1]), zip(warehouse_prices, split)))
price = sum(price_per_warehouse)
for warehouse_id, warehouse_price in enumerate(price_per_warehouse):
if 0 < warehouse_price < warehouse_min_price[warehouse_id]:
price += freight_cost
return price
@gyfis
gyfis / pdf_interpolate_false.py
Created May 9, 2017 14:48
Last frontier destroyed, submitting thesis.pdf
from pdfrw import PdfReader, PdfWriter, PdfObject
def main():
thesis = PdfReader('thesis.pdf')
for i, _ in enumerate(thesis.pages):
try:
im_keys = thesis.pages[i].Resources.XObject.keys()