Skip to content

Instantly share code, notes, and snippets.

View naithar's full-sized avatar
:octocat:

Sergey Minakov naithar

:octocat:
  • Moscow
View GitHub Profile
@naithar
naithar / navigationBarHack.m
Last active October 7, 2015 14:47
Hack to fix navigation bar frame after closing video view controller in landscape mode for iOS 8, iOS 9
[[NSNotificationCenter defaultCenter] addObserverForName:@"UIWindowDidRotateNotification" object:nil queue:nil usingBlock:^(id _) {
[self.navigationController setNavigationBarHidden:YES animated:NO];
[self.navigationController setNavigationBarHidden:NO animated:NO];
}];
//
// Weak.swift
// DDScanner
//
// Created by Sergey Minakov on 12.05.16.
// Copyright © 2016 Code Monkeys. All rights reserved.
//
import UIKit
public extension SequenceType {
/// Categorises elements of self into a dictionary, with the keys given by keyFunc
func categorise<U : Hashable>(@noescape keyFunc: Generator.Element -> U) -> [U:[Generator.Element]] {
var dict: [U:[Generator.Element]] = [:]
for el in self {
let key = keyFunc(el)
if case nil = dict[key]?.append(el) { dict[key] = [el] }
}
import Foundation
//MARK: GCD Extensions
typealias Queue = dispatch_queue_t
enum QueueType {
case Main
case Low, Normal, High, Background
# coding=utf-8
import sys
import os
from datetime import datetime, date, time
def main(arguments):
if len(arguments) == 0: return
name = arguments[0][:1].upper() + arguments[0][1:]
createDirectory = False
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="[\t] \[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\[\033[31m\]\$(parse_git_branch)\[\033[00m\]$ "
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
alias ls='ls -GFh'
export LC_COLLATE=ru_RU.UTF-8
# OS X
.DS_Store
# Xcode
build/
*.pbxuser
!default.pbxuser
*.mode1v3
@naithar
naithar / darwin_log.txt
Created February 10, 2017 07:37
Foundation Test NSCache
Darwin implementation
=======
I. Default keys for NSCache (current NSCache behavior. If not Darwin -> should match Darwin's)
=======
using NSCache with SwiftNoHash
default NSCache values: '.totalCostLimit' = 0, '.countLimit' = 0
set value 'a' for key <swift.noHash.10> (0)
set value 'b' for key <swift.noHash.10> (1)
Stored value for key (0): <swift.noHash.10> = a
Stored value for key (1): <swift.noHash.10> = b
import Foundation
extension UnicodeScalar {
var isSpace: Bool {
return isspace(Int32(self.value)) != 0
}
var isAlphanumeric: Bool {
return isalnum(Int32(self.value)) != 0
function webRequest(url, data, callback, target) {
var http = new XMLHttpRequest();
if(!data){ mode="GET"; } else { mode="POST"; }
http.open(mode, url, true);
if(mode=="POST"){ http.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); }
http.onreadystatechange = function(){ if(http.readyState==4){ callback(http.responseText,target); }};
http.send(data);
}
//http://stackoverflow.com/questions/247483/http-get-request-in-javascript