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
@chriseidhof
chriseidhof / LICENSE
Last active July 16, 2019 13:14
A tiny networking library
Copyright 2015 Chris Eidhof
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 permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHE
@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
@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;
}
@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

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]
});
@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"
@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);
@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)) {
@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;
@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)