Skip to content

Instantly share code, notes, and snippets.

@jeremy-w
jeremy-w / rot13.swift
Created August 4, 2014 21:36
Demonstrates rot13 in Swift with non-[A-Z][a-z] pass-through.
import Cocoa
var input = "This is a test"
var expected = "Guvf vf n grfg"
/// Advances `i` by `by` through `string`, wrapping to start on hitting
/// end.
/// NOTE: `by` must be non-negative.
func wrappingAdvance(string: String, i: String.Index, by: Int)
-> String.Index {
@flatpickles
flatpickles / SKShapeNode Tiled Fill Texture
Last active July 15, 2018 20:42
SKShapeNode scales a fill texture by default, instead of repeating the pattern. This snippet extends SKShapeNode to support setting a tiled fill-texture.
import SpriteKit
extension SKShapeNode {
func setTiledFillTexture(imageName: String, tileSize: CGSize) {
let targetDimension = max(self.frame.size.width, self.frame.size.height)
let targetSize = CGSizeMake(targetDimension, targetDimension)
let targetRef = UIImage(named: imageName).CGImage
UIGraphicsBeginImageContext(targetSize)
let contextRef = UIGraphicsGetCurrentContext()
@preble
preble / gist:5117339
Last active December 14, 2015 16:48
iOS & Cocoa Resources
@markd2
markd2 / array.m
Created February 21, 2013 14:53
On-demand Objective-C message tracing
#import <Foundation/Foundation.h>
// clang -g -fobjc-arc -framework Foundation -o array array.m
void observeObject (id objectToWatch) {
// Just a stub to give DTrace something to hook in to.
}
int main (void) {
@autoreleasepool {
@chaptastic
chaptastic / gist:1127738
Created August 5, 2011 15:10
Open in Chrome for Reeder
property theURL : ""
set clipSave to the clipboard
tell application "Reeder"
activate
end tell
tell application "System Events"
keystroke "c" using {shift down, command down}
anonymous
anonymous / snippet.txt
Created October 8, 2010 15:07
#!/bin/sh
osascript <<END
tell app "Terminal" to do script "cd \"`pwd`\""
END