Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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: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: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: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 / 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 / .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