Skip to content

Instantly share code, notes, and snippets.

Aral Balkan aral

Block or report user

Report or block aral

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
aral / NSView+ChangeAnchorPointWithoutMakingTheLayerJump.swift
Created Jul 18, 2015
A replacement for the anchorPoint property that doesn’t make the layer jump
View NSView+ChangeAnchorPointWithoutMakingTheLayerJump.swift
// NSView+ChangeAnchorPointWithoutMakingTheLayerJump.swift
// Setting .anchorPoint on a layer makes the layer jump which is most
// likely not what you want. This extension fixes that. Useful for Core Animation.
// Usage: (e.g., to set the anchor point to the centre)
// myView.setAnchorPoint(CGPointMake(0.5, 0.5))
aral / NSView+CustomTaggable.swift
Last active May 27, 2016
Tag support in Interface Builder for custom NSViews
View NSView+CustomTaggable.swift
// NSView+CustomTaggable.swift
// Allows you to set tags in Interface Builder for custom NSViews.
// Usage:
// Your custom view must implement the CustomTaggable protocol. Then, in your custom
// NSView, declare the customTag property like this:
aral / gist:300a0588563d4f52a950
Last active Aug 29, 2015
Example of allowing free text entry of significant tokens in Interface Builder (for an @IBDesignable view) using a bitmask.
View gist:300a0588563d4f52a950
// Unfortunately, this has to be a string right now as IBInspectable enums are not supported at the moment.
@IBInspectable var alignmentToParentName:String = "top right"
var name = (alignmentToParentName.lowercaseString as NSString)
let top = 0b00, bottom = 0b10, right = 0b00, left = 0b01
var bitmask = 0b0
// The default, even if garbage is entered in Interface Builder, is top right.
aral /
Created Jun 20, 2015
Keybase proof

Keybase proof

I hereby claim:

  • I am aral on github.
  • I am aral ( on keybase.
  • I have a public key whose fingerprint is FB1B E897 B399 F107 780A B004 B89F B743 1702 6216

To claim this, I am signing this object:

aral / gist:84ddf7ac37be079632ab
Last active Jul 31, 2018
NSPopover .appearance property is NSAppearance in Swift, not NSPopoverAppearance as per the docs
View gist:84ddf7ac37be079632ab
// The docs say that the appearance property of an NSPopover should be set to an
// NSPopoverAppearance enum but it actually expects an NSAppearance instance.
// e.g., in an NSViewController subclass:
let popover = NSPopover()
popover.contentViewController = self.storyboard?.instantiateControllerWithIdentifier("someViewController") as? NSViewController
popover.appearance = NSAppearance(named: NSAppearanceNameVibrantLight)
popover.behavior = NSPopoverBehavior.Transient
aral / gist:f65d30da4aff818af3c4
Last active Aug 29, 2015
AnyObject? to unwrapped value
View gist:f65d30da4aff818af3c4
let a = NSDictionary(object: NSNumber(bool: true), forKey: "boolKey")
let b: AnyObject? = a.objectForKey("boolKey")
if let b:AnyObject = b, c:NSNumber = (b as? NSNumber) where c.boolValue == true
println("It’s true.")
aral / ugly-swift
Created Feb 17, 2015
Please, make it stop!
View ugly-swift
let cgContext:CGContextRef = CGBitmapContextCreate(nil, UInt(resolutionForExport.width), UInt(resolutionForExport.height), 8, 4*UInt(resolutionForExport.width), colorSpace, CGBitmapInfo.ByteOrderDefault|CGBitmapInfo(CGImageAlphaInfo.PremultipliedLast.rawValue))
aral / MainWindowController.swift
Last active Aug 29, 2015
Applying CATransitions — won’t work with vibrancy
View MainWindowController.swift
// MainWindowController.swift
// Heartbeat
// Created by Aral Balkan on 07/02/2015.
// Copyright (c) 2015
// Released under the MIT license.
import Cocoa
aral / gist:f208f7408e56b6db19d7
Created Oct 30, 2014
Hash Sieve in CoffeeScript
View gist:f208f7408e56b6db19d7
# Implementation of hash sieve algorithm that I read
# about at
# in CoffeeScript with slightly more literate code :)
Array.prototype.unique = ->
hashSieve = {}
arrayOfUniqueValues = [];
aral / gist:183b3bd303df237ed6d9
Created Oct 29, 2014
Add a new SSH key to Dokku after initial install (e.g., email starts with aral@…)
View gist:183b3bd303df237ed6d9
cat .ssh/authorized_keys | grep aral@ | sshcommand acl-add dokku aral
You can’t perform that action at this time.