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
| class Fixnum | |
| def with_ordinals | |
| if (11..13).include?(self.abs % 100) | |
| 'th' | |
| else | |
| case self.abs % 10 | |
| when 1 then 'st' | |
| when 2 then 'nd' | |
| when 3 then 'rd' | |
| else 'th' |
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
| #!/usr/bin/env sh | |
| read -p 'File? ' file | |
| echo 'data:'$(file --mime-type -b $file)';base64,'$(base64 -i $file) | pbcopy |
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
| -----BEGIN PGP PUBLIC KEY BLOCK----- | |
| Version: GnuPG v1.4.12 (Darwin) | |
| mQENBFBEE/gBCACy6e3EeDEmPG97fQpzdzbU8LBGxPWaq3UVymbrQeYudlP10kvm | |
| EfR++wFT+9F5RR0pxZiGA5RxuDWQcEDfl9W/yZhg2on/phfLSXSDAt8mmWiWR6IG | |
| caUneLrEGe5FPiVcnAirV/3/WdkL3QFiqVdz307MvB4qPi8FfK3Ziez0mzLs939R | |
| wZduZfHVnU4+Ll1C7TF9LsyCS0o+DN5BpUF915QXTcaBk0IQhqr0Z5DAw7VOuzyP | |
| ljLguaJDgFviqIvljNvQc/Ju0ReGQS7uDU7LEa5sZbn/G/t8lpGr81deIfNvSWuM | |
| 9YgJACQb3foNj/zCOwpln+bsRalHqp4SfuanABEBAAG0QENlc2FyIEZpZ3Vlcm9h | |
| IChVc2VyIEludGVyZmFjZSBEZXNpZ25lcikgPGNlc2FyLmZpZ3Vlcm9hQG1lLmNv |
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
| property :created_at, DateTime, :writer => :private | |
| property :updated_at, DateTime, :writer => :private |
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
| document.addEventListener('DOMContentLoaded', function () { | |
| window.resizeBy(-window.innerWidth + 320, -window.innerHeight + 480); | |
| }); |
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
| class Length < Grape::Validations::SingleOptionValidator | |
| def validate_param!(attr_name, params) | |
| case @option | |
| when Integer | |
| unless params[attr_name].to_s.length == @option | |
| throw :error, :status => 400, | |
| :message => "#{attr_name} must be #{@option} characters long" | |
| end | |
| when Range | |
| unless @option.include?(params[attr_name].to_s.length) |
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
| class String | |
| def titleize | |
| self.downcase.split.map(&:capitalize).join(' ') | |
| 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 Subdomain | |
| class NoSubdomain | |
| def self.matches?(request) | |
| request.subdomain.blank? && request.subdomain != 'www' | |
| end | |
| end | |
| class API | |
| def self.matches?(request) | |
| request.subdomain == 'api' |
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
| class Hash | |
| def only(*keys) | |
| self.select { |key, _| keys.include?(key) } | |
| end | |
| def except(*keys) | |
| self.reject { |key, _| keys.include?(key) } | |
| 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
| EMAIL_ADDRESS = /\A[A-z0-9._%+-]+@[A-z0-9.-]+\.[A-z]{2,4}\z/ |
OlderNewer