Skip to content

Instantly share code, notes, and snippets.

View mrtj's full-sized avatar

Janos Tolgyesi mrtj

View GitHub Profile
@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 / TJIntegerArray.h
Last active July 18, 2018 19:47
Simple Objective C wrapper around a C integer array. Supports fast enumeration via NSNumber objects. #integer #array #objective-c License: BSD
// Author: janos.tolgyesi@gmail.com
// License: BSD
#import <Foundation/Foundation.h>
@interface TJIntegerArray : NSObject <NSFastEnumeration>
{
NSInteger* _array;
}
@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 / NSURL+QueryParser.h
Created May 20, 2013 15:58
NSURL category to parser GET parameters from the URL into a NSDictionary #objective-c #utils #url
#import <Foundation/Foundation.h>
@interface NSURL (QueryParser)
-(NSDictionary*)queryDictionary;
@end
@mrtj
mrtj / covid-19-mortality-municipality-table.md
Last active April 20, 2020 16:38
mortality-covis19 article, municipality table
@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 / 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))
aws stepfunctions start-execution \
  - state-machine-arn {CrossValidatorStateMachineArn} \
  - input file://my_input.json
@mrtj
mrtj / augmented_image_format_s3.py
Last active May 5, 2021 10:39
Create Augmented Manifest Image Format for dogs-vs-cats dataset in an S3 bucket
import boto3
bucket, prefix = 'my_bucket', 'datasets/dogs_vs_cats'
paginator = boto3.client('s3').get_paginator('list_objects')
with open('manifest.jsonl', 'w') as f:
for page in paginator.paginate(Bucket=bucket, Prefix=prefix):
for obj in page['Contents']:
lbl = 0 if 'dog.' in obj['Key'] else 1
f.write('{{"source-ref":"s3://{}/{}", "class":"{}"}}\n'\
.format(bucket, obj['Key'], lbl))
@mrtj
mrtj / kinetics_actions.sh
Last active July 9, 2021 07:05
Search for a given action in the Kinetics human activity dataset
#!/usr/bin/env bash
cat train.csv | sed 's/ /_/g' | sed 's/,/ /g' | awk '{print $1}' | grep "$1" | sort | uniq