Skip to content

Instantly share code, notes, and snippets.

View skyylex's full-sized avatar

Yury Lapitsky skyylex

View GitHub Profile
@skyylex
skyylex / main.cpp
Created March 2, 2017 21:51
StripedMap hash verification gist
#include <iostream>
static int size = 64;
int stripedMapPseudoHash(uintptr_t addr) {
return ((addr >> 4) ^ (addr >> 9)) % size;
}
int main(int argc, const char * argv[]) {
int numericMap[size];
@skyylex
skyylex / NSURL-Extensions.h
Created December 26, 2016 18:59
iOS 6+ compatible functions set to update URL parameters
//
// NSURL-Extensions.h
// url-modificator
//
// Created by yury.lapitsky on 26/12/2016.
// Copyright © 2016 yury.lapitsky. All rights reserved.
//
#import <Foundation/Foundation.h>
@skyylex
skyylex / osx env setup
Last active November 16, 2016 13:49
Setup Developer tools for iOS Developer in the terminal
# Sublime links setup
sudo rm -rf /usr/local/bin/subl
sudo ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/
subl .
# Homebrew packages
# bash-completion, carthage, swiftlint, rbenv
@skyylex
skyylex / git_daily_use_shortcuts.txt
Last active July 21, 2016 14:53
git daily-use shortcuts
// Last commit diff
git log -p -1
@skyylex
skyylex / pack_epub.sh
Created March 14, 2016 14:54
Bash script that generates .epub file from sources. (first argument = filename)
#!/bin/bash
rm -f "$1"
zip -X0 "$1" mimetype
zip -X9Dr "$1" META-INF OEBPS
@skyylex
skyylex / UIViewController+RAC.m
Last active October 11, 2015 09:43
ReactiveCocoa-way to present UIViewControllers
@implementation UIViewController (RAC)
- (RACCommand *)showCommandWithPresenter:(RACSignal *)presenter {
RACSignal *presentedControllerDataSignal = [RACSignal return:self];
return [[RACCommand alloc] initWithSignalBlock:^RACSignal *(id input) {
RACSignal *presentDataSignal = [presenter combineLatestWith:presentedControllerDataSignal];
return [presentDataSignal.deliverOnMainThread flattenMap:^RACStream *(RACTuple *tuple) {
return [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
UIViewController *presenterController = tuple.first;
UIViewController *controllerToPresent = tuple.second;
@skyylex
skyylex / RACSignal+DistinctBasedOnRule.m
Last active October 9, 2015 18:11
More common way to distinguish values in the RACSignal stream (ReactiveCocoa 2)
typedef BOOL(^PassRuleBlock)(id first, id second);
- (RACSignal *)distinctBasedOnRule:(PassRuleBlock)passRuleBlock {
Class class = self.class;
return [[self bind:^{
__block id lastValue = nil;
return ^(id x, BOOL *stop) {
if ((passRuleBlock(x, lastValue) == NO)) { return [class empty]; }