Skip to content

Instantly share code, notes, and snippets.

@rmascarenhas
rmascarenhas / repeat.sh
Created September 2, 2012 16:04
repeat a command in bash
#!/usr/bin/env bash
# repeat.sh
#
# Usage:
# repeat <command>
# will repeat <command> forever.
#
# repeat -nN <command>
# will repeat <command> N times.
@rmascarenhas
rmascarenhas / wf.sh
Created September 16, 2012 23:01
Word-frequency calculator. Can be used standalone or in pipelines.
#!/usr/bin/env bash
# Word-frequency.
# Usage:
#
# $ wf [-ni] file.txt [file1.txt file2.txt ...]
#
# You can choose to display just the first [n] most frequent words.
#
# $ wf -n2 file.txt
@rmascarenhas
rmascarenhas / ds.rb
Created September 19, 2012 19:57
delivery strategy
class TagSubscription < ActiveRecord::Base
belongs_to :delivery_strategy
end
class DeliveryStrategy < ActiveRecord::Base
# Attributes:
# type: can be 'real_time', 'daily' or 'weekly'
# day: contain the day of the week
# time: the time of the day (morning, afternoon, night)
#
has_many :tag_subscriptions
@rmascarenhas
rmascarenhas / email_renderer.rb
Created September 26, 2012 21:45
EmailRenderer
require 'config/environment'
class EmailRenderer
class_inheritable_accessor :view_paths
self.view_paths = ["."]
def template
@template ||= initialize_template
end
@rmascarenhas
rmascarenhas / undo.sh
Created November 16, 2012 02:19
Undoing your last command
# undo: reverts the last command, as long as there is a registered handler
# for it.
#
# Usage:
#
# $ undo
#
# There are no options.
#
# There are by default registered handlers for the following commands: