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
module UrlHelpers | |
extend ActiveSupport::Concern | |
def default_url_options | |
Rails.configuration.action_mailer.default_url_options | |
end | |
included do | |
include Rails.application.routes.url_helpers | |
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
<style type="text/css"> | |
/****** EMAIL CLIENT BUG FIXES - BEST NOT TO CHANGE THESE ********/ | |
.ExternalClass { | |
width: 100%; | |
} | |
/* Forces Outlook.com to display emails at full width */ | |
.ExternalClass, .ExternalClass p, .ExternalClass span, .ExternalClass font, .ExternalClass td, .ExternalClass div { line-height: 100%; } | |
/* Forces Outlook.com to display normal line spacing, here is more on that: http://www.emailonacid.com/forum/viewthread/43/ */ | |
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
// Execute the following code somewhere in your app | |
UIToolbar *datePickerToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0.f, 50.f, self.window.bounds.size.width, 44.f)]; | |
UIBarButtonItem *flexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]; | |
UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithTitle:@"Cancel" style:UIBarButtonItemStylePlain target:self action:nil]; | |
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithTitle:@"OK" style:UIBarButtonItemStyleDone target:self action:nil]; | |
datePickerToolbar.items = @[cancelButton, flexibleSpace, doneButton]; | |
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
// | |
// CoreImage filter chain to blur an arbitrary UIImage | |
// Input: blur radius and target size | |
// This is assumed to be called on a background queue, it takes a response block to process the completed, blurred image | |
// <C> 2013/2014 Joerg Schwieder, use at will; I'd love to see an attribution, of course but don't demand it. | |
// Contains some pseudo code, see comments. | |
// | |
+ (CGFloat)blurRadius { |
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 "UICollectionViewFlowLayoutCenterItem.h" | |
@implementation UICollectionViewFlowLayoutCenterItem | |
- (CGPoint)targetContentOffsetForProposedContentOffset:(CGPoint)proposedContentOffset withScrollingVelocity:(CGPoint)velocity | |
{ | |
CGSize collectionViewSize = self.collectionView.bounds.size; | |
CGFloat proposedContentOffsetCenterX = proposedContentOffset.x + self.collectionView.bounds.size.width * 0.5f; | |
CGRect proposedRect = self.collectionView.bounds; |
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
// Taken from the commercial iOS PDF framework http://pspdfkit.com. | |
// Copyright (c) 2014 Peter Steinberger, PSPDFKit GmbH. All rights reserved. | |
// Licensed under MIT (http://opensource.org/licenses/MIT) | |
// | |
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it. | |
// PLEASE DUPE rdar://27192338 (https://openradar.appspot.com/27192338) if you would like to see this in UIKit. | |
#import <objc/runtime.h> | |
#import <objc/message.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
if ENV['DEBUG_REQUIRE'] | |
require 'benchmark' | |
def require(file) | |
@@first ||= Time.now | |
rc = false | |
ts = Benchmark.measure do | |
rc = super | |
end | |
if ENV['DEBUG_REQUIRE'].to_f < ts.total |
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
# First attempting to use Capybara directly, you will ran into issues when trying to set HTTP header. | |
# Using Basic HTTP Authentication requires that we needed to set the header. | |
# Also we need to set the Content-Type and Accept headers to ensure that Rails handles the input and output correctly. | |
# When using Rack, Capybara delegates request and response handling down to Rack::Test. | |
# So I used Rack::Test directly in my step definitions, and it works. | |
# Rack::Test has a module called Rack::Test::Methods that can be mixed into a class to provide it | |
# with methods for get, post, put, delete as well as last_request, last_response, header and more. | |
# I mixed Rack::Test::Methods into the Cucumber world at the top of our API steps file like so: | |
############################## |
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
# SSL self signed localhost for rails start to finish, no red warnings. | |
# 1) Create your private key (any password will do, we remove it below) | |
$ openssl genrsa -des3 -out server.orig.key 2048 | |
# 2) Remove the password | |
$ openssl rsa -in server.orig.key -out server.key |