This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
import sys | |
# import debugpy | |
from dateutil import rrule | |
from datetime import datetime, timezone, timedelta | |
from croniter import croniter | |
from collections import defaultdict | |
def main(crontab, start, end, fromDuration): | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
/// ------------------------------------------------------------------- | |
private func example1() { | |
let queue = DispatchQueue.global(qos: DispatchQoS.QoSClass.default) | |
for i in 0..<10 { | |
queue.async() { | |
print("Start: \(i)") | |
sleep(3) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// ---------------- When a presenter is UIViewController | |
class View: UIView { | |
let loadButton = UIButton() | |
let priceLabel = UILabel() | |
} | |
class Presenter : UIViewController { | |
var price: Int? | |
var theView: View { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Works only `NSDate()`! `Date()` will not be stubbed. Uses a Private API and should not be in main project target or your application will be rejected !!! | |
extension NSDate { | |
func stubAsCurrenDate(block: () -> Void) { | |
let customDateBlock: @convention(block) (AnyObject) -> NSDate = { _ in self } | |
let implementation = imp_implementationWithBlock(unsafeBitCast(customDateBlock, to: AnyObject.self)) | |
let method = class_getInstanceMethod(NSClassFromString("__NSPlaceholderDate"), #selector(NSObject.init)) | |
let oldImplementation = method_getImplementation(method) | |
method_setImplementation(method, implementation) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Если отсутствует утулита **PackageMaker**: | |
1. Скачиваем необходимые ресурсы по [ссылке](http://adcdownload.apple.com/Developer_Tools/auxiliary_tools_for_xcode__late_july_2012/xcode44auxtools6938114a.dmg); | |
2. Распаковываем и копируем все вложенные файлы в "/Applications/Utilities". | |
Создание установочного файла для **MOGenerator**: | |
1. Клонируем проект из [репозитория](https://github.com/fs/mogenerator); | |
2. Открываем приложение ```Терминал```; | |
3. Переходим в папку с клонированным репозиторием ```cd path/to/mogenerator```; | |
4. Выполняем скрипт для генерации установочных файлов через команду ```sh installer/make_installer.command```; | |
5. Вводим пароль и ждем надписи ```[Процесс завершен]```; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIImage { | |
func resize(size: CGSize) -> UIImage! { | |
if let colorSpace = CGColorSpaceCreateDeviceRGB() { | |
let bitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.PremultipliedLast.rawValue) | |
let context = CGBitmapContextCreate(nil, Int(size.width), Int(size.height), 8, 0, colorSpace, bitmapInfo.rawValue) | |
CGContextClearRect(context, CGRectMake(0, 0, size.width, size.height)) | |
switch self.imageOrientation | |
{ |