Skip to content

Instantly share code, notes, and snippets.

View aral's full-sized avatar

Aral Balkan aral

View GitHub Profile
@aral
aral / LEDPong.ino
Created March 30, 2014 20:11
1D LED Pong inspired by Jason Hotchkiss’s 1D Pong
//
// 1D LED PONG
// Copyright (c) 2014 Aral Balkan. Released under the MIT License.
//
// Inspired by Jason Hotchkiss’s 1D Pong (hat-tip Seb Lee-Delisle)
//
// Video of working result: https://twitter.com/aral/status/450334281953722369
//
// With knowledge gleamed from the Build Brighton Introduction to Arduino Workshop on 29th March, 2014.
// http://buildbrighton.com
@aral
aral / gist:183b3bd303df237ed6d9
Created October 29, 2014 23:29
Add a new SSH key to Dokku after initial install (e.g., email starts with aral@…)
cat .ssh/authorized_keys | grep aral@ | sshcommand acl-add dokku aral
@aral
aral / gist:f208f7408e56b6db19d7
Created October 30, 2014 00:17
Hash Sieve in CoffeeScript
#
# Implementation of hash sieve algorithm that I read
# about at http://www.shamasis.net/2009/09/fast-algorithm-to-find-unique-items-in-javascript-array/
# in CoffeeScript with slightly more literate code :)
#
Array.prototype.unique = ->
hashSieve = {}
arrayOfUniqueValues = [];
@aral
aral / MainWindowController.swift
Last active August 29, 2015 14:14
Applying CATransitions — won’t work with vibrancy
//
// MainWindowController.swift
// Heartbeat
//
// Created by Aral Balkan on 07/02/2015.
// Copyright (c) 2015 Ind.ie.
// Released under the MIT license.
//
import Cocoa
@aral
aral / ugly-swift
Created February 17, 2015 21:42
Please, make it stop!
let cgContext:CGContextRef = CGBitmapContextCreate(nil, UInt(resolutionForExport.width), UInt(resolutionForExport.height), 8, 4*UInt(resolutionForExport.width), colorSpace, CGBitmapInfo.ByteOrderDefault|CGBitmapInfo(CGImageAlphaInfo.PremultipliedLast.rawValue))
@aral
aral / gist:f65d30da4aff818af3c4
Last active August 29, 2015 14:17
AnyObject? to unwrapped value
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
aral / keybase.md
Created June 20, 2015 12:50
Keybase proof

Keybase proof

I hereby claim:

  • I am aral on github.
  • I am aral (https://keybase.io/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
aral / gist:300a0588563d4f52a950
Last active August 29, 2015 14:25
Example of allowing free text entry of significant tokens in Interface Builder (for an @IBDesignable view) using a bitmask.
// Unfortunately, this has to be a string right now as IBInspectable enums are not supported at the moment.
@IBInspectable var alignmentToParentName:String = "top right"
{
didSet
{
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 testing Gist
@aral
aral / gist:965632
Created May 10, 2011 23:48
Orientation change doesn't fire on iPad - workaround - jQueryMobile scrollView
/*$(document).live("orientationchange", function(event) {
ResizePageContentHeight($(".ui-page"));
});*/
// As per: http://code.google.com/p/jqtouch/issues/detail?id=370
$(window).bind('orientationchange', function(event) {
ResizePageContentHeight($(".ui-page"));
}).trigger('orientationchange');