Skip to content

Instantly share code, notes, and snippets.

View iby's full-sized avatar
👻

Ian Bytchek iby

👻
View GitHub Profile
@iby
iby / boto3_hands_on.md
Created October 25, 2015 18:36 — forked from iMilnb/boto3_hands_on.md
Programmatically manipulate AWS resources with boto3 - a quick hands on

boto3 quick hands-on

This documentation aims at being a quick-straight-to-the-point-hands-on AWS resources manipulation with [boto3][0].

First of all, you'll need to install [boto3][0]. Installing it along with [awscli][1] is probably a good idea as

  • [awscli][1] is boto-based
  • [awscli][1] usage is really close to boto's
@iby
iby / Playground.swift
Last active June 29, 2020 20:45
Block / method / function comparison in Swift
import Foundation
// Some interesting observations on block comparing. Apparently swift nor objective c don't allow comparing closures
// due to the complexity of the process and because of compiler optimisations… bla bla. But it seems to be possible
// to do this using conventions blocks, aka the objective c ones that can be cast as objects. The interesting part
// is how swift freely casts SwfBlock to ObjBlock, yet in reality two casted SwfBlock blocks will always be different
// values, while ObjBlocks won't. When we cast ObjBlock to SwfBlock, the same thing happens to them, they become two
// different values. So, in order to preserve the reference, this sort of casting should be avoided.
typealias SwfBlock = () -> ()
ACTION = build
AD_HOC_CODE_SIGNING_ALLOWED = NO
ALTERNATE_GROUP = staff
ALTERNATE_MODE = u+w,go-w,a+rX
ALTERNATE_OWNER = grantdavis
ALWAYS_SEARCH_USER_PATHS = NO
ALWAYS_USE_SEPARATE_HEADERMAPS = YES
APPLE_INTERNAL_DEVELOPER_DIR = /AppleInternal/Developer
APPLE_INTERNAL_DIR = /AppleInternal
APPLE_INTERNAL_DOCUMENTATION_DIR = /AppleInternal/Documentation
@iby
iby / NSViewOverlapTest.swift
Last active December 18, 2022 11:02
Overlap test for NSView with tracking areas
import AppKit
extension NSView
{
/// Checks if view overlaps with other views above it at specified **window** location.
func overlapTest(_ point: NSPoint) -> Bool {
// Perform hit test to get the view under mouse. Because it can be a view within
@iby
iby / Foo.m
Last active May 4, 2019 08:01
Using NSObject’s +load and +initialize from Swift, checkout the full story – https://medium.com/post-mortem/using-nsobjects-load-and-initialize-from-swift-f6f2c6d9aad0
#import <Foundation/Foundation.h>
#import <MyProject/MyProject-Swift.h>
// This was a more concise solution in Swift 4.2 and earlier. If you try this with Swift 5 you'd get "Swift class
// extensions and categories on Swift classes are not allowed to have +load methods" runtime error.
// @implementation Foo (private)
// + (void)load { [self swiftyLoad]; }
// + (void)initialize { [self swiftyInitialize]; }
// @end
@iby
iby / MLWAsyncAVPlayer.h
Created March 11, 2018 15:48 — forked from k06a/MLWAsyncAVPlayer.h
Awesome optimized AVPlayer for smooth scrolling AVPlayerLayer inside UICollectionView/UITableView (tested on iOS10+)
#import <AVFoundation/AVFoundation.h>
@interface MLWAsyncAVPlayer : AVPlayer
@end
extension Reactive {
/// A proxy which holds reactive binding target extensions of `Base`.
struct Binds<Base> {
fileprivate init(_ base: Base) { self.base = base }
let base: Base
}
var bind: Binds<Base> { return Binds(self.base) }
class Foo: ReactiveExtensionsProvider {
let pipe = Signal<String, NoError>.pipe()
var bar: String = "Such bar!" {
didSet { self.pipe.input.send(value: self.bar) }
}
}
extension Reactive.Binds where Base: Foo {
var bar: BindingTarget<String> {
return self.reactive.makeBindingTarget({ $0.bar = $1 })
let fooOne: Foo = Foo()
let fooTwo: Foo = Foo()
fooOne.reactive.signal.bar.observeValues({ Swift.print($0) })
fooOne.reactive.bind.bar <~ fooTwo.reactive.signal.bar
fooOne.bar = "Such b-a-r!"
fooTwo.bar = "Very BAR!"
@iby
iby / CALayer+CARenderer.swift
Last active June 6, 2023 12:20
Rendering animated CALayer off-screen using CARenderer with MTLTexture, https://stackoverflow.com/q/56150363/458356
import AppKit
import Metal
import QuartzCore
let view = NSView(frame: CGRect(x: 0, y: 0, width: 600, height: 400))
let circle = NSView(frame: CGRect(x: 0, y: 0, width: 50, height: 50))
circle.wantsLayer = true
circle.layer?.backgroundColor = NSColor.red.cgColor
circle.layer?.cornerRadius = 25