Skip to content

Instantly share code, notes, and snippets.

View d-zhukov's full-sized avatar

Dmitry Zhukov d-zhukov

View GitHub Profile
import UIKit
struct Action {
let title: String
let style: UIAlertAction.Style
let action: () -> Void
}
extension Action {
static func `default`(_ title: String, action: @escaping () -> Void) -> [Action] {
@dkw5877
dkw5877 / FireworksParticleView.swift
Created March 6, 2019 21:31
An example of particle emitters used to generate fireworks
import UIKit.UIView
class FireworksParticleView:UIView {
var particleImage:UIImage?
var flareImage:UIImage?
override class var layerClass:AnyClass {
return CAEmitterLayer.self
}
@podkovyrin
podkovyrin / podkovyr_btt.json
Last active January 29, 2020 13:50 — forked from vas3k/vas3k_btt_v2.json
BetterTouchTool Preset
{
"BTTPresetName" : "podkovyr-btt-preset",
"BTTPresetUUID" : "4DA9BBE8-9392-4B6C-A22B-AAF8189CE7C1",
"BTTPresetContent" : [
{
"BTTAppBundleIdentifier" : "BT.G",
"BTTAppName" : "Global",
"BTTAppSpecificSettings" : {
},
@mash
mash / audio.swift
Created September 22, 2017 10:50
audio stuff on macOS
//
// File.swift
// AudioSwitcher
//
// Created by Masakazu Ohtsuka on 2017/09/22.
// Copyright © 2017 maaash.jp. All rights reserved.
//
import Foundation
import Cocoa
@michaelochs
michaelochs / NSFormattingContextDynamic.m
Created December 13, 2016 15:37
`NSFormattingContextDynamic` makes a formatter return string proxies that change based on where you but them inside a format string.
NSDate *date = [NSDate new];
NSDateFormatter *dateFormatter = [NSDateFormatter new];
dateFormatter.locale = [NSLocale localeWithLocaleIdentifier:@"nl_NL"];
dateFormatter.dateStyle = NSDateFormatterFullStyle;
dateFormatter.formattingContext = NSFormattingContextDynamic; // this is the important setting
NSString *dateString = [dateFormatter stringFromDate:date];
NSString *s1 = [NSString stringWithFormat:@"Foo %@", dateString]; // "Foo dinsdag 13 december 2016"
@mackuba
mackuba / wwdc16.md
Last active March 5, 2023 21:28
New stuff from WWDC 2016

Following the tradition from last year, here's my complete list of all interesting features and updates I could find in Apple's OSes, SDKs and developer tools that were announced at this year's WWDC. This is based on the keynotes, the "What's New In ..." presentations and some others, Apple's release notes, and blog posts and tweets that I came across in the last few weeks.

If for some reason you haven't watched the talks yet, I really recommend watching at least the "State of the Union" and the "What's New In" intros for the platforms you're interested in. The unofficial WWDC Mac app is great way to download the videos and keep track of what you've already watched.

If you're interested, here are my WWDC 2015 notes (might be useful if you're planning to drop support for iOS 8 now and start using some iOS 9 APIs).


OSX → macOS 10.12 Sierra

@nicklockwood
nicklockwood / gist:493da04de6ea5cbc7a7e
Last active December 28, 2016 16:02
Animating layer contents when bounds changes
@interface AnimatedContentsLayer: CALayer
@property (nonatomic, assign) CGSize animatedSize;
@end
@implementation AnimatedContentsLayer
@dynamic animatedSize;
@phatblat
phatblat / gist:0dd175b406cf2f3fbfc9
Created August 26, 2015 01:22
xcodebuild -exportOptionsPlist available keys (Xcode 7b6)
Available keys for -exportOptionsPlist:
compileBitcode : Bool
For non-App Store exports, should Xcode re-compile the app from bitcode? Defaults to YES.
embedOnDemandResourcesAssetPacksInBundle : Bool
For non-App Store exports, if the app uses On Demand Resources and this is YES, asset packs are embedded in the app bundle so that the app can be tested without a server to host asset packs. Defaults to YES unless onDemandResourcesAssetPacksBaseURL is specified.
// Props to the fine folks on this thread http://bbs.iosre.com/forum.php?mod=viewthread&tid=694
//
// Example output of a call to dailyUsageStasticsForBundleIdentifier or weeklyUsageStasticsForBundleIdentifier
// Inline comments are educated guesses at meaning
// {
// Airdrop = 0; // Has App used Airdrop
// Airplay = 0; // Has App used Airplay
// BBCondition = 0; // ?? BB = Backboard? This number is a float (ie 24.8766038700895)
//
// // No idea what the below units are, or what BLD means
@steipete
steipete / FullscreenWindow.m
Created November 7, 2014 18:11
Workaround for rdar://18906964: Moving UIViewController from one window to another breaks rotation in iOS 8.1
@interface FullscreenWindow : UIWindow @end
@implementation FullscreenWindow
- (void)setRootViewController:(UIViewController *)rootVC {
// Try to clear the existing interface orientation, fixes rdar://18906964.
// Apparantly in iOS 8.1 the interface orientation doesn't correctly clears out,
// which then leads to weird rotation issues.
@try {[rootVC setValue:@(UIInterfaceOrientationPortrait) forKey:NSStringFromSelector(@selector(interfaceOrientation))];}
@catch (NSException *exception) {}
[super setRootViewController:rootVC];