Skip to content

Instantly share code, notes, and snippets.

View mrtj's full-sized avatar

Janos Tolgyesi mrtj

View GitHub Profile
@mrtj
mrtj / UIView+Blur.h
Created July 4, 2013 15:20
Create blurred image from any UIView #objective-c
#import <UIKit/UIKit.h>
@interface UIView (Blur)
+(UIImage*)createBlurredImageFromView:(UIView*)view;
@end
@mrtj
mrtj / BouncyButtonViewController.h
Created February 19, 2014 10:56
iOS view controller demonstrating how to create a bouncy rubber button with the new UIView method animateWithDuration:delay:usingSpringWithDamping:initialSpringVelocity:options:animations:completion: of iOS 7
#import <UIKit/UIKit.h>
@interface BouncyButtonViewController : UIViewController
@end
@mrtj
mrtj / ggcore_enable_sync.py
Created October 4, 2018 16:13
A python script that enables IoT shadow syncing for an AWS Greengrass Core
import boto3
import logging
import json
import re
import uuid
import argparse
'''
This script enables the IoT shadow syncing for your AWS Greengrass Core.
@mrtj
mrtj / csv2md.py
Last active November 12, 2018 11:43
Convert a CSV file to a Markdown table
from __future__ import print_function
import csv
def print_row(row, maxlen):
for elem, len in zip (row, maxlen):
print('| {} '.format(elem.ljust(len)), end='')
print('|')
def print_hline(maxlen):
for len in maxlen:
@mrtj
mrtj / parse_telegram_export.py
Last active April 7, 2022 10:10
Parse the html export of a Telegram chat
''' The parse_telegram_export function in this gist parses the html export of a Telegram chat.
You should have [BeautifulSoup](https://www.crummy.com/software/BeautifulSoup/bs4/) and
[dateutil](https://dateutil.readthedocs.io/) installed. It extracts the sender name, the
message date and time, the message text and the links in the message.
'''
from bs4 import BeautifulSoup
import dateutil
def parse_telegram_export(html_str, tz_name=None):
@mrtj
mrtj / covid-19-mortality-municipality-table.md
Last active April 20, 2020 16:38
mortality-covis19 article, municipality table
@mrtj
mrtj / local_ref.py
Last active March 13, 2022 14:07
Use local references in jsonschema python package
import os
import json
from pathlib import Path
from urllib.parse import urljoin
import jsonschema
def add_local_schemas_to(resolver, schema_folder, base_uri, schema_ext='.schema.json'):
''' Add local schema instances to a resolver schema cache.
@mrtj
mrtj / aws_iot_direct_call.py
Created September 30, 2020 15:25
Call any AWS service directly using the credentials of AWS IoT device certificate
'''
A snippet demonstrating how an AWS IoT device can make direct calls to every AWS
service using only the device certificate and private key.
For more info see the docs at https://docs.aws.amazon.com/iot/latest/developerguide/authorizing-direct-aws.html
to create the role and the role alias. To get the AWS IoT credential provider endpoint of your account you can use
$ aws iot describe-endpoint --endpoint-type iot:CredentialProvider
Dependencies: requests and boto3
@mrtj
mrtj / augmented_image_format.py
Last active May 4, 2021 21:41
Create Augmented Manifest Image Format for dogs-vs-cats dataset in a local folder
import glob
prefix = 's3://my_bucket/dogs_vs_cats/'
with open('manifest.jsonl', 'w') as f:
for img in glob.glob('*.jpg'):
lbl = 0 if img.startswith('dog') else 1
f.write('{{"source-ref":"{}{}", "class":"{}"}}\n'\
.format(prefix, img, lbl))