Skip to content

Instantly share code, notes, and snippets.

View jcavar's full-sized avatar

Josip Ćavar jcavar

  • Dubrovnik, Croatia
View GitHub Profile
@jcavar
jcavar / AVAudioEngineTSan.swift
Created November 25, 2023 14:35
Simple AVAudioEngine setup that generates TSan violation when adding nodes after engine has started
import SwiftUI
import AudioUnit
import AVFAudio
@main
struct AllocOnOneUseOnAnotherApp: App {
let description = AudioComponentDescription(
componentType: kAudioUnitType_Effect,
componentSubType: 1768125554,
componentManufacturer: 1768125554,
@jcavar
jcavar / wish.c
Created March 25, 2021 10:50
A shell in C and Swift
#include <stdio.h>
#include <readline/readline.h>
#include <unistd.h>
#include <sys/wait.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
char *paths;
@jcavar
jcavar / gist:a30c23b42e98974740accfd49fe42318
Created June 13, 2017 18:30
WebDriverAgent stack trace
*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[1]
(
0 CoreFoundation 0x000000010d09db0b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010cb02141 objc_exception_throw + 48
2 CoreFoundation 0x000000010cfb256d -[__NSPlaceholderArray initWithObjects:count:] + 269
3 CoreFoundation 0x000000010cfb92b4 +[NSArray arrayWithObjects:count:] + 52
4 XCTest 0x000000010c4fe4f7 -[XCElementSnapshot(Hitpoint) _transformPoint:windowContextID:windowDisplayID:] + 133
5 XCTest 0x000000010c4fe8e9 -[XCElementSnapshot(Hitpoint) hitPoint] + 386
6 WebDriverAgentLib 0x000000011e83a00a -[XCElementSnapshot(FBIsVisible) fb_isVisible] + 810
2017-06-10 15:11:51:552 - info: [Xcode] = 13.91s Find: Elements matching predicate '"Accept" IN identifiers'
2017-06-10 15:11:51:552 - info: [Xcode] t = 13.91s Find: Element at index 0
2017-06-10 15:11:51:552 - info: [Xcode] t = 13.91s Use cached accessibility hierarchy for com.bundle.identifier
2017-06-10 15:11:51:552 - info: [Xcode] t = 13.91s Find: Descendants matching type Any
2017-06-10 15:11:51:552 - info: [Xcode] t = 13.91s Find: Elements matching predicate '"Accept" IN identifiers'
2017-06-10 15:11:51:552 - info: [Xcode] t = 13.91s Find: Element at index 0
2017-06-10 15:11:51:552 - info: [Xcode] t = 13.91s Use cached accessibility hierarchy for com.bundle.identifier
2017-06-10 15:11:51:553 - info: [Xcode] t = 13.91s Find: Descendants matching type Any
2017-06-10 15:11:51:553 - info: [Xcode] t = 13.92s Find: Elements matching predicate '"Accept" IN identifiers'
2017-06-10 15:11:51:553 - info: [Xcode]
### Keybase proof
I hereby claim:
* I am jcavar on github.
* I am jcavar (https://keybase.io/jcavar) on keybase.
* I have a public key whose fingerprint is EBC7 C756 9125 1336 27CC 593C 1BBC EBC1 0499 EE18
To claim this, I am signing this object:
@jcavar
jcavar / VerticalText
Created June 28, 2014 08:51
Regex to insert \n after every character in string
NSString *horizontalText = @"horizontal text";
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"(.)" options:NSRegularExpressionCaseInsensitive error:nil];
NSString *verticalText = [regex stringByReplacingMatchesInString:horizontalText options:0 range:NSMakeRange(0, horizontalText.length) withTemplate:@"$1\n"];
@jcavar
jcavar / SideViewController.m
Created May 14, 2014 10:47
Preffered way to implement side controller when using ViewDeck(https://github.com/Inferis/ViewDeck)
@interface SideViewController ()
@property (strong, nonatomic) IBOutlet UITableView *tableViewSide;
@property (strong, nonatomic) NSArray *options;
@end
@implementation SideViewController
#pragma mark - Object lifecycle
@jcavar
jcavar / TimeAgo
Created May 11, 2014 15:16
DateUtils getRelativeTimeSpanString method which cares about time zone
/**
* DateUtils getRelativeTimeSpanString methods which cares about time zone
* @param date date for which you want time ago
* @param timeZone time zone in which is date
* @return time ago string
*/
public static String timeAgoFromDate(Date date, TimeZone timeZone) {
TimeZone defaultTimeZone = TimeZone.getDefault();
TimeZone.setDefault(timeZone);