Skip to content

Instantly share code, notes, and snippets.

View Kalaivanimurugan's full-sized avatar

Kalaivani Murugan Kalaivanimurugan

  • Spritle Software
  • Chennai
View GitHub Profile
@Kalaivanimurugan
Kalaivanimurugan / production.rb
Created May 9, 2018 12:03
Log Rotation in Rails
config.logger = Logger.new(config.paths["log"].first, 5, 25.megabytes) # Keeps the Last 5 log files which are rotated at every 25MB
config.log_level = :error #in log file the errors only wriiten.
@Kalaivanimurugan
Kalaivanimurugan / git.txt
Created March 29, 2018 12:04
Get your git commits
git log --author="Kalaivani Murugan" // list your commits only
wb = xlsx_package.workbook #create excel book
wb.add_worksheet(name: "Stock Status") do |sheet|
sps_img = File.expand_path(Rails.root+'app/assets/images/sps_logo.png')
sheet.add_image(:image_src => sps_img, :end_at => true) do |image|
image.start_at 0, 0
image.end_at 3, 4
end
header = wb.styles.add_style({:alignment => {:horizontal => :center, :vertical => :center, :wrap_text => true}, :border => { :style => :thin, :color => "000000" }})
border = wb.styles.add_style({:border => { :style => :thin, :color => "000000" }})
align_right = wb.styles.add_style({:alignment => {:horizontal => :right}})
@Kalaivanimurugan
Kalaivanimurugan / display_model_names.rb
Last active December 1, 2023 21:13
List all model names in rails console
Rails.application.eager_load!
ActiveRecord::Base.descendants # It returns all models and its attributes.
ApplicationRecord.descendants.collect(&:name) # It returns only the model names
@Kalaivanimurugan
Kalaivanimurugan / date_range.rb
Last active December 19, 2017 05:15
Generate date range based on from and to date in Ruby
from = Date.parse("1-10-2017")
to = Date.parse("30-10-2017")
date_range = (from..to).map { |d| d }