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
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(); |
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
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 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 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 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 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 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
GrapeSwaggerRails.options.url = '/api/v1/apis_doc.json' | |
GrapeSwaggerRails.options.before_action do | |
GrapeSwaggerRails.options.app_url = request.protocol + request.host_with_port | |
end | |
GrapeSwaggerRails.options.app_name = 'Service Name' | |
GrapeSwaggerRails.options.api_auth = 'basic' # Or 'bearer' for OAuth | |
GrapeSwaggerRails.options.api_key_name = 'Authorization' | |
GrapeSwaggerRails.options.api_key_type = 'header' | |
GrapeSwaggerRails.options.doc_expansion = 'list' |
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
# config/initializers/rails_admin_delete_override.rb | |
module RailsAdmin | |
module Config | |
module Actions | |
class Delete < RailsAdmin::Config::Actions::Base | |
RailsAdmin::Config::Actions.register(self) | |
register_instance_option :visible? do | |
!bindings[:object].respond_to?(:destroyable?) || bindings[:object].destroyable? | |
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
Searchkick.class_eval do | |
# Your new methods here | |
def self.load_records(records, ids) | |
records = | |
if records.respond_to?(:queryable) | |
# Mongoid 3+ | |
records.queryable.for_ids(ids) | |
elsif records.respond_to?(:primary_key) | |
# ActiveRecord | |
records.where(records.primary_key => ids) if records.primary_key |
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
rails_root = Rails.root || File.dirname(__FILE__) + '/../..' | |
rails_env = Rails.env || 'development' | |
redis_config = YAML.load(ERB.new(File.read("#{Rails.root}/config/redis.yml")).result)[rails_env] | |
redis_config.symbolize_keys! | |
Sidekiq.configure_server do |config| | |
config.redis = { url: "redis://#{redis_config[:host]}:#{redis_config[:port]}/12" } | |
end | |
Sidekiq.configure_client do |config| |
NewerOlder