Skip to content

Instantly share code, notes, and snippets.

@rbaulin
rbaulin / dynamic_realm.m
Last active August 29, 2015 14:21
Realm dynamic API usage example
#import <Realm.h>
// extracted from RLMRealm_Dynamic.h
@interface RLMProperty (AGDynamic)
- (instancetype)initWithName:(NSString *)name
type:(RLMPropertyType)type
objectClassName:(NSString *)objectClassName
indexed:(BOOL)indexed;
@end
@rbaulin
rbaulin / AppDelegate.m
Last active August 29, 2015 14:20
AppDelegate without Storyboards snippet
<#ViewController#> *vc = [[<#ViewController#> alloc] init];
UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:vc];
UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
window.rootViewController = nc;
[window makeKeyAndVisible];
self.window = window;
if [ "${CONFIGURATION}" = "Ad Hoc" ] || [ "${CONFIGURATION}" = "App Store" ]; then
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${INFOPLIST_FILE}")
buildNumber=$((buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "${INFOPLIST_FILE}"
./Pods/Fabric/Fabric.framework/run key key
fi
class Date
def quarter
case self.month
when 1,2,3
return 1
when 4,5,6
return 2
when 7,8,9
return 3
when 10,11,12
// related to SO question:
// http://stackoverflow.com/questions/26252432/how-do-i-set-a-auto-increment-key-in-realm/26257616#26257616
// keywords: realm auto increment id primary key autoincrement
//
// two assumptions:
// 1) time always goes forward
// 2) realm and app has shared lifetime:
// no external realms are imported, if app deleted realm is deleted
@interface TSUUID : NSObject
@property (nonatomic) double baseOffset;
- (NSString *)randomString {
NSString *alphabet = @"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXZY0123456789";
u_int32_t len = arc4random_uniform(20) + 5;
NSMutableString *s = [NSMutableString stringWithCapacity:len];
for (NSUInteger i = 0U; i < len; i++) {
u_int32_t r = arc4random() % [alphabet length];
unichar c = [alphabet characterAtIndex:r];
[s appendFormat:@"%C", c];
}
return s;
// crash and exceptions in google analytics are stripped and all wrong
// but action and label can be delivered in full length
//
// send formatted string w/o params in action (as unique error name)
// will show up count in realtime dashboard under category err
//
// send formatted string w/ params in label (as error description)
// can be inspected and queryied in behaviour -> events -> overview -> err
//
// sample: TRACK_ERR(@"audiosession error %@", error)
#
# (c) Baulin Roman 2015
#
# http://stackoverflow.com/questions/1247125/how-to-get-sinatra-to-auto-reload-the-file-after-each-change
# https://github.com/rtomayko/shotgun
# sse http://www.w3schools.com/html/html5_serversentevents.asp
# sse with sinatra http://stackoverflow.com/questions/5227431/html5-server-sent-events-with-ruby-sinatra
# cool demo https://gist.github.com/rkh/1476463
#

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@rbaulin
rbaulin / UIImage+ImageEffects.h
Last active January 9, 2017 09:38
UIImage+ImageEffects.m presented on WWDC 2013
/*
File: UIImage+ImageEffects.h
Abstract: This is a category of UIImage that adds methods to apply blur and tint effects to an image. This is the code you’ll want to look out to find out how to use vImage to efficiently calculate a blur.
Version: 1.0
Copyright (C) 2013 Apple Inc. All Rights Reserved.
*/
@import UIKit;