This file contains hidden or 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 'rubygems' | |
require 'parslet' | |
class Address < Parslet::Parser | |
# Single character rules | |
rule(:comma) { str(',') >> space? } | |
rule(:space) { match('\s').repeat } | |
rule(:space?) { space.maybe } | |
rule(:newline) { str("\n").repeat } | |
rule(:digit) { match('[0-9]') } |
This file contains hidden or 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 | |
# This script parses US mailing addresses. | |
# | |
# For development, execute this from the command line to run the test cases. | |
# | |
# For production, just require the file, then: | |
# address_hash = AddressParser.new.parse(input_string) | |
require 'rubygems' |
This file contains hidden or 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 | |
# This script parses US mailing addresses. | |
# | |
# For development, execute this from the command line to run the test cases. | |
# | |
# For production, just require the file, then: | |
# address_hash = AddressParser.new.parse(input_string) | |
require 'rubygems' |
This file contains hidden or 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
<h2>Log In</h2> | |
<%= form_tag sessions_path do %> | |
<div class="field"> | |
<%= label_tag :user_name %><br> | |
<%= text_field_tag :user_name, params['user_name'] %> | |
</div> | |
<p></p> | |
<div class="field"> | |
<%= label_tag :password %><br/> |
This file contains hidden or 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
class SessionsController < ApplicationController | |
def new | |
if member = Member.find_by_password_digest(cookies[:digest]) | |
session[:member_id] = member.id | |
redirect_to (session[:ref] || root_path), :notice => "Welcome back #{member.first_name}" | |
end | |
end | |
def create |
This file contains hidden or 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
class ApplicationController < ActionController::Base | |
protect_from_forgery | |
def current_ability | |
@current_ability ||= Ability.new(current_member) | |
end | |
rescue_from CanCan::AccessDenied do |exception| | |
flash[:alert] = "Access Denied." | |
redirect_to root_url |
This file contains hidden or 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 'faye' | |
abort "Usage: #{$0} <url> <channel> <nick>" if ARGV.length != 3 | |
$url, $channel, $nick = ARGV | |
$client = Faye::Client.new($url) |
This file contains hidden or 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 'spreadsheet' | |
book = Spreadsheet.open 'input.xls' | |
sheet = book.worksheet 0 | |
sheet[0,0] = "Changed Cell" | |
book.write 'output.xls' |
This file contains hidden or 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 'spreadsheet' | |
book = Spreadsheet.open 'input.xls' | |
sheet = book.worksheet 0 | |
sheet[0,0] = "Changed Cell" | |
book.write 'output.xls' |
This file contains hidden or 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
# The mail servers of many SMS gateways treat email as spam if the mails | |
# arrive too frequently. This has happened using the SMS-gateways managed | |
# by Verizon and Sprint. | |
# | |
# Maintains a queue of delivery addresses for a given carrier. | |
# Limits the sending frequency, to reduce the chance of being rejected as spam. | |
# | |
class CarrierQueue |