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
| <% a = File.open("db/schema.rb") %> | |
| <% a.each do |out| %> | |
| <% if out.scan(/\s\s\s\st.[a-z]{1,12}\s{1,6}"(.*?)\"/) %> | |
| <% if out.scan(/\s\s\s\st.[a-z]{1,12}\s{1,6}"(.*?)\"/).join(', ') == 'created_at' || out.scan(/\s\s\s\st.[a-z]{1,12}\s{1,6}"(.*?)\"/).join(', ') == 'updated_at' %> | |
| <% else %> | |
| :<%= out.scan(/\s\s\s\st.[a-z]{1,12}\s{1,6}"(.*?)\"/).join(', ') %>, | |
| <% end %> | |
| <% elsif out.scan(/\s\s\s\st.[a-z]{1,12}\s{1,6}"(.*?)\"\n\s\send/)%> | |
| <% if out.scan(/\s\s\s\st.[a-z]{1,12}\s{1,6}"(.*?)\"\n\s\send/).join(', ') == 'created_at' || out.scan(/\s\s\s\st.[a-z]{1,12}\s{1,6}"(.*?)\"\n\s\send/).join(', ') == 'updated_at' %> | |
| <% else %> |
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 card_number_format | |
| case card_type.downcase | |
| when 'visa' | |
| /^4\d{3}\d{4}\d{4}\d{4}$/ | |
| when 'mastercard' | |
| /^5[1-5]\d{2}\d{4}\d{4}\d{4}$/ | |
| when 'american express' | |
| /^3[4,7]\d{13}$/ | |
| 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
| Ruby function for delete leading and trailing white-spaces: | |
| 2.1.5 :001 > " clean up my edges ".strip | |
| => "clean up my edges" | |
| Regex for trailing white-spaces: | |
| [ \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
| class MailersController < Admin::BaseController | |
| def render_layout | |
| # received params | |
| # params[:mailer_type] | |
| # params[:email_template] | |
| # params[:email_format] | |
| mailer_type = params[:mailer_type].camelize | |
| mailer_template = params[:email_template] | |
| type_class = mailer_type.classify.safe_constantize |
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
| $('.icon-menu').click(function() { | |
| $('.menu').animate({ | |
| left: "0px" | |
| }, 200); | |
| $('body').animate({ | |
| left: "285px" | |
| }, 200); | |
| }); |
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
| <% if object and object.errors.any? %> | |
| <div class="error_explanation"> | |
| <h2><%= pluralize(object.errors.count, "error") %> prohibited this <%= object.class.model_name.human.downcase %> from being saved:</h2> | |
| <ul> | |
| <% object.errors.full_messages.each do |msg| %> | |
| <li>* <%= msg %></li> | |
| <% end %> | |
| </ul> | |
| </div> |
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
| Open Rails console in jruby: | |
| jruby -S bundle exec rails console | |
| jRuby RailsCast | |
| http://railscasts.com/episodes/376-jruby-basics |
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
| <div data-bind="text: fqdn5() === '' ? 'Default Value' : fqdn5 "></div> |
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
| If you have attempted to install the Nokogiri gem and encountered errors similar to the output below… I feel your pain and have a solution. | |
| The Pain | |
| ➜ z gem install nokogiri Building native extensions. This could take a while... ERROR: Error installing nokogiri: ERROR: Failed to build gem native extension. | |
| /Users/mariozig/.rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20150318-11691-1hlore5.rb extconf.rb | |
| checking if the C compiler accepts ... yes | |
| checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no | |
| Building nokogiri using packaged libraries. | |
| checking for gzdopen() in -lz... yes |
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
| https://www.rocketmarketinginc.com/blog/get-never-expiring-facebook-page-access-token/ | |
| additional 3.3.1 |