most of these require logout/restart to take effect
# Enable character repeat on keydown
defaults write -g ApplePressAndHoldEnabled -bool false
# Set a shorter Delay until key repeat
#! /usr/bin/swift | |
import ScriptingBridge | |
@objc protocol iTunesTrack { | |
optional var name: String! {get} | |
optional var album: String! {get} | |
optional var foo: String! {get} | |
} |
extension Array { | |
func first() -> Element? { | |
if isEmpty { | |
return nil | |
} | |
return self[0] | |
} | |
func last() -> Element? { |
// The MIT License (MIT) | |
// | |
// Copyright (c) 2014 Nate Cook | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal | |
// in the Software without restriction, including without limitation the rights | |
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
// copies of the Software, and to permit persons to whom the Software is | |
// furnished to do so, subject to the following conditions: |
/** | |
Provides the ability to verify key paths at compile time. | |
If "keyPath" does not exist, a compile-time error will be generated. | |
Example: | |
// Verifies "isFinished" exists on "operation". | |
NSString *key = SQKeyPath(operation, isFinished); | |
// Verifies "isFinished" exists on self. |
import Foundation | |
var l = [ | |
"abesi", | |
"hidebu", | |
"tawaba", | |
] | |
var m = [ | |
"abesi": 1, |
// Use Swift operator overloading to blend two UIColors with the addition operator | |
import UIKit | |
@infix func + (left: UIColor, right: UIColor) -> UIColor { | |
var leftRGBA = CGFloat[](count: 4, repeatedValue: 0.0) | |
var rightRGBA = CGFloat[](count: 4, repeatedValue: 0.0) | |
left.getRed(&leftRGBA[0], green: &leftRGBA[1], blue: &leftRGBA[2], alpha: &leftRGBA[3]) | |
right.getRed(&rightRGBA[0], green: &rightRGBA[1], blue: &rightRGBA[2], alpha: &rightRGBA[3]) |
#!/usr/bin/env ruby | |
require 'gosu' # gem install gosu --no-document | |
include Gosu | |
$dimension, $splits = 200, 20 | |
$size = $dimension.to_f / $splits.to_f | |
class Worm | |
attr_writer :dir | |
def initialize() reset end |
#!/bin/bash | |
# change PREFIX to match whatever you use to denote private | |
# methods internally in .m files | |
# e.g. | |
# - (void)_privateMethod | |
PREFIX="_" | |
if [ $# -eq 0 ] | |
then |
@import MobileCoreServices; | |
static CFStringRef UTTypeForImageData(NSData *data) { | |
const unsigned char * bytes = [data bytes]; | |
if (data.length >= 8) { | |
if (bytes[0] == 0x89 && bytes[1] == 0x50 && bytes[2] == 0x4E && bytes[3] == 0x47 && bytes[4] == 0x0D && bytes[5] == 0x0A && bytes[6] == 0x1A && bytes[7] == 0x0A) { | |
return kUTTypePNG; | |
} | |
} |