This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pragma mark menu | |
- (BOOL)validateMenuItem:(NSMenuItem *)menuItem { | |
if ([menuItem action] == @selector(toggleRuler:)) { | |
if ([canvasView rulersVisible]) { | |
[menuItem setTitle:@"Hide Ruler"]; | |
} else { | |
[menuItem setTitle:@"Show Ruler"]; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The goal... | |
[NSPredicate predicateWithFormat:@"dateModified >= CAST(CAST(now(), \"NSNumber\") - %d, \"NSDate\")", (30*86400)]; | |
//"now()" is a function and takes no arguments | |
NSExpression *now = [NSExpression expressionForFunction:@"now" arguments:[NSArray array]]; | |
//CAST(now(), 'NSNumber') | |
NSArray *castNowArguments = [NSArray arrayWithObjects:now, [NSExpression expressionForConstantValue:@"NSNumber"], nil]; | |
NSExpression *castNow = [NSExpression expressionForFunction:@"castObject:toType:" arguments:castNowArguments]; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p style="font-family: Bebas; font-size: 20px; color: white;">This is a headline...</p> | |
<p>This is some normal text on a new line... <a href="http://www.example.com">... with a link</a></p> | |
<p>...etc...</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Given /^I have a valid API account$/ do | |
@account = Account.create(:token => UUID.generate(:compact)) | |
@token = @account.token | |
authorize 'x', @account.secret | |
end | |
Given /^I send and accept XML$/ do | |
header 'Accept', 'application/xml' | |
header 'Content-Type', 'application/xml' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ENV['RACK_ENV'] = 'test' | |
require File.join(File.dirname(__FILE__), '../../app.rb') | |
require 'capybara' | |
require 'capybara/dsl' | |
require 'rspec/expectations' | |
require 'rack/test' | |
require 'uuid' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra' | |
require 'action_mailer' | |
class Mailer < ActionMailer::Base | |
def contact | |
mail( | |
:to => "test@example.com", | |
:from => "test@example.com", | |
:subject => "Test") do |format| | |
format.text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Cocoa/Cocoa.h> | |
@interface NSColor (Hex) | |
- (NSString *)hexadecimalValue; | |
+ (NSColor *)colorFromHexadecimalValue:(NSString *)hex; | |
@end | |
#import "NSColor+Hex.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func centerViewOn(point: CGPoint) { | |
if let layer = self.layers.first?.layer { | |
let viewSize = self.view!.bounds.size | |
let ratioWidth = self.size.height / viewSize.height | |
let newWidth = viewSize.width * ratioWidth | |
let ratioHeight = self.size.width / viewSize.width | |
let newHeight = viewSize.height * ratioHeight | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct StudentsView: View { | |
@FetchRequest( | |
entity: Student.entity(), | |
sortDescriptors: [], | |
predicate: NSPredicate(format: "name = %@", "Joe") | |
) var students: FetchedResults<Student> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct StudentsView: View { | |
var request: FetchRequest<Student> | |
var students: FetchedResults<Student>{ request.wrappedValue } | |
// MARK: - Lifecycle | |
init( |
OlderNewer