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
+ (instancetype)viewFromXIB
{
UINib *nib = [UINib nibWithNibName:NSStringFromClass([self class]) bundle:[NSBundle bundleForClass:[self class]]];
NSArray *objects = [nib instantiateWithOwner:nil options:nil];
for (id obj in objects) {
if ([obj isKindOfClass:[self class]]) {
return obj;
}
}
NSAssert(NO, @"Can't load view from XIB");
@rbsgn
rbsgn / gist:5089314
Last active December 14, 2015 12:49
Shell script to open Xcode workspace or project from terminal.
#!/bin/bash
find_project_or_workspace() {
MASK=$1
ALL_PROJECTS_OR_WORKSPACES=`/bin/ls -1 -d $MASK 2>/dev/null`
FILE_TO_OPEN=''
if [ z"${ALL_PROJECTS_OR_WORKSPACES}" != z ] ; then
for i in ${ALL_PROJECTS_OR_WORKSPACES} ; do
if [ z"${PROJECT}" == z ] ; then
# language: ru
Функционал: Сборка iOS приложения
Чтобы не запоминать сложный набор параметров для xcodebuild
Разработчики
Хотят собирать iOS приложения одной простой командой
Сценарий: Сборка Xcode проекта
Допустим я нахожусь в папке с Xcode проектом
И настройками BuildKit для него
Когда я запускаю сборку проекта BuildKit
class AppDelegate
def application(application, didFinishLaunchingWithOptions:launchOptions)
alert = UIAlertView.alloc.initWithTitle:'title', message:'message', delegate:nil, cancelButtonTitle:'Dismiss', otherButtonTitles:'Okay', nil
alert.show
true
end
end
#!/usr/bin/perl
#
# PackageApplication
#
# Copyright (c) 2009-2010 Apple Inc. All rights reserved.
#
# Package an iPhone Application into an .ipa wrapper
#
use Pod::Usage;
@rbsgn
rbsgn / kvo-initialize-issue.m
Created January 30, 2012 20:32
Sample code that demonstrates issue with +initialize under KVO
// clang test.m -o test -framework Foundation -f-arc
#import <Foundation/Foundation.h>
@interface Foo : NSObject
@property (nonatomic, copy) NSString * bar;
@end
@implementation Foo
@synthesize bar;
@rbsgn
rbsgn / gist:1485682
Created December 16, 2011 11:14
Find the most largest and the most smallest file in your iOS application
find . -type f \( -iname '*.m' -or -iname '*.h' \) -not -iname 'main.m' -print0 | xargs -0 wc -l | grep -v 'total' | awk 'BEGIN{ min = 4294967295; min_filename = ""; max = 0; max_filename = "" ; } { if ($1 < min) { min = $1; min_filename = $2; } ; if ($1 > max) { max = $1; max_filename = $2 } ; } END { print "min: ", min, "; file: ", min_filename ; print "max: ", max, "; file: ", max_filename ;} '
@rbsgn
rbsgn / iOSDocumentMigrator.m
Created December 7, 2011 05:11 — forked from steipete/iOSDocumentMigrator.m
Helps migrating documents between iOS <= 5.0 and >= 5.0.1 to comply with Apple's iCloud guidelines. Follow @steipete on Twitter for updates.
#include <sys/xattr.h>
/// Set a flag that the files shouldn't be backuped to iCloud.
+ (void)addSkipBackupAttributeToFile:(NSString *)filePath {
u_int8_t b = 1;
setxattr([filePath fileSystemRepresentation], "com.apple.MobileBackup", &b, 1, 0, 0);
}
/// Returns the legacy storage path, used when the com.apple.MobileBackup file attribute is not available.
+ (NSString *)legacyStoragePath {
@rbsgn
rbsgn / reset_user.sh
Created November 27, 2011 11:05
Reset a Mac
#!/bin/bash -x
echo 'Remount the root partition as writable...'
/sbin/mount -uw / && echo 'Done'
echo 'Run Directory Services...'
launchctl load /System/Library/LaunchDaemons/com.apple.DirectoryServices.plist && echo 'Done'
dscl . -delete /Users/$1
dscl . -delete /Groups/admin GroupMembership $1
rm -rf /Users/$1
rm /var/db/.AppleSetupDone
@rbsgn
rbsgn / Makefile
Created October 26, 2011 21:44
A Makefile to build openvpn for Tunnelblick. This is a slightly modernized and refactored version of original file third_party/Makefile
CC ?= gcc
MACOSX_DEPLOYMENT_TARGET ?= 10.6
SDKROOT ?= /Developer/SDKs/MacOSX10.6.sdk
VALID_ARCHS ?= i386 x86_64
CFLAGS=-isysroot $(SDKROOT) -Os -mmacosx-version-min=$(MACOSX_DEPLOYMENT_TARGET)
TOPDIR = $(PWD)
BUILD_DIR = build
BUILD_RESULTS_DIR = $(TOPDIR)/$(BUILD_DIR)