Skip to content

Instantly share code, notes, and snippets.

View harssh-sparkway's full-sized avatar

harssh-sparkway

View GitHub Profile
@harssh-sparkway
harssh-sparkway / sublime_packages.html
Created January 31, 2014 08:45
Sublime useful packages
12 SublimeERb
TextMate Style ERB Block for Sublime Text
https://github.com/eddorre/SublimeERB
11. A Sublime Text 2/3 plugin to see git diff in gutter
http://www.jisaacks.com/gitgutter
10. Package control
@harssh-sparkway
harssh-sparkway / rails_logger_tricks.rb
Created January 31, 2014 07:18
Rails Logger Tricks
#Rails Logger Tricks
#Here are a few quick tricks for using the Rails logger.
#Save disk space by rotating logs in the config/environments/test.rb and config/environments/development.rb
config.logger = Logger.new(Rails.root.join("log",Rails.env + ".log"),3,5*1024*1024)
#which will rotate the log files every 5 megabytes and leave only the three most recent log files. This will limit the total spaces #used by the logs at 15 megabytes.
#To log to STDOUT while using the console use this trick:
@harssh-sparkway
harssh-sparkway / dry.rb
Last active July 7, 2022 23:33
Don’t Repeat Yourself (DRY) in Ruby on Rails
#Don’t Repeat Yourself (DRY) in Ruby on Rails
#DRY (Don’t Repeat Yourself) is a principle of Software Development to reducing repetition of information or codes. We can #apply DRY quite broadly to database schema, test plan, system, even documentation. And in this post, we will take example of DRY #in Ruby on Rails development.
#In particular case, if you find some methods whose definitions are more or less similar, only different by the method name, it #may use meta programming to simplify the things to make your model more clean and DRY. Consider this simple example where we #have an article with three states.
#Before
class Article < ActiveRecord::Base