Skip to content

Instantly share code, notes, and snippets.

View rbsgn's full-sized avatar

Roman Busygin rbsgn

  • Dodo Engineering
  • Moscow
  • X @rbsgn
View GitHub Profile
@rentzsch
rentzsch / gist:1216022
Created September 14, 2011 07:14
NSString* JRNSStringFromCATransform3D(CATransform3D transform)
static NSString* prettyFloat(CGFloat f) {
if (f == 0) {
return @"0";
} else if (f == 1) {
return @"1";
} else {
return [NSString stringWithFormat:@"%.3f", f];
}
}
@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)
@ericallam
ericallam / CLLocationManager+MockingLocation.h
Created June 1, 2013 03:57
Mocking out CLLocationManager
#import <CoreLocation/CoreLocation.h>
extern CLLocationDegrees kMockedLatitude;
extern CLLocationDegrees kMockedLongitude;
@interface CLLocationManager (MockingLocation)
+ (BOOL)custom_locationServicesEnabled;
+ (CLAuthorizationStatus)custom_authorizationStatus;
-(void)custom_startUpdatingLocation;
@delebedev
delebedev / gist:7266332
Created November 1, 2013 14:36
NSURLCache trick to control cache on client side
typedef NSCachedURLResponse * (^WGNCachedResponseBlock)(NSURLConnection *connection, NSCachedURLResponse *cachedResponse);
- (WGNCachedResponseBlock)cacheResponseBlockWithTime:(NSTimeInterval)time {
return ^NSCachedURLResponse *(NSURLConnection *connection, NSCachedURLResponse *cachedResponse) {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*)[cachedResponse response];
NSDictionary *headers = [httpResponse allHeaderFields];
NSString *cacheControl = [headers valueForKey:@"Cache-Control"];
NSString *expires = [headers valueForKey:@"Expires"];
if((cacheControl == nil) && (expires == nil)) {
@delebedev
delebedev / OHHTTPStubs+ShortBlocks.h
Created November 1, 2013 16:01
OHTTPStubs+ShortBlocks
void (^stubResponseWithHeaders)(NSString *, NSString *, NSDictionary *);
void (^stubResponse)(NSString *, NSString *);
void (^stubResponseWithStatusCode)(NSString *, int);
@chrismiles
chrismiles / reveal.py
Last active September 2, 2021 00:26
Lazy script to wrap Reveal lib load/start commands in one LLDB command.
""" File: reveal.py
Add to ~/.lldbinit:
command script import ~/.lldb-scripts/reveal.py
Q: Want to automatically load the Reveal lib on launch while debugging from Xcode?
A: In Xcode:
Add a Symbolic Breakpoint
Symbol: "UIApplicationMain"
Action: Debugger Command with value "reveal"
Note that like all analogies, this is not a perfect one. I find it helps me think about it though. Also, don't try to draw conclusions about performance from this analogy :)
-[NSUserDefaults setObject:forKey:] is like...
<edit file to add key and value>
git add file
git commit
dispatch_after(some time, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[[NSUserDefaults standardUserDefaults] synchronize]
});
@orta
orta / network-models.md
Last active August 29, 2015 13:56
Network models

Using a real artsy example from today.

Creating a follow button on a view controller for different types of objects Artist, Profile, Gene

Needs: networking Needs: layout Needs: interface changes based on networking

Networking

@matthiasplappert
matthiasplappert / gist:9493050
Last active August 29, 2015 13:57
QuickLook Debugging for `UIView`
@interface UIView (MPAdditions)
@end
@implementation UIView (MPAdditions)
- (id)debugQuickLookObject {
if (self.bounds.size.width < 0.0f || self.bounds.size.height < 0.0f) {
return nil;
}
@dhh
dhh / test_induced_design_damage.rb
Last active June 22, 2023 06:18
This is an extraction from Jim Weirich's "Decoupling from Rails" talk, which explained how to apply the hexagonal design pattern to make every layer of your application easily unit testable (without touching the database etc). It only seeks to extract a single method, the EmployeesController#create method, to illustrate the design damage that's …
# Original Rails controller and action
class EmployeesController < ApplicationController
def create
@employee = Employee.new(employee_params)
if @employee.save
redirect_to @employee, notice: "Employee #{@employee.name} created"
else
render :new
end