Skip to content

Instantly share code, notes, and snippets.

View pruinis's full-sized avatar

Anton M. pruinis

  • Ukraine
View GitHub Profile
@pruinis
pruinis / multiple_ssh_setting.md
Created March 19, 2019 23:18 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "[email protected]"
@pruinis
pruinis / gist:27f3371188c556416d9336283df601cb
Created November 3, 2016 01:35 — forked from bwhiteley/gist:049e4bede49e71a6d2e2
Initialize Swift subclass of UIView, designed in .xib
// Create CustomView.xib, set File's Owner to CustomView.
// Link the top level view in the XIB to the contentView outlet.
class CustomView : UIView {
@IBOutlet private var contentView:UIView?
// other outlets
override init(frame: CGRect) { // for using CustomView in code
super.init(frame: frame)
self.commonInit()
@pruinis
pruinis / ConcurrentOperation.swift
Created October 15, 2016 20:22 — forked from calebd/AsynchronousOperation.swift
Concurrent NSOperation in Swift
//
// ConcurrentOperation.swift
//
// Created by Caleb Davenport on 7/7/14.
//
// Learn more at http://blog.calebd.me/swift-concurrent-operations
//
import Foundation
@pruinis
pruinis / MKAnnotationView-v1.swift
Created August 17, 2016 12:55 — forked from mackuba/MKAnnotationView-v1.swift
Swift MKAnnotationView WTF
/*
MKAnnotationView has one init listed in its documentation, initWithAnnotation:reuseIdentifier:, so let's override that.
But this causes a runtime exception:
fatal error: use of unimplemented initializer 'init(frame:)' for class 'PulsatingDotMarker'
*/
class PulsatingDotMarker: MKAnnotationView {
let innerCircle: UIView
@pruinis
pruinis / NSString+Distance.h
Created August 15, 2016 14:17 — forked from KATT/NSString+Distance.h
NSString+Distance category (using ARC)
//
// NSString+Distance.h
//
// Created by Alexander Johansson on 2011-11-27.
// Based on http://stackoverflow.com/q/5684973/590396
//
#import <Foundation/Foundation.h>
@interface NSString (Distance)
@pruinis
pruinis / timeago.swift
Created May 1, 2016 14:43 — forked from minorbug/timeago.swift
"Time ago" function for Swift (based on MatthewYork's DateTools for Objective-C)
func timeAgoSinceDate(date:NSDate, numericDates:Bool) -> String {
let calendar = NSCalendar.currentCalendar()
let unitFlags = NSCalendarUnit.CalendarUnitMinute | NSCalendarUnit.CalendarUnitHour | NSCalendarUnit.CalendarUnitDay | NSCalendarUnit.CalendarUnitWeekOfYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitSecond
let now = NSDate()
let earliest = now.earlierDate(date)
let latest = (earliest == now) ? date : now
let components:NSDateComponents = calendar.components(unitFlags, fromDate: earliest, toDate: latest, options: nil)
if (components.year >= 2) {
return "\(components.year) years ago"
@pruinis
pruinis / Thread_management_iOS.swift
Created April 25, 2016 16:15 — forked from nbhasin2/Thread_management_iOS.swift
Multi Threading in Swift (iOS) using Dispatch Group
//Group 4 will be executed last after 1-3 are done executing
//Multi Threadin in Swift Group Dispatch Example
//Global Dispatch Queue
let dispatchGroup = dispatch_group_create()
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), {
@pruinis
pruinis / TCHorizontalSelectorView
Created March 15, 2016 12:27 — forked from redent/TCHorizontalSelectorView
Horizontal selector view with view reuse and infinite circular scrolling, allowing more than one element per page
//
// TCHorizontalSelectorView.m
// TwinCodersLibrary
//
// Created by Guillermo Gutiérrez on 16/01/13.
// Copyright (c) 2013 TwinCoders S.L. All rights reserved.
//
#import <UIKit/UIKit.h>
@pruinis
pruinis / UISearchBar.m
Created December 30, 2015 12:05 — forked from jeksys/UISearchBar.m
Detecting when clear is clicked in UISearchBar (X button)
- (void)viewDidLoad {
//find the UITextField view within searchBar (outlet to UISearchBar)
//and assign self as delegate
for (UIView *view in searchBar.subviews){
if ([view isKindOfClass: [UITextField class]]) {
UITextField *tf = (UITextField *)view;
tf.delegate = self;
break;
}
}