Skip to content

Instantly share code, notes, and snippets.

View andr-ggn's full-sized avatar

Andrey Gagan andr-ggn

View GitHub Profile
@jacobbubu
jacobbubu / ioslocaleidentifiers.csv
Created February 15, 2012 14:41
iOS Locale Identifiers
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
mr Marathi
bs Bosnian
ee_TG Ewe (Togo)
ms Malay
kam_KE Kamba (Kenya)
mt Maltese
ha Hausa
es_HN Spanish (Honduras)
ml_IN Malayalam (India)
ro_MD Romanian (Moldova)
@dchohfi
dchohfi / tableView:viewForHeaderInSection:
Created April 9, 2012 19:49
tableView:viewForHeaderInSection: like the default header view
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
float width = tableView.bounds.size.width;
int fontSize = 18;
int padding = 10;
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, width, fontSize)];
view.backgroundColor = [UIColor colorWithWhite:0 alpha:0];
view.userInteractionEnabled = YES;
view.tag = section;
@ridiculousfish
ridiculousfish / SafeSet.m
Created June 26, 2012 09:22
A thread safe set written in Objective-C
#import <Foundation/Foundation.h>
@interface SafeSet : NSObject {
NSMutableSet *set;
dispatch_queue_t queue;
}
@end
@implementation SafeSet
@tsafrir
tsafrir / gist:5627179
Last active May 19, 2016 15:47
Use SDWebImage to download an image the display in UITableViewCell with fade in and the image cache build in SDWebImage. https://github.com/rs/SDWebImage
#import "UIImageView+WebCache.h"
// load the image in:
// - (void)configureCell:(MyCell*)cell atIndexPath:(NSIndexPath*)indexPath
// or in - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
NSString *imageURLString = item.imageURL;
if (imageURLString) {
NSURL *url = [NSURL URLWithString:imageURLString];
if (url) {
@nscoding
nscoding / NSCSearchBar.h
Last active July 6, 2018 04:07
On iOS 7 UISearchBar the placeholder text is centred and I want to disable that and make it always stick to the left like it was before. There is a private method setCenterPlaceholder and calling this with a BOOL work will make the trick. I am wondering if there is any other, not "Hacked" that does the same thing.
@interface NSCodingSearchBar : UISearchBar
// Default by the system is YES.
// https://github.com/nst/iOS-Runtime-Headers/blob/master/Frameworks/UIKit.framework/UISearchBar.h
@property (nonatomic, assign, setter = setHasCentredPlaceholder:) BOOL hasCentredPlaceholder;
@end
@emarashliev
emarashliev / UIViewController.m
Created February 25, 2014 16:29
Custom animation for modal dismiss
- (void)dismiss
{
[CATransaction begin];
CATransition *transition = [CATransition animation];
transition.type = kCATransitionReveal;
transition.subtype = kCATransitionFromTop;
transition.duration = 0.25f;
transition.fillMode = kCAFillModeForwards;
transition.removedOnCompletion = YES;
@tomasbasham
tomasbasham / UIImage+Scale.m
Last active February 1, 2024 19:04
Scale a UIImage to any given rect keeping the aspect ratio
@implementation UIImage (scale)
/**
* Scales an image to fit within a bounds with a size governed by
* the passed size. Also keeps the aspect ratio.
*
* Switch MIN to MAX for aspect fill instead of fit.
*
* @param newSize the size of the bounds the image must fit within.
* @return a new scaled image.
@andelf
andelf / Optional-ext.swift
Last active November 21, 2018 19:55
Swift Optional Extension
protocol Index {
typealias IndexType
typealias Result
subscript (i: IndexType) -> Result { get }
}
protocol IndexMut: Index {
typealias IndexType
typealias Result
int invoke_fun(int (*f)(void));
//
// AppDelegate.swift
// TypedTableViewControllers
//
// Created by Chris Eidhof on 23/03/15.
// Copyright (c) 2015 Unsigned Integer. All rights reserved.
//
import UIKit