Skip to content

Instantly share code, notes, and snippets.

View gavrix's full-sized avatar
:shipit:
Shipping

Sergey Gavrilyuk gavrix

:shipit:
Shipping
  • Shopify
  • Toronto, ON
View GitHub Profile
@xslim
xslim / gist:1779062
Created February 9, 2012 10:15
Print all methods from class
#include <objc/runtime.h>
#include <objc/message.h>
+ (void)printClassMethods:(Class)class {
NSLog(@"Methods in %@", NSStringFromClass(class));
unsigned int out_count = 0;
Method *class_methods = class_copyMethodList(class, &out_count);
for (int i = 0; i < out_count; i++) {
Method m = class_methods[i];
NSLog(@"\t%@", NSStringFromSelector(method_getDescription(m)->name));
@xslim
xslim / round_corners.sh
Created June 14, 2012 15:53
Make 3px rounded corners on PNG images
#!/bin/bash
# Usage: find . -name "epg_cell_bg_*" -exec ./round_corners.sh '{}' \;
convert $1 \( +clone -alpha extract -draw 'fill black polygon 0,0 0,3 3,0 fill white circle 3,3, 3,0' \( +clone -flip \) \
-compose Multiply -composite \( +clone -flop \) -compose Multiply -composite \) -alpha off \
-compose CopyOpacity -composite $1
@nfarina
nfarina / UIView+FrameAdditions.h
Created August 21, 2012 06:40
UIView Frame helper getter/setter category methods
#import <UIKit/UIKit.h>
@interface UIView (SMFrameAdditions)
@property (nonatomic, assign) CGPoint $origin;
@property (nonatomic, assign) CGSize $size;
@property (nonatomic, assign) CGFloat $x, $y, $width, $height; // normal rect properties
@property (nonatomic, assign) CGFloat $left, $top, $right, $bottom; // these will stretch the rect
@end
@krzysztofzablocki
krzysztofzablocki / gist:4091783
Created November 16, 2012 23:13
Free memory on iOS
-(float) get_free_memory {
mach_port_t host_port;
mach_msg_type_number_t host_size;
vm_size_t pagesize;
host_port = mach_host_self();
host_size = sizeof(vm_statistics_data_t) / sizeof(integer_t);
host_page_size(host_port, &pagesize);
vm_statistics_data_t vm_stat;
if (host_statistics(host_port, HOST_VM_INFO, (host_info_t)&vm_stat, &host_size) != KERN_SUCCESS) {
@mpospese
mpospese / CGRectIntegralScaled.m
Created February 28, 2013 03:34
Pixel aligns rectangles, taking the device's screen scale into account.
CGRect CGRectIntegralScaledEx(CGRect rect, CGFloat scale)
{
return CGRectMake(floorf(rect.origin.x * scale) / scale, floorf(rect.origin.y * scale) / scale, ceilf(rect.size.width * scale) / scale, ceilf(rect.size.height * scale) / scale);
}
CGRect CGRectIntegralScaled(CGRect rect)
{
return CGRectIntegralScaledEx(rect, [[UIScreen mainScreen] scale]);
}
@rsobik
rsobik / boost.sh
Created November 17, 2013 13:20
Build Boost 1.55.0 for iOS 7 and OS X including 64 Bit
#===============================================================================
# Filename: boost.sh
# Author: Pete Goodliffe
# Copyright: (c) Copyright 2009 Pete Goodliffe
# Licence: Please feel free to use this, with attribution
# Modified version
#===============================================================================
#
# Builds a Boost framework for the iPhone.
# Creates a set of universal libraries that can be used on an iPhone and in the
@steipete
steipete / DevelopmentEnviromentDetector.m
Last active October 30, 2019 03:49
Detect if you're currently running a development version or an App Store/Ad Hoc version.
static BOOL PSPDFIsDevelopmentBuild(void) {
#if TARGET_IPHONE_SIMULATOR
return YES;
#else
static BOOL isDevelopment = NO;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
// There is no provisioning profile in AppStore Apps.
NSData *data = [NSData dataWithContentsOfFile:[NSBundle.mainBundle pathForResource:@"embedded" ofType:@"mobileprovision"]];
if (data) {