This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<#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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var path = require('path'); | |
var express = require('express'); | |
var app = express(); | |
var openConnections = []; | |
global.emitEvent = function () { | |
console.log("emit to clients " + openConnections.length); | |
openConnections.forEach(function(res) { | |
res.write('data: event' + "\n\n"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// unity pc and mobile input | |
// http://docs.unity3d.com/ScriptReference/Input.GetMouseButtonDown.html | |
// http://docs.unity3d.com/Manual/MobileInput.html | |
void Update() { | |
if (SystemInfo.deviceType == DeviceType.Desktop) { | |
if (Input.GetMouseButtonDown(0)) {// 0 - left click, 1 - right click, 2 - middle click | |
// click | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# open terminal here service | |
# works in OSX El Capitan | |
# to install create new Automator Service with Run Shell script below | |
# original script http://protips.maxmasnick.com/cdff-cd-to-the-path-of-the-front-most-finder-window | |
function ff { osascript -e 'tell application "Finder"'\ | |
-e "if (${1-1} <= (count Finder windows)) then"\ | |
-e "get POSIX path of (target of window ${1-1} as alias)"\ | |
-e 'else' -e 'get POSIX path of (desktop as alias)'\ | |
-e 'end if' -e 'end tell'; };\ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSString *rand_str() { | |
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; |