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 CustomiseDevise | |
extend ActiveSupport::Concern | |
included do | |
attr_accessor :project_name, :mailer_host_name, :confirmation_required, :confirmation_type | |
after_create :send_confirmation_instructions, if: :confirmation_required? | |
class_eval do | |
def confirmation_required? | |
!!confirmation_required |
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 AdminGenerator < Rails::Generators::Base | |
argument :name, type: :string | |
source_root File.expand_path('../templates', __FILE__) | |
desc "Generates required files." | |
def copy_controller_and_spec_files | |
@model = name.to_s.constantize | |
@attributes = @model.attribute_names.reject{|c| c.match(/^_id/)}.map(&:to_sym) | |
template "resource.rb", "app/admin/#{name.underscore}.rb" | |
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
t = 270921 | |
mm, ss = t.divmod(60) #=> [4515, 21] | |
hh, mm = mm.divmod(60) #=> [75, 15] | |
dd, hh = hh.divmod(24) #=> [3, 3] | |
puts "%d days, %d hours, %d minutes and %d seconds" % [dd, hh, mm, ss] | |
#=> 3 days, 3 hours, 15 minutes and 21 seconds |
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
ELASTICSEARCH_URL=https://**** | |
AWS_REGION=**** | |
AWS_ACCESS_KEY_ID=**** | |
AWS_SECRET_ACCESS_KEY=**** |
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
client = Mongo::Client.new([ '127.0.0.1:27017' ], :database => 'database name') | |
client.collections.map {|c| puts c.namespace.gsub('database name.','') }.count |
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
var data = []; | |
$("#content table tbody tr").each(function() { | |
timezone = {}; | |
$(this).find('td').each(function(index) { | |
if (index == 0) { | |
timezone['countryCode'] = $(this).html(); | |
} else if (index == 1) { | |
timezone['countryName'] = $(this).html(); | |
} else if (index == 2) { | |
timezone['zoneName'] = $(this).find('a').html(); |
OlderNewer