Skip to content

Instantly share code, notes, and snippets.

View karuppasamy's full-sized avatar
🎯
Focusing

Karuppasamy M karuppasamy

🎯
Focusing
  • Cognizant
  • Belfast, NI
View GitHub Profile
@karuppasamy
karuppasamy / sublime-linter-settings
Created May 4, 2016 16:00
Sublime - Linter Settings
{
"user": {
"debug": false,
"delay": 0.25,
"error_color": "D02000",
"gutter_theme": "Packages/SublimeLinter/gutter-themes/Default/Default.gutter-theme",
"gutter_theme_excludes": [],
"lint_mode": "background",
"linters": {
"eslint": {
@karuppasamy
karuppasamy / i18n_yaml_sort.rb
Created March 8, 2016 15:50
Sort I18n yaml files
# Recursive sorting algorithm for Hash
class Hash
def sort_by_key(recursive = false, &block)
self.keys.sort(&block).reduce({}) do |seed, key|
seed[key] = self[key]
if recursive && seed[key].is_a?(Hash)
seed[key] = seed[key].sort_by_key(true, &block)
end
seed
@karuppasamy
karuppasamy / calculate_duration.rb
Created March 8, 2016 03:06
ruby - number of months between dates
(end_date.year * 12 + end_date.month) - (start_date.year * 12 + start_date.month) + (end_date.day >= start_date.day ? 1 : 0)
class DoNotDisturb
def initialize
@desk = InformationDesk.new
end
def method_missing(name, *args)
unless name.to_s == "emergency"
hour = Time.now.hour
raise "Out for lunch" if hour >= 12 && hour < 14
end