Skip to content

Instantly share code, notes, and snippets.

View vskintiian's full-sized avatar
🍎

Vladyslav Skintiian vskintiian

🍎
View GitHub Profile
import Foundation
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
func async<T>(_ executable: @escaping @autoclosure () -> T, _ priority: DispatchQoS.QoSClass = DispatchQoS.QoSClass.default, completion: @escaping (T) -> Void) {
DispatchQueue.global(qos: priority).async {
let result = executable()
DispatchQueue.main.async {
@vskintiian
vskintiian / UITabBarItemTextColor.swift
Last active March 17, 2017 15:07
UITabBarItem text color
let normalAttributes = [NSFontAttributeName: UIFont(font: SomeFont, size: 12), NSForegroundColorAttributeName: UIColor.redColor()]
let highlightedAttributes = [NSFontAttributeName: UIFont(font: SomeFont, size: 12), NSForegroundColorAttributeName: UIColor.whiteColor()]
let tabBarItem = UITabBarItem(title: "Button", image: UIImage(named: "Button")!, selectedImage: UIImage(named: "Button_selected")!)
tabBarItem.setTitleTextAttributes(highlightedAttributes, forState: .Highlighted)
tabBarItem.setTitleTextAttributes(normalAttributes, forState: .Normal)
@vskintiian
vskintiian / osx_bootstrap.sh
Last active October 31, 2017 12:26 — forked from codeinthehole/osx_bootstrap.sh
Script to prepare a new OSX machine for work
#!/usr/bin/env bash
#
# Bootstrap script for setting up a new OSX machine
#
# This should be idempotent so it can be run multiple times.
#
# Some apps don't have a cask and so still need to be installed by hand. These
# include:
#
# - Twitter (app store)
@vskintiian
vskintiian / imageFromView.swift
Created December 7, 2017 13:51
imageFromView
extension UIView {
public var image: UIImage? {
UIGraphicsBeginImageContextWithOptions(bounds.size, false, 0.0)
defer { UIGraphicsEndImageContext() }
return UIGraphicsGetCurrentContext().flatMap { [unowned self] _ in
self.drawHierarchy(in: bounds, afterScreenUpdates: true)
return UIGraphicsGetImageFromCurrentImageContext()
}
// return UIGraphicsGetCurrentContext().flatMap { [unowned self] context in
@vskintiian
vskintiian / useHexo.md
Created June 17, 2018 13:16 — forked from btfak/useHexo.md
How to use Hexo and deploy to GitHub Pages
@vskintiian
vskintiian / UIView+Utility.swift
Created February 9, 2019 13:01 — forked from joshavant/UIView+Utility.swift
Ambiguity Treadmill
extension UIView {
@objc func exerciseAmbiguityInLayoutRepeatedly() {
if self.hasAmbiguousLayout {
Timer.scheduledTimer(timeInterval: 0.5,
target: self,
selector: #selector(UIView.exerciseAmbiguityInLayout),
userInfo: nil,
repeats: true)
}
}
@vskintiian
vskintiian / detweet.swift
Created February 9, 2019 13:02 — forked from mxcl/detweet.swift
Delete all tweets and favorites older than two months ago. Instructions in comment.
#!/usr/bin/swift sh
import Foundation
import PromiseKit // @mxcl ~> 6.5
import Swifter // @mattdonnelly == b27a89
let swifter = Swifter(
consumerKey: "FILL",
consumerSecret: "ME",
oauthToken: "IN",
oauthTokenSecret: "https://developer.twitter.com/en/docs/basics/apps/overview.html"
[user]
name = Vladyslav Skintiian
email = PUT EMAIL HERE
username = vskintiyan
editor = code
[merge]
tool = vscode
[mergetool "vscode"]
cmd = code --wait $MERGED
[diff]
@vskintiian
vskintiian / Hole.swift
Created June 12, 2020 14:42
Hole type for Swift lang
protocol Holable {
static var hole: Self { get }
}
extension Holable {
static var hole: Self {
fatalError()
}
}