Skip to content

Instantly share code, notes, and snippets.

@0xced
0xced / Emoji.json
Last active November 22, 2023 15:53
Extract emoji by category using the EmojiFoundation framework
{
"People" : [
"😀",
"😃",
"😄",
"😁",
"😆",
"😅",
"😂",
"🤣",
@jshier
jshier / gist:b4858a4b417217fe8c73
Last active June 21, 2017 12:53
Generic Alamofire response serializer with Argo and a custom error type
static func CloudFlareResponseSerializer<T: Decodable where T == T.DecodedType>() -> GenericResponseSerializer<T> {
return GenericResponseSerializer { (request, response, data) -> Result<T> in
guard let validData = data else {
let failureReason = "Tried to decode response with nil data."
let error = Error.errorWithCode(.DataSerializationFailed, failureReason: failureReason)
return .Failure(data, CloudFlareError.SerializationError(error: error))
}
let JSONSerializer = Request.JSONResponseSerializer(options: .AllowFragments)
let JSONResult = JSONSerializer.serializeResponse(request, response, validData)
@kharmabum
kharmabum / ocmock-cheatsheet.m
Last active July 30, 2024 07:14
OCMock cheatsheet
/*----------------------------------------------------*/
#pragma mark - XCTAsserts
/*----------------------------------------------------*/
XCTAssert(expression, format...);
XCTAssertTrue(expression, format...);
XCTAssertFalse(expression, format...);
XCTAssertEqual(expression1, expression2, format...);
XCTAssertNotEqual(expression1, expression2, format...);
XCTAssertNil(expression, format...);
@davidcunha
davidcunha / data-structures-summary.md
Last active May 13, 2022 04:36
Data Structures Summary

General purposes data structures

Linked Lists

  • small amount of data, not predictable
  • used when data is frequently inserted and deleted
  • searching is slow
  • the insertion order matters when searching

Arrays

  • searching and deletion are slow
@jpsim
jpsim / JAZMusician.h
Created July 7, 2014 09:25
SourceKit Playground
//
// JAZMusician.h
// JazzyApp
//
#import <Foundation/Foundation.h>
/**
JAZMusician models, you guessed it... Jazz Musicians!
From Ellington to Marsalis, this class has you covered.
@prendio2
prendio2 / SUPTableViewController.m
Created March 26, 2014 15:05
Custom viewWillApear to restore selected row when transition is cancelled
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
NSIndexPath *selectedRowIndexPath = [self.tableView indexPathForSelectedRow];
if (selectedRowIndexPath) {
[self.tableView deselectRowAtIndexPath:selectedRowIndexPath animated:YES];
[[self transitionCoordinator] notifyWhenInteractionEndsUsingBlock:^(id<UIViewControllerTransitionCoordinatorContext> context) {
if ([context isCancelled]) {
[self.tableView selectRowAtIndexPath:selectedRowIndexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
@steipete
steipete / Macros.h
Last active January 6, 2024 07:24
Declare on your main init that all other init methods should call. It's a nice additional semantic warning. Works with Xcode 5.1 and above. Not tested with earlier variants, but should just be ignored. A reference to this macro shortly appeared in https://developer.apple.com/library/ios/releasenotes/ObjectiveC/ModernizationObjC/AdoptingModernObj…
#ifndef NS_DESIGNATED_INITIALIZER
#if __has_attribute(objc_designated_initializer)
#define NS_DESIGNATED_INITIALIZER __attribute((objc_designated_initializer))
#else
#define NS_DESIGNATED_INITIALIZER
#endif
#endif
@paul-delange
paul-delange / HighChartViewController.h
Created March 27, 2013 11:03
Highcharts running in a UIWebView for iOS
#import <UIKit/UIKit.h>
@interface HighChartViewController : UIViewController
@property (weak, nonatomic) IBOutlet UIWebView *webView;
@property (strong, nonatomic) NSArray* seriesArray;
@property (copy, nonatomic) NSString* optionFileName;
@end
@kylefox
kylefox / color.m
Created January 27, 2012 17:45
Generate a random color (UIColor) in Objective-C
/*
Distributed under The MIT License:
http://opensource.org/licenses/mit-license.php
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to