Skip to content

Instantly share code, notes, and snippets.

@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[] )
sudo lsof -i -P | grep -i "listen"
@emarashliev
emarashliev / main.c
Created January 22, 2014 16:59
POSIX Thread Example
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#define NUM_THREADS 5
void *TaskCode(void *argument)
{
int tid;