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
@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()
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 / 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
@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 = [*?⚀..?⚅]
# => ["⚀", "⚁", "⚂", "⚃", "⚄", "⚅"]