Skip to content

Instantly share code, notes, and snippets.

//
// KeychainBehaviourTests.m
//
// Created by Roman Baulin on 25/04/2017.
// Copyright © 2017. All rights reserved.
//
//
// see SecBase.h and osstatus.com and to investigate keychain error codes
//
@implementation NSArray (FDMapping)
// import, array diff
// https://github.com/glebd/google-toolbox-for-mac/blob/master/Foundation/GTMNSArray%2BMerge.m
// https://github.com/Wondermall/Doppelganger
// https://github.com/Basket/BKDeltaCalculator/blob/master/BKDeltaCalculator/BKDeltaCalculator.m
+ (void)ag_mapSourceArray:(NSArray *)source toDestArray:(NSArray *)dest sourceKey:(id (^)(id obj))sourceKeyBlock destKey:(id (^)(id obj))destKeyBlock compare:(NSComparisonResult (^)(id, id))compareBlock match:(void (^)(id, id))matchBlock {
NSArray *sortedSource = [source sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
- (instancetype)init
{
self = [super initWithStyle:UITableViewStyleGrouped];
if (self) {
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
#!/bin/sh
palette="/tmp/palette.png"
filters="fps=$4,scale=$3:-1:flags=lanczos"
ffmpeg -v warning -i $1 -vf "$filters,palettegen" -y $palette
ffmpeg -v warning -i $1 -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y $2
@rbaulin
rbaulin / rand-nsstring.m
Last active June 6, 2016 17:54
random NSString in objective-c
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;
# 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'; };\
// 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
}
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");
- (UIImage *)render:(CGRect)frame {
if (CGRectIsEmpty(frame) || CGRectIsInfinite(frame) || CGRectIsNull(frame)) {
return nil;
}
UIGraphicsBeginImageContextWithOptions(frame.size, NO, 0); // same as [[UIScreen mainScreen] scale]
// drawing code
// Create new image