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
extension String { | |
var blank: Bool { | |
get { | |
let trimmed = self.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet()) | |
return trimmed.isEmpty | |
} | |
} | |
var present: Bool { | |
get{ |
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
## Rake task test cheat sheet | |
require "rails_helper" | |
require "rake" | |
describe "cleanup" do | |
before :all do | |
Rake.application.rake_require "tasks/cleanup" |
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
@NgComponent( | |
selector: 'my-component', | |
template: '<div ng-include="{{cmp.templateURL}}"></div>', | |
publishAs: 'cmp' | |
) | |
class MyComponent { | |
String get templateURL => 'packages/project/components/my_component.html'; | |
} |
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
def show_me_a_screenshot | |
if Capybara.current_driver == :webkit | |
name = "screen-shot-#{Time.now.strftime('%Y-%m-%d-%H-%M-%S')}.png" | |
tmp_dir = File.join(Rails.root, 'tmp') | |
FileUtils.mkdir_p tmp_dir | |
file_name = File.join(tmp_dir, name) | |
page.driver.save_screenshot file_name | |
Launchy.open file_name | |
end | |
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
module Slugger | |
extend ActiveSupport::Concern | |
included do | |
validates :title, uniqueness: true, | |
presence: true, | |
length: 3..50 | |
validates :slug, presence: true, | |
format: { with: /\A[a-zA-Z0-9-]+\z/ } | |
NewerOlder