This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // NOTE: This delegate method requires you to disable UICollectionView's `pagingEnabled` property. | |
| - (void)scrollViewWillEndDragging:(UIScrollView *)scrollView | |
| withVelocity:(CGPoint)velocity | |
| targetContentOffset:(inout CGPoint *)targetContentOffset { | |
| CGPoint point = *targetContentOffset; | |
| UICollectionViewFlowLayout *layout = (UICollectionViewFlowLayout *)self.collectionView.collectionViewLayout; | |
| // This assumes that the values of `layout.sectionInset.left` and |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Steps to safely remove a git submodule: | |
| 1. Delete the relevant section from the .gitmodules file | |
| 2. Stage the .gitmodules changes git add .gitmodules | |
| 3. Delete the relevant section from .git/config | |
| 4. Run git rm --cached path_to_submodule | |
| 5. Run rm -rf .git/modules/path_to_submodule | |
| 6. Commit git commit -m "Removed submodule <name>" | |
| 7. Delete the now untracked submodule files rm -rf path_to_submodule |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Xcode | |
| build/* | |
| *.pbxuser | |
| !default.pbxuser | |
| *.mode1v3 | |
| !default.mode1v3 | |
| *.mode2v3 | |
| !default.mode2v3 | |
| *.perspectivev3 | |
| !default.perspectivev3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| + (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++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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]; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }' - | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - (void)test_Given<#state#>_When<#action#>_Then<#result#> { | |
| XCTAssert(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @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); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| File.open("your_file.md", 'r') do |f| | |
| f.each_line do |line| | |
| forbidden_words = ['Table of contents', 'define', 'pragma'] | |
| next if !line.start_with?("#") || forbidden_words.any? { |w| line =~ /#{w}/ } | |
| title = line.gsub("#", "").strip | |
| href = title.gsub(" ", "-").downcase | |
| puts " " * (line.count("#")-1) + "* [#{title}](\##{href})" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |