Skip to content

Instantly share code, notes, and snippets.

View albertodebortoli's full-sized avatar
👶

Alberto De Bortoli albertodebortoli

👶
View GitHub Profile
@albertodebortoli
albertodebortoli / MoreWarnings.xcconfig
Created February 10, 2014 23:58
MoreWarnings.xcconfig
//
// MoreWarnings.xcconfig
//
// Created by Steven Fisher:
// http://tewha.net/2010/11/xcode-warnings/
// See also:
// http://boredzo.org/blog/archives/2009-11-07/warnings
//
GCC_WARN_CHECK_SWITCH_STATEMENTS = YES
@albertodebortoli
albertodebortoli / linux-snippets.md
Last active August 29, 2015 13:56
Linux Snippets

Linux - Snippets

by Marco Cattai

Searching

Search all the files/folder with that name and remove them

find . -name "FILE-TO-FIND"-exec rm -rf {} \;

@albertodebortoli
albertodebortoli / blurFacebookProfileimage.m
Last active August 29, 2015 13:56
Blur the Facebook Profile image retrieved with the Facebook SDK
self.profilePictureView.profileID = user.id;
double delayInSeconds = 2.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
UIImageView *imageView = nil;
for (UIView *subview in [self.profilePictureView subviews]) {
if ([subview isKindOfClass:[UIImageView class]]) {
imageView = (UIImageView *)subview;
@albertodebortoli
albertodebortoli / concurrency-trivia.m
Last active August 29, 2015 13:57
Objective-C Concurrency/Threading/GCD Trivia
@synchronized(self) {
NSLog(@"%i", 1);
dispatch_queue_t queue = dispatch_queue_create("com.albertodebortoli.serial_queue", DISPATCH_QUEUE_SERIAL);
dispatch_sync(queue, ^{
NSLog(@"%i", 2);
@synchronized(self) {
NSLog(@"%i", 3);
}
NSLog(@"%i", 4);
});
@albertodebortoli
albertodebortoli / unit_test_snippet
Created May 6, 2014 19:27
Xcode Unit Test snippet
- (void)test_Given<#state#>_When<#action#>_Then<#result#> {
XCTAssert();
}
git shortlog -s -n
git log --author="__YOUR_NAME_HERE__" --pretty=tformat: --numstat | awk '{ add += $1 ; subs += $2 ; loc += $1 - $2 } END { printf "added lines: %s removed lines : %s total lines: %s\n",add,subs,loc }' -
@albertodebortoli
albertodebortoli / property_type.m
Created July 30, 2014 11:10
Get the type of a property.
static const char *getPropertyType(objc_property_t property) {
const char *attributes = property_getAttributes(property);
char buffer[1 + strlen(attributes)];
strcpy(buffer, attributes);
char *state = buffer, *attribute;
while ((attribute = strsep(&state, ",")) != NULL) {
if (attribute[0] == 'T' && attribute[1] != '@') {
NSString *name = [[NSString alloc] initWithBytes:attribute + 1 length:strlen(attribute) - 1 encoding:NSASCIIStringEncoding];
return (const char *)[name cStringUsingEncoding:NSASCIIStringEncoding];
}
@albertodebortoli
albertodebortoli / TrackingScrollView
Created July 30, 2014 17:13
Something that will be handly sooner of later.
+ (UIScrollView *)_trackingScrollView:(id)selfObject {
if ([selfObject respondsToSelector:@selector(trackingScrollView)]) {
return objc_msgSend(selfObject, @selector(trackingScrollView));
}
unsigned int proprtiesCount;
objc_property_t *properties = class_copyPropertyList([self class], &proprtiesCount);
for (int i = 0; i < proprtiesCount; i++) {
@albertodebortoli
albertodebortoli / .gitignore
Created August 1, 2014 23:07
.gitignore for Xcode projects in 2014
# Xcode
build/*
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
@albertodebortoli
albertodebortoli / gist:a73154bdc77ae3d6c539
Created May 12, 2015 18:45
Fix Xcode 6.3.1 installing on device code signing problem.
rm -rf ~/Library/Developer/Xcode/DerivedData/JUSTEAT-*/Build/Products/Debug-iphoneos/*.appex/