This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "date" | |
class Todo | |
attr_accessor :complete | |
attr_reader :name, :due_on | |
def initialize(name, due_on=nil, complete=false) | |
@name = name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rb-inotify' | |
notifier = INotify::Notifier.new | |
notifier.watch("/path/to/watch", :moved_to, :create) do |event| | |
puts "I found #{event.name}!" | |
end | |
notifier.run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'machinist/mongomapper' | |
require 'sham' | |
require 'faker' | |
Sham.define do | |
username { Faker::Internet.user_name } | |
email { Faker::Internet.email } | |
# confirmed_at { ...date... } | |
# confirmation_sent_at { ...date... } | |
# remember_token { 'Cj4ja2A3Xp6MEK6rdUej' } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'basic_daemon' | |
class MyDaemon < BasicDaemon | |
def run | |
foo = open("/tmp/out", "w") | |
i = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'basic_daemon' | |
basedir = "/tmp" | |
d = BasicDaemon.new | |
# for restarts to work properly, you can't use anonymous blocks. In other |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# requires and stuff go here | |
def load_irbrc(path) | |
return if (path == ENV["HOME"]) || (path == '/') | |
load_irbrc(File.dirname path) | |
irbrc = File.join(path, ".irbrc") | |
load irbrc if File.exists?(irbrc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'date' | |
(Date.new(year, 12, 31) << (12-month)).day # Ruby 1.8.x | |
Date.new(2010, 12, 31).prev_month(12 - 4).day # Ruby 1.9.x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="message-popdown" class="grid_12"> | |
<% if flash[:error_msg] %> | |
<span class="error-msg"><%= flash[:error_msg] %></span> | |
<% elsif flash[:success_msg] %> | |
<span class="success-msg"><%= flash[:success_msg] %></span> | |
<% elsif flash[:warning_msg] %> | |
<span class="warning-msg"><%= flash[:warning_msg] %></span> | |
<% elsif flash[:message] %> | |
<span class="notice-msg"><%= flash[:message] %></span> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#message-popdown { | |
background-color: #dea852; | |
display: none; | |
position: fixed; | |
z-index: 999; | |
cursor: pointer; | |
padding-top: 20px; | |
padding-bottom: 20px; | |
-webkit-border-bottom-right-radius: 10px; | |
-webkit-border-bottom-left-radius: 10px; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (!RegExp(/^\s*$/).test($("#message-popdown").html())) { | |
$("#message-popdown").slideDown("slow", function() { | |
var that = $(this); | |
setTimeout(function() {that.slideUp();}, 5000); | |
}); | |
} | |
$("#message-popdown").click(function() { | |
$(this).slideUp(); | |
}); |
OlderNewer