Skip to content

Instantly share code, notes, and snippets.

@timothyekl
timothyekl / UIImage+NFExtensions.h
Created April 12, 2016 01:31
UIImage(NFExtensions), a category for rescaling UIImage instances to generate thumbnails. Originally distributed as part of the UW PCE iOS course; now available under the MIT License.
// Copyright Tim Ekl 2014–2016. Available under MIT License.
#import <UIKit/UIKit.h>
@interface UIImage (NFExtensions)
- (UIImage *)scaledImageConstrainedToSize:(CGSize)size;
@end
package main
import (
"time"
)
func IntRangeGenerator(min, max int) <-chan int {
output := make(chan int)
go func() {
for i := min; i < max; i++ {
str = "noël" # decomposed
puts str.reverse # expect lëon
puts str[0..2] # expect noë
puts str.length # expect 4
str = "😸😾" # emoji
puts str.reverse # expect 😾😸
puts str[1..str.length] # expect 😾
puts str.length # expect 2
#import <Foundation/Foundation.h>
@interface NSString (Reversing)
- (NSString *)reverseString;
@end
@implementation NSString (Reversing)
- (NSString *)reverseString;
{
NSMutableString *reversedString = [NSMutableString stringWithCapacity:[self length]];
@timothyekl
timothyekl / gist:6604488
Created September 18, 2013 04:17
Abstract superclass initializers in Objective-C
#import <Foundation/Foundation.h>
@interface Parent : NSObject
@end
@implementation Parent
- (id)init;
{
if (!(self = [super init]))
return nil;
@timothyekl
timothyekl / keynote2pdf.scpt
Created May 28, 2013 14:33
Convert Keynote 5.3 documents to PDF
on run
display dialog "Drag keynote documents on me to convert to PDF."
end run
on open draggeditems
repeat with thisFile in draggeditems as list
tell application "Finder" to reveal item thisFile
set thisFile to thisFile as alias
tell application "Keynote" to open thisFile
@timothyekl
timothyekl / gist:5587371
Created May 15, 2013 21:05
rdar://13903643 - "NSCell does not implement methods declared in NSTextAttachmentCell protocol" NSTextAttachmentCell's documentation claims that NSCell implements all but three of its methods. This isn't the case.
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
int main(int argc, char *argv[]) {
@autoreleasepool {
SEL *selectors = malloc(10 * sizeof(SEL));
// The following selectors are taken from the NSTextAttachmentCell protocol reference.
// That document states that NSCell responds to all of its declared methods with three exceptions (noted below).
#import <stdio.h>
int main(int argc, char *argv[]) {
printf("Get things done!");
return 0;
}
@timothyekl
timothyekl / config.yml
Created November 21, 2011 01:25
PneumatiCraft ChatSuite config
plugin:
default_locale: en
locales: [en]
# if allow_channels is false, your users will be unable to use any channel
# related commands, and as such the default channel will become their permanent
# chat place (it is recommended to set default_channel to global if you set this to false)
# note: a change to this setting will require a full /reload or server restart
allow_channels: true
allow_whispers: true
allow_afk: true
@timothyekl
timothyekl / gist:1217887
Created September 14, 2011 21:44
Cross-platform: recompile LaTeX documents using Ruby, Guard
# Tested with Ruby 1.9
# Needs gem "guard" (https://github.com/guard/guard)
# Needs gem "guard-shell" (https://github.com/guard/guard-shell)
# Uses process "growlnotify" (http://growl.info/extras.php)
# Uses process "pdflatex" from standard TeXLive distribution
guard 'shell' do
watch(%r{(.+)\.tex}) do |m|
`growlnotify -m #{m[0]} Recompiling`
`pdflatex -interaction=batchmode #{m[0]} >/dev/null`