Skip to content

Instantly share code, notes, and snippets.

@emarashliev
emarashliev / gist:1cd7336f2f6f54a0775c
Last active August 29, 2015 14:14
Change commit messages of past Git commits
git rebase -i [COMMIT BEFORE THE FIRST YOU WANT TO EDIT]
# Mark all messages to be changed with "edit".
# Git will start the rebasing and stop at every marked commit.
git commit -amend -m "new message"
git rebase -continue
class Array2D<T> {
let columns: Int
let rows: Int
var array: Array<T?>
init(columns: Int, rows: Int) {
self.columns = columns
self.rows = rows
array = Array<T?>(count: rows * columns, repeatedValue: nil)
}
@emarashliev
emarashliev / cherry-pick
Last active August 29, 2015 14:04
cherry-pick
git checkout release
git pull --rebase origin release
git branch {branch}
git checkout {branch}
git cherry-pick 1283094rtwedfsgg
git push origin {branch}
@implementation UIViewController (Swizzled)
+ (void)load
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
[self swizzlingInstanceMethod:@selector(viewDidLoad) swizzledSelector:@selector(swizzled_viewDidLoad)];
});
}
@emarashliev
emarashliev / ViewController.m
Created April 15, 2014 08:33
Centered UIView by AutoLayout
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
UIView *view = [[UIView alloc] init];
view.backgroundColor = [UIColor whiteColor];
[self.view addSubview:view];
@emarashliev
emarashliev / remove_recursively.sh
Created April 13, 2014 19:18
Recursively remove files
find . -name ".DS_Store" -print0 | xargs -0 rm -rf
#import <sys/utsname.h>
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSLog(@"%@", [self machineName]);
}
@emarashliev
emarashliev / UIViewController.m
Created February 25, 2014 16:29
Custom animation for modal dismiss
- (void)dismiss
{
[CATransaction begin];
CATransition *transition = [CATransition animation];
transition.type = kCATransitionReveal;
transition.subtype = kCATransitionFromTop;
transition.duration = 0.25f;
transition.fillMode = kCAFillModeForwards;
transition.removedOnCompletion = YES;
@emarashliev
emarashliev / convert_string.c
Created February 5, 2014 15:52
From CFStringRef to C string
CFStringRef eventStr = CFSTR("Hello, I'm an event.");
CFIndex length = CFStringGetLength(eventStr);
CFIndex maxSize = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8);
char *event = (char *)malloc(maxSize);
CFStringGetCString(eventStr, event, maxSize,kCFStringEncodingUTF8);
printf("Event %s\n", event);
@emarashliev
emarashliev / main.m
Last active March 19, 2024 12:51
FileSystem Observing
#import <Foundation/Foundation.h>
#include <CoreServices/CoreServices.h>
void callbackFunction( ConstFSEventStreamRef streamRef,
void *clientCallBackInfo,
size_t numEvents,
void *eventPaths,
const FSEventStreamEventFlags eventFlags[],
const FSEventStreamEventId eventIds[] )