Skip to content

Instantly share code, notes, and snippets.

@awd
awd / gist:1529838
Created December 28, 2011 21:28 — forked from datwright/gist:1355453
SOCKS Proxy for remote FTP server
OH NO! It turns out that simple one-port SSH Tunnels won't work for FTP since it uses another random port to actually transfer data. No problem! SOCKS Proxy to the rescue!
This assumes that you have SSH access to a server that can successfully connect to the FTP server you want access to.
On your local execute (if you have a woople ssh alias setup):
ssh -ND 1234 woople
You'll need an FTP client that supports SOCKS Proxies. I recommend Filezilla. Enter localhost:1234 as your SOCKS proxy server and connect to the FTP server using its regular internet address (as though you were connecting from your production server). SWEEEET!
def search_cache
@search_cache ||= Sunspot.search [Course, Channel, Episode] do
keywords(query)
any_of do
with(:channel_id, accessible_channel_ids)
with(:course_id, accessible_course_ids)
with(:episode_id, accessible_episode_ids)
end
paginate(:page => current_page)
end
@awd
awd / org.apache.solr.plist
Created October 27, 2011 14:40 — forked from santosh79/solr.plist
org.apache.solr.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.apache.solr</string>
<key>OnDemand</key>
<true/>
<key>ProgramArguments</key>
<array>
@awd
awd / org.apache.solr.plist
Created October 27, 2011 14:34 — forked from gcachet/org.apache.solr.plist
plist to launch solr with launchd on mac os X
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC
"-//Apple Computer//DTD PLIST 1.0//EN" "
http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.apache.solr</string>
<key>ProgramArguments</key>
<array>
@awd
awd / migrate_paperclip_to_s3.rake
Created October 1, 2011 23:31
Migrate local paperclip assets to Amazon S3.
##
# Use this behind the scenes to migrate files from your filesystem to Amazon S3
# %: rake paperclip_migration:migrate_to_s3
##
namespace :attachments do
desc "migrate files from filesystem to s3"
task :migrate_to_s3 => :environment do
require 'aws/s3'
#
# Cookbook Name:: passenger_memory_increase
# Recipe:: default
#
if node.engineyard.environment.stack.passenger?
ey_cloud_report "passenger_memory_increase" do
message "processing passenger memory increase"
end
node.engineyard.apps.each do |app|
[Tue, 28 Jun 2011 12:55:51 -0700] INFO: Starting Chef Solo Run
/etc/chef-custom/recipes/cookbooks/passenger_memory_increase/recipes/default.rb:5:in `from_file': undefined method `environment' for #<Mash:0xb780fe28> (NoMethodError)
from /usr/local/ey_resin/ruby/lib/ruby/gems/1.8/gems/chef-0.6.0.2/lib/chef/cookbook.rb:139:in `load_recipe'
from /usr/local/ey_resin/ruby/lib/ruby/gems/1.8/gems/chef-0.6.0.2/lib/chef/recipe.rb:76:in `include_recipe'
from /usr/local/ey_resin/ruby/lib/ruby/gems/1.8/gems/chef-0.6.0.2/lib/chef/recipe.rb:63:in `each'
from /usr/local/ey_resin/ruby/lib/ruby/gems/1.8/gems/chef-0.6.0.2/lib/chef/recipe.rb:63:in `include_recipe'
from /usr/local/ey_resin/ruby/lib/ruby/gems/1.8/gems/chef-0.6.0.2/lib/chef/recipe.rb:82:in `require_recipe'
from /etc/chef-custom/recipes/cookbooks/main/recipes/default.rb:73:in `from_file'
from /usr/local/ey_resin/ruby/lib/ruby/gems/1.8/gems/chef-0.6.0.2/lib/chef/cookbook.rb:139:in `load_recipe'
from /usr/local/ey_resin/ruby/lib/ruby/gems/1.8/gems/chef-0.6.0.2
class ProgressiveContent
# additionally you could pass in arguments
# to help initialize a specific scope
def initialize
@generated = false
@test_response = false
end
# this method is used in the CSV Responder
class ProgressiveController < ApplicationController
def show
respond_to do |wants|
wants.csv {
render :csv => ProgressiveContent.new, :status => :ok
}
end
end
end
# this renderer allows the system to render progressively generated content
# rendering a proc was removed in Rails 3.0
ActionController::Renderers.add :csv do |detailed_report, options|
filename = detailed_report.to_filename
headers['Cache-Control'] = 'must-revalidate, post-check=0, pre-check=0'
headers['Content-Disposition'] = "attachment; filename=#{filename}"
headers['Content-Type'] = 'text/csv'
headers['Content-Transfer-Encoding'] = 'binary'