Skip to content

Instantly share code, notes, and snippets.

View antoniocasero's full-sized avatar
🎯
Focusing

Antonio Casero antoniocasero

🎯
Focusing
View GitHub Profile
@antoniocasero
antoniocasero / The Technical Interview Cheat Sheet.md
Created August 7, 2018 14:41 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
public func reloadData(_ completion: @escaping () -> Void) {
UIView.animate(withDuration: 0, animations: {
self.reloadData()
}, completion: { _ in
completion()
})
}
@antoniocasero
antoniocasero / Reusable.swift
Created May 5, 2017 14:02
Protocol to reuse and simplify UITableViewCell
import Foundation
import UIKit
protocol Reusable {}
extension Reusable where Self: UITableViewCell {
static var reuseIdentifier: String {
return String(describing: self)
}
}
@antoniocasero
antoniocasero / Start.swift
Last active April 28, 2017 14:56
Async Chainable
// Created by Palmero, Antonio on 04/01/2017.
// Copyright © 2017 ACP. All rights reserved.
//
import Foundation
public typealias ResultOp = Start
public typealias OperationClosure = ((ResultOp) -> Void)
public typealias ErrorClosure = ((Error) -> Void)
public class Start {
typedef NS_ENUM(NSInteger, kErrorCode) {
kErrorCodeInternal = 431432,
};
extern NSError *NSErrorMake(NSString *message, NSInteger code, NSDictionary *aUserInfo, NSString *methodOrFunction);
#define NSObjcAssert NSAssert
#define InvalidConditionString(condition) (@"Invalid condition not satisfying: " #condition)
#define GenericAssertCondition(ctype, condition) NS ## ctype ## Assert((condition), InvalidConditionString((condition)))
#define GenericErrorMake(condition, func) NSErrorMake(InvalidConditionString((condition)), kErrorCodeInternal, nil, func)
Contributor Code of Conduct
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the p
- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewRowAction *moreAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"More" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
// maybe show an action sheet with more options
[self.tableView setEditing:NO];
}];
moreAction.backgroundColor = [UIColor lightGrayColor];
UITableViewRowAction *blurAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"Blur" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
[self.tableView setEditing:NO];
}];
#!/bin/bash
all_assets=`find $1 -type f | uniq | grep -v @2x`
for asset in $all_assets; do
name=`basename $asset | cut -d . -f 1`
count=`git grep $name | grep -v project.pbxproj: | wc -l`
echo -e "$count\t$asset"
done
typedef NS_ENUM(NSInteger, kErrorCode) {
kErrorCodeInternal = 431432,
};
extern NSError *NSErrorMake(NSString *message, NSInteger code, NSDictionary *aUserInfo, NSString *methodOrFunction);
#define NSObjcAssert NSAssert
#define InvalidConditionString(condition) (@"Invalid condition not satisfying: " #condition)
#define GenericAssertCondition(ctype, condition) NS ## ctype ## Assert((condition), InvalidConditionString((condition)))
#define GenericErrorMake(condition, func) NSErrorMake(InvalidConditionString((condition)), kErrorCodeInternal, nil, func)
@antoniocasero
antoniocasero / WeakSingleton
Created July 14, 2013 09:57
Weak Singleton
+ (id)sharedInstance
{
static __weak ASingletonClass *instance;
ASingletonClass *strongInstance = instance;
@synchronized(self) {
if (strongInstance == nil) {
strongInstance = [[[self class] alloc] init];
instance = strongInstance;
}
}