Skip to content

Instantly share code, notes, and snippets.

@RanjitReddy
RanjitReddy / custom_logger.rb
Created November 16, 2016 08:57 — forked from kinopyo/custom_logger.rb
Custom logger file in Rails
# lib/custom_logger.rb
class CustomLogger < Logger
def format_message(severity, timestamp, progname, msg)
"#{timestamp.to_formatted_s(:db)} #{severity} #{msg}\n"
end
end
logfile = File.open("#{Rails.root}/log/custom.log", 'a') # create log file
logfile.sync = true # automatically flushes data to file
CUSTOM_LOGGER = CustomLogger.new(logfile) # constant accessible anywhere
@RanjitReddy
RanjitReddy / MySQL_practice_problems.md
Created February 20, 2023 06:38 — forked from wgopar/MySQL_practice_problems.md
MySQL Employees Sample Database exercise problems + solutions.

MySQL practice problems using the Employees Sample Database along with my solutions. See here for database installation details.

Problem 1

Find the number of Male (M) and Female (F) employees in the database and order the counts in descending order.

SELECT gender, COUNT(*) AS total_count
FROM employees 
GROUP BY gender