Skip to content

Instantly share code, notes, and snippets.

View soffes's full-sized avatar

Sam Soffes soffes

View GitHub Profile
@PadraigK
PadraigK / Widon't
Last active August 29, 2015 13:57
Quick and dirty implementation of Shaun Inman's 'Widont' in Cocoa
// Example:
//
// Widont makes the last space non-breaking
// so you don't end up with one word on its
// own.
//
// Widont makes the last space non-breaking
// so you don't end up with one word on
// its own.
//
/**
Allows easier pushing and popping of clang warnings.
Example (Ignoring undeclared selectors):
SQClangDiagnosticPushIgnored(-Wundeclared-selector);
SEL undeclaredSelector = @selector(thisSelectorDoesNotExist:::);
SQClangDiagnosticPop;
*/
@seivan
seivan / gist:35aa77623ca5a90de44d
Created July 16, 2014 01:19
This is what I had to resort to given all the bugs in Swift - though now I can run my UIBezierPath code on OS X :)
//#if os(OSX)
import Cocoa
struct NSRectCorner : RawOptionSet {
var value: UInt = 0
init(_ value: UInt) { self.value = value }
func toRaw() -> UInt { return self.value }
func getLogicValue() -> Bool { return self.value != 0 }
static func fromRaw(raw: UInt) -> NSRectCorner? { return self(raw) }
static func fromMask(raw: UInt) -> NSRectCorner { return self(raw) }
static func convertFromNilLiteral() -> NSRectCorner { return self(0) }
//
// SSMapAnnotation.h
// Public Domain
//
// Created by Sam Soffes on 3/22/10.
// Copyright 2010 Sam Soffes. All rights reserved.
//
#import <MapKit/MapKit.h>
@mattorb
mattorb / gist:415172
Created May 26, 2010 22:31
discrete, custom timed (per frame) UIImageView Animation
// keyTimes = array floats for second [(NSNumber)1.2,(NSNumber)2.0] == 2 frames, 1.2 secs for first frame, 2.0 seconds for second frame
- (void) addDiscreteTimedImageAnimation:(NSString *)animationName view:(UIImageView *)imageView images:(NSArray *)images keyTimes:(NSArray *)keyTimes repeatCount:(float)repeatCount onDone:(SEL)callback {
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"contents"];
NSMutableArray *values = [[NSMutableArray alloc] initWithCapacity:[images count]];
NSMutableArray *keyTimesAsPercent = [[NSMutableArray alloc] initWithCapacity:[keyTimes count]];
double totalDuration = 0.0;
for(UIImage *image in images) {
[values addObject:(id)(image.CGImage)];
}
@lukeredpath
lukeredpath / Rakefile
Created August 31, 2010 18:16
Rakefile.rb
require 'rake/tasklib'
TARGET_NAME = "libLROAuth2Client"
module XcodeBuild
class TaskBuilder < Rake::TaskLib
attr_accessor :target, :configuration
def initialize(name)
@name = name
@seangaffney
seangaffney / TextMate SASS Save to CSS
Created September 16, 2010 22:26
This TextMate command will export your SCSS files to CSS on save. Hotness. Requires HAML gem to be installed. It's really just a modified version of the LESS Save to CSS command. Be sure to check the screenshot in the comments for the rest of the config
#!/usr/bin/env ruby
file = STDIN.read[/sass: ([^*]+\.scss)/, 1] || ENV["TM_FILEPATH"]
file2 = file.sub(/\.scss/,'.css')
system("sass \"#{file}\":\"#{file2}\"")
@jakemarsh
jakemarsh / gist:592329
Created September 22, 2010 19:28
Throw this on your UITableViewDelegate (probably your UITableViewController) to achieve the "keyboard dismisses when I tap away" effect.
//Throw this on your UITableViewDelegate (probably your UITableViewController) to achieve the "keyboard dismisses when I tap away" effect.
//Your users will thank you. A lot.
- (void) scrollViewWillBeginDragging:(UIScrollView *)scrollView {
[self.view endEditing:YES];
}
//The endEditing: method on UIView comes to us from a category that UITextField adds to UIKit that makes the view or any subview that is the first responder resign (optionally force), that's what the "YES" bit is.
@ryanb
ryanb / deploy.rb
Created July 12, 2011 16:14
Check to see if you have changes in head which have not been pushed before deploying
namespace :deploy do
desc "Make sure there is something to deploy"
task :check_revision, :roles => :web do
unless `git rev-parse HEAD` == `git rev-parse origin/master`
puts "WARNING: HEAD is not the same as origin/master"
puts "Run `git push` to sync changes."
exit
end
end
end
gem 'sass-rails', :git => 'https://github.com/rails/sass-rails.git', :ref => '031236b31eaf20658226a9ae051749cc6647c33f'
gem 'compass', :git => 'https://github.com/chriseppstein/compass.git', :ref => '2c1fcfcad708875d10db65740aabf417abc636a6'
gem 'sprockets', '2.0.0.beta.10'