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
class ActionMailer::Base | |
# Using this on staging server: never send emails to actual people. | |
# (Ocassionaly pulling live data into staging server) | |
def perform_delivery_safemail(mail) | |
addr = mail.to_addrs.first | |
mail.to = %{"#{addr.name || addr.address}" <test@... your email ...>} | |
perform_delivery_sendmail mail | |
end | |
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
class ActionMailer::Base | |
# We're using the SendGrid SMTP API to send emails to a large distribution | |
# list. During testing, we want to validate that each recipient received a | |
# copy of the email. Do that by looking for emails sent to a distribution | |
# list and creating multiple copies, one for each recipient. | |
def perform_delivery_test(mail) | |
mail.ready_to_send # All duplicates must have same message id | |
smtpapi = JSON.parse(mail["X-SMTPAPI"].to_s) if mail["X-SMTPAPI"] | |
if smtpapi && smtpapi["to"] | |
mail.delete "X-SMTPAPI" |
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 "resque" | |
require "resque/failure/multiple" | |
require "resque/failure/redis" | |
# Configure Resque connection from config/redis.yml. This file should look | |
# something like: | |
# development: localhost:6379 | |
# test: localhost:6379:15 | |
# production: localhost:6379 | |
Resque.redis = YAML.load_file(Rails.root + 'config/redis.yml')[Rails.env] |
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
# Rails 2.3 metal file to incorporate Resque Web UI inside Rails application. | |
# Uses HTTP Basic Authentication, until I can figure out how to get Authlogic | |
# working here. Accepts only users listed in ADMINS. | |
require "resque/server" | |
# since Authlogic is not keeping up, see http://github.com/binarylogic/authlogic/issuesearch?state=open&q=sinatra#issue/80 | |
class Sinatra::Request | |
def self.before | |
end | |
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
# Allows something like: | |
# map.admin "/:action/:id", controller: :admin, conditions: { host: "admin.example.com" } | |
module ActionController | |
module Routing | |
class RouteSet | |
def extract_request_environment(request) | |
{ method: request.method, host: request.host } | |
end | |
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
start on runlevel [2345] | |
stop on runlevel [06] | |
chdir /var/app/current | |
exec run_bundle unicorn -c config/unicorn.rb -E production | |
post-start script | |
sleep 5 | |
rm -f /var/app/shared/system/maintenance.html | |
end script |
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
Sinatra is already a tested and proven development option and we plan to continue our quest to make Sinatra development so flexible that it can be used for the smallest one line app or an advanced e-commerce consumer site without sacrificing what makes the development experience so pleasant. |
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
z = require("./src/index") | |
z.listen null, (err)-> | |
console.log "Listening" | |
console.log err if err | |
requests =[ | |
"*1\r\n$7\r\nBROWSER", | |
"*3\r\n$5\r\nVISIT$1\r\n0$20\r\nhttp://labnotes.org/", | |
"*2\r\n$4\r\nWAIT$1\r\n0" |
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
rescue_from = {} | |
# Associate status code with an HTTP status code. First argument is the status | |
# code, second argument is a function that accepts the XHR object. For example: | |
# $.rescueFrom 404, (xhr)-> alert("Oh no, page not found!") | |
$.rescueFrom = (status, fn)-> | |
rescue_from[status] = fn | |
# Default handling for unsuccessulf HTTP status code. Finds and calls most | |
# appropriate handler based on the HTTP status code (see `$.rescueFrom`). |
OlderNewer