Skip to content

Instantly share code, notes, and snippets.

@maxhuk
maxhuk / Moon.swift
Created March 22, 2017 17:37
Extended moon phase utils
/** Extended moon phase utils
Ported from https://github.com/solarissmoke/php-moon-phase/blob/master/Solaris/MoonPhase.php
Maksym Huk 2017
*/
import Foundation
import SwiftMoment
class Moon {
@maxhuk
maxhuk / Moon.swift
Created March 22, 2017 15:39
Moon phase utils
/** Moon phase utils.
Ported from https://github.com/mourner/suncalc
Maksym Huk 2017
*/
class Moon {
let rad = M_PI / 180
let daySeconds: TimeInterval = 60 * 60 * 24
@maxhuk
maxhuk / AsyncURLConnection.h
Created April 9, 2013 13:04
Cancelable NSURLConnection with exact timeout.
//
// AsyncURLConnection.h
//
// Created by Maksym Huk on 10/31/12.
// Copyright (c) 2012 Maksym Huk. All rights reserved.
//
#import <Foundation/Foundation.h>
// Send request with exact timeout
@maxhuk
maxhuk / NSString+Hash.h
Created April 9, 2013 12:54
Common hashing algorithms on top of NSString.
//
// NSString+Hash.h
//
// Created by Maksym Huk on 10/10/12.
// Copyright (c) 2012 Maksym Huk. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface NSString (Hash)
@maxhuk
maxhuk / UISegmentedControl+Background.h
Created April 9, 2013 10:23
Fast UISegmentedControl appearance customization.
//
// UISegmentedControl+Background.h
//
// Created by Maksym Huk on 4/3/13.
// Copyright (c) 2013 Maksym Huk. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UISegmentedControl (Background)
@maxhuk
maxhuk / Localize.h
Created April 9, 2013 10:22
Useful localization macros. Fast localize for IB views and objects (text is replaced with NSLocalizedString(text, nil)).
//
// Localize.h
//
// Created by Maksym Huk on 3/31/13.
// Copyright (c) 2013 Maksym Huk. All rights reserved.
//
#import <Foundation/Foundation.h>
#define LS(...) NSLocalizedString((__VA_ARGS__), nil)
@maxhuk
maxhuk / AppDirectories.h
Created April 9, 2013 10:16
Fast path composition for common file locations.
//
// AppDirectories.h
//
// Created by Maksym Huk on 3/31/13.
// Copyright (c) 2013 Maksym Huk. All rights reserved.
//
#import <Foundation/Foundation.h>
NSString *AppendToDocumentsDirectory(NSString *path);
@maxhuk
maxhuk / NSAttributedString+Compose.h
Created April 9, 2013 10:15
Comfortable multi-part NSAttributedString composition.
//
// NSAttributedString+Compose.h
//
// Created by Maksym Huk on 3/31/13.
// Copyright (c) 2013 Maksym Huk. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface NSAttributedString (Compose)
@maxhuk
maxhuk / NSString+DateFormatter.h
Created April 9, 2013 10:13
Fast date formatting.
//
// NSString+DateFormatter.h
//
// Created by Maksym Huk on 3/31/13.
// Copyright (c) 2013 Maksym Huk. All rights reserved.
//
#import <Foundation/Foundation.h>
#define DateFormatDate @"yyyy-MM-dd"
@maxhuk
maxhuk / MBProgressHUD+ActivityBlock.h
Created April 9, 2013 10:12
Full activity block using MBProgressHUD.
//
// MBProgressHUD+ActivityBlock.h
//
// Created by Maksym Huk on 4/1/13.
// Copyright (c) 2013 Maksym Huk. All rights reserved.
//
#import "MBProgressHUD.h"
@interface MBProgressHUD (ActivityBlock)