This file contains hidden or 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 { | |
@State var predicate: NSPredicate = NSPredicate(format: "firstName contains[c] %@", "Joe") | |
var body: some View { | |
VStack { | |
FetchedObjects( | |
predicate: self.predicate, |
This file contains hidden or 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 | |
import CoreData | |
struct FetchedObjects<T, Content>: View where T : NSManagedObject, Content : View { | |
// MARK: - Properties | |
let content: ([T]) -> Content | |
var request: FetchRequest<T> |
This file contains hidden or 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( |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 => "[email protected]", | |
:from => "[email protected]", | |
:subject => "Test") do |format| | |
format.text |
This file contains hidden or 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 hidden or 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 hidden or 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> |