Skip to content

Instantly share code, notes, and snippets.

@mapedd
mapedd / .gitignore
Created March 15, 2012 16:24
.gitignore file for files generated by Xilinx ISE IDE
#Gitignore for files generated by Xilinx ISE
*.log
*.svf
*.scr
*.cmd
*.bak
*.lso
*.elf
*.ace
@mapedd
mapedd / Xcode4HockeyAppTestFlightintegration.sh
Created November 26, 2012 22:58 — forked from c0diq/Xcode4HockeyAppTestFlightintegration.sh
Automatic TestFlight/HockeyApp Upload XCode Script
#!/bin/bash
#
# (Above line comes out when placing in Xcode scheme)
#
# Inspired by original script by incanus:
# https://gist.github.com/1186990
#
# Rewritten by martijnthe:
# https://gist.github.com/1379127
#
@mapedd
mapedd / gist:5146483
Last active December 14, 2015 20:49
Short program to get all objects with key = Title from Root.plist and save them to Root.strings file for localizing app settings
#import <Foundation/Foundation.h>
BOOL isDictionary(id object);
BOOL isString(id object);
BOOL isArray(id object);
void addObjectForKeyToArray(NSString *key, id collection, NSMutableArray *array);
void addArrayObjectsForKeyToArray(NSString *searchKey, id collection, NSMutableArray *array);
@mapedd
mapedd / gist:d4c04a5d965a0bf1203e
Created January 29, 2015 15:45
Why does this crash?
import Foundation
func eratosthenes(n: Int) -> [Int]{
var results = [Int]()
for i in 0...(n-1){
results.append(i+1)
}
@mapedd
mapedd / gist:25fc76480c8379398991
Created January 29, 2015 16:18
Stop dividing by 0
// Playground - noun: a place where people can play
import Cocoa
func eratosthenes(n: Int) -> [Int]{
var results = Array(1...n)
for i in 1...(n-1){
var number = results[i]
@mapedd
mapedd / gist:57d027653e4a61941e9d
Last active August 29, 2015 14:15
LRUCache with constant access time for reading and writing
//
// LRUCache.m
// ObjCAlg
//
// Created by Tomasz Kuzma on 20/02/2015.
//
#import <Foundation/Foundation.h>
@mapedd
mapedd / gist:bc51b9da4390789fec70
Last active August 29, 2015 14:15
Find missing numbers in array of sorted consecutive natural numbers [n,n+1, n+2, ... n + m] Objective-C
#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>
NSArray *missingNumbers(NSArray *a){
if(a.count < 2){
return [NSArray new];
}
NSMutableArray *array = [NSMutableArray new];
for (NSInteger i = 0; i < a.count - 1; i ++) {
@mapedd
mapedd / ExampleDomain.swift
Created January 31, 2023 16:18 — forked from lukeredpath/ExampleDomain.swift
An enum equivalent of IfLetStore for The Composable Architecture
enum AppState: Equatable {
case featureOne(FeatureState)
case featureTwo(FeatureState)
case featureThree(FeatureState)
}
enum AppAction: Equatable {
case featureOne(FeatureAction)
case featureTwo(FeatureAction)
case featureThree(FeatureAction)
@mapedd
mapedd / libdispatch-efficiency-tips.md
Created July 10, 2024 22:36 — forked from tclementdev/libdispatch-efficiency-tips.md
Making efficient use of the libdispatch (GCD)

libdispatch efficiency tips

The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).

My take-aways are:

  • You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.

  • Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse