I've been trying to understand how to setup systems from
the ground up on Ubuntu. I just installed redis
onto
the box and here's how I did it and some things to look
out for.
To install:
config.action_controller.asset_host = Proc.new do |source, request| | |
non_ssl_host = "http://asset#{source.hash % 4}.backpackit.com" | |
ssl_host = "https://asset1.backpackit.com" | |
if request.ssl? | |
case | |
when source =~ /\.js$/ | |
ssl_host | |
when request.headers["USER_AGENT"] =~ /(Safari)/ | |
non_ssl_host |
require 'rubygems' | |
require 'sinatra' | |
require 'fileutils' | |
# upload with: | |
# curl -v -F "data=@/path/to/filename" http://localhost:4567/user/filename | |
post '/:name/:filename' do | |
userdir = File.join("files", params[:name]) |
function(key, values, rereduce) { | |
Array.prototype.unique = function() { | |
var a = []; | |
var l = this.length; | |
for(var i=0; i<l; i++) { | |
for(var j=i+1; j<l; j++) { | |
// If this[i] is found later in the array | |
if (this[i] === this[j]) | |
j = ++i; | |
} |
# | |
# Cookbook Name:: delayed_job | |
# Recipe:: default | |
# | |
node[:applications].each do |app_name, data| | |
user = node[:users].first | |
case node[:instance_role] | |
when "solo", "app", "app_master" |
require 'oauth_util.rb' | |
require 'net/http' | |
o = OauthUtil.new | |
o.consumer_key = 'examplek9SGJUTUpocjZ5QjBJmQ9WVdrOVVFNHdSR2x1TkhFbWNHbzlNQS0tJnM9Y29uc3VtkZXJzZWNyZXQmeD0yYg--'; | |
o.consumer_secret = 'exampled88d4109c63e778dsadcdd5c1875814977'; | |
url = 'http://query.yahooapis.com/v1/yql?q=select%20*%20from%20social.updates.search%20where%20query%3D%22search%20terms%22&diagnostics=true'; |
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |
#!/usr/bin/env ruby | |
# Script to automate view and database compaction | |
# Based on CouchPotato and for use in a Rails project. | |
# Will only compact one view at a time to keep the load | |
# | |
# Installation: Drop into bin/ or script/ in your project. | |
# | |
# Usage: RAILS_ENV=development ./bin/couchdb_compact.rb | |
# | |
# Courtesy of your friendly folks at http://scalarium.com |
# note - you may need to split into a before-deploy (stop) and after-deploy (start) depending on your setup | |
desc "Hot-reload God configuration for the Resque worker" | |
deploy.task :reload_god_config do | |
sudo "god stop resque" | |
sudo "god load #{File.join deploy_to, 'current', 'config', 'resque.god'}" | |
sudo "god start resque" | |
end | |
after 'deploy:update_code', 'deploy:update_shared_symlinks' |
from time import strftime,gmtime,time | |
import urllib2 | |
import hmac | |
import hashlib | |
import base64 | |
import string | |
def publishAmazonSnsMsg(Subject,TopicArn,Message,AWSAccessKeyId,privatekey): | |
#http://docs.amazonwebservices.com/AWSSimpleQueueService/2008-01-01/SQSDeveloperGuide/ | |
amzsnshost = 'sns.us-east-1.amazonaws.com' |