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 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/ } | |
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
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 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 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 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 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
//use whatever activity view makes you happy in this project we were converting from ObjC to Swift, #2016 | |
protocol ActivityVC: class { | |
var activityView: DejalBezelActivityView? { get set } | |
var view: UIView! { get } | |
} | |
extension ActivityVC { | |
mutating func activityStart() { | |
if activityView == nil { | |
activityView = DejalBezelActivityView(forView: view, withLabel: nil, width: 40) |
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
// copy and paste into play ground | |
import UIKit | |
protocol ListViewModel { | |
associatedtype T:Comparable | |
var items: [T] { get set } | |
mutating func clear() | |
func item(forIndex index: NSIndexPath) -> T |
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
defmodule Splife.Bar do | |
use Splife.Web, :model | |
schema "bars" do | |
field :baz, :string | |
field :fizz, :string | |
timestamps() | |
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
// | |
// String.swift | |
// MyModule | |
// | |
// Created by Shaun Hubbard on 10/9/17. | |
// Copyright © 2017 MyCompany, LLC. All rights reserved. | |
// | |
import Foundation |
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
// I needed to make a gist to show some things off and whats nots | |
import Foundation | |
enum HttpMethod: String { | |
case get = "GET" | |
case post = "POST" | |
case patch = "PATCH" | |
case delete = "DELETE" | |
} |
OlderNewer