Dezember 2, 2011 at 12:49 pm · Filed under Rails, Ruby
Sometimes you need to save a locally created file to S3 instead of an uploaded file (the standard). Here is how:
has_attached_file :tagged_text_file, STORAGE_OPTIONS.merge({
:processors => []
})
...
def save_tagged_text_file
file = File.open("#{RAILS_ROOT}/tmp/tagged_text_#{id}.txt", 'w+')
file << tagged_text
self.tagged_text_file = file
save!
file.close
end
Dezember 2, 2011 at 12:46 pm · Filed under Allgemein
SSH tunneling is, of course, useful for a ton of services, but I happened to stumble upon it, when I wanted to connect to a remote redis server.
If you have a redis server running on [remotehost], you can easily connect
to it (given you have ssh access to it, of course) via:
ssh -L 9999:localhost:6379 [remoteuser]@[remotehost]
This will open a tunnel from the remote port 6379 (redis standard) to your local port 9999.
You can now use the redis on your local port 9999 like you would if it was running locally. Nice.