Skip to content

Instantly share code, notes, and snippets.

View romainbriche's full-sized avatar

Romain Briche romainbriche

  • San Francisco, California
View GitHub Profile
@rustle
rustle / gist:5027734
Created February 25, 2013 04:23
An accessible UISlider subclass that closely emulates the time scrubber in Music.app
//
// KATGShowControlsScrubber.m
// KATG
//
// Created by Doug Russell on 2/24/13.
// Copyright (c) 2013 Doug Russell. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
@0xced
0xced / README.md
Last active November 1, 2018 14:56
How to class-dump an iOS static framework

Using HockeySDK as an example

  1. Download HockeySDK 3.0.0
  2. Run these commands:
ARCH=armv7
FRAMEWORK_DIRECTORY="${HOME}/Downloads/HockeySDK-iOS-3/HockeySDK.embeddedframework"
FRAMEWORK_NAME=$(basename `echo "${FRAMEWORK_DIRECTORY}"/*.framework` .framework)
@ole
ole / update_storyboard_strings.sh
Last active April 4, 2022 06:11
Automatically extract translatable strings from Xcode storyboards and update .strings files. Original version by MacRumors forum user mikezang (http://forums.macrumors.com/showpost.php?p=16060008&postcount=4). Slightly updated by Ole Begemann. NOTE: this Gist moved to a regular repo at https://github.com/ole/Storyboard-Strings-Extraction.
# (File moved to https://github.com/ole/Storyboard-Strings-Extraction)
@luca-bernardi
luca-bernardi / TheEleganceOfBlock.mm
Created February 18, 2013 10:42
How to use inline block to better organize a block of code
__weak typeof(self) weakSelf = self;
self.collectionView = (UICollectionView *)^{
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
UICollectionView *collectionView = [[UICollectionView alloc] initWithFrame:weakSelf.view.bounds
collectionViewLayout:flowLayout];
collectionView.delegate = weakSelf;
collectionView.dataSource = weakSelf;
return collectionView;
@lilyball
lilyball / gist:4968834
Created February 16, 2013 21:33
RXLazyEnumeration adjustment
typedef struct RXLazyEnumerationState {
unsigned long state;
__unsafe_unretained id *itemsPtr;
unsigned long *mutationsPtr;
__unsafe_unretained id *arrayItemsPtr;
unsigned long arrayItemsCount;
NSFastEnumerationState *arrayState;
unsigned long extra[2];
} RXLazyEnumerationState;
@alloy
alloy / gist:4952606
Last active August 19, 2020 03:48
Upload iOS application for clients on their iTunes Connect account.

Obviously, the simplest solution would be for the client to share their account details or add us as ‘team admin’, but that is not what this is about.

  1. [Add us to your iOS Developer Program as ‘team member’.][1]
  2. [Create a ‘Distribution Certificate’, if you haven’t got one already.][2]
  3. [Create a ‘App Store Distribution Provisioning Profile’.][3]
  4. [Export the ‘Distribution Certificate’ assets and send the export and password to us.][4] (For security sake, it’s a good idea to send us the password via other means than the exported certificate. E.g. by phone/SMS.)
@ole
ole / FunctionalBankAccount.m
Created February 11, 2013 15:20
FunctionalBankAccount: a simple implementation of a blocks-based object model in (Objective-)C, inspired by a similar Scheme implementation in "Structure and Interpretation of Computer Programs". See http://oleb.net/blog/2013/02/building-blocks-based-object-system-in-objective-c/ for an explanation.
#import <Foundation/Foundation.h>
typedef id(^BankAccount)(char *cmd);
typedef id(^CurrentBalanceMethod)(void);
typedef id(^DepositMethod)(double);
typedef id(^WithdrawMethod)(double);
BankAccount CreateBankAccount(double initialBalance)
{
// Initialization
@akshay1188
akshay1188 / whatsapp-image-compression
Last active June 10, 2023 16:42
Whatsapp like image compression
- (UIImage *)compressImage:(UIImage *)image{
float actualHeight = image.size.height;
float actualWidth = image.size.width;
float maxHeight = 600.0;
float maxWidth = 800.0;
float imgRatio = actualWidth/actualHeight;
float maxRatio = maxWidth/maxHeight;
float compressionQuality = 0.5;//50 percent compression
if (actualHeight > maxHeight || actualWidth > maxWidth) {
@simonwhitaker
simonwhitaker / GSDismissableViewControllerDelegate.h
Last active December 12, 2015 08:38
A simple protocol for view controllers that want to communicate that they should be dismissed without knowing about how they were presented.
// GSDismissableViewControllerDelegate.h
//
// Created by Simon Whitaker at Goo Software Ltd.
// https://gist.github.com/simonwhitaker/4745057
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@protocol GSDismissableViewControllerDelegate <NSObject>
@nicklockwood
nicklockwood / Async JSON request
Created February 9, 2013 08:58
Async networking on iOS
NSURLrequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://example.com/file.json"]];
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
id jsonObject = [NSJSONSerialization JSONObjectWithData:data options:0 error:NULL];
}];