Skip to content

Instantly share code, notes, and snippets.

@doooby
doooby / info.md
Last active August 29, 2015 14:13
Direct (POST) uploading to AWS S3 using aws-sdk gem

Direct uploading to AWS S3

Since there are new regions of Amazon S3 services that accepts only Signature v4 (e.g. frankfurt) you cannot use aws-sdk-v1 gem's #presigned_url functionality. And newer aws-sdk gem (beeing stil in preview for 2.x) doesn't have a functionality to do direct uploading either. Here's my inplementation of that functionality, build on top of aws-sdk v2.0.16.pre and jquery (it's using some javascript stuff that older browsers won't support though).

For some basic information see this Heroku's Direct to S3 Image Uploads in Rails article https://devcenter.heroku.com/articles/direct-to-s3-image-uploads-in-rails . A "how to" by Amazaon itself in Authenticating Requests in Browser-Based Uploads Using POST (AWS Signature Version 4) http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-UsingHTTPPOST.html (notice beelow are subsections of details, like how to create signing policy).

An exapmle for simultaneous multiple images browser-based uploading

So, I build it the way,

@dominicsayers
dominicsayers / elasticsearch.md
Last active March 2, 2024 15:52
Configuring ElasticSearch to use less memory

What I actually did

/etc/security/limits.conf

elasticsearch hard memlock 100000

/etc/default/elasticsearch

@aserafin
aserafin / resque.rake
Created October 10, 2013 10:10
clear all resque tasks from redis
desc "Clear pending tasks"
task "resque:clear" => :environment do
queues = Resque.queues
queues.each do |queue_name|
puts "Clearing #{queue_name}..."
Resque.redis.del "queue:#{queue_name}"
end
puts "Clearing delayed..." # in case of scheduler - doesn't break if no scheduler module is installed
Resque.redis.keys("delayed:*").each do |key|
@mguymon
mguymon / demo_stomplet.rb
Created May 25, 2013 19:06
Demo Stomplet that shows how to use a session token for auth
require 'torquebox-stomp'
class DemoStomplet
def initialize()
super
@subscribers = []
# passthrough for local messages to skip auth
@passthrough_code = "e32f53ac7569ae3a1f692177"
end
@shmatov
shmatov / deploy.rake
Created November 15, 2012 13:17
rails + mina + unicorn
# lib/tasks/deploy.rake
namespace :deploy do
desc 'Deploy to staging environment'
task :staging do
exec 'mina deploy -f config/deploy/staging.rb'
end
end
@rnhurt
rnhurt / dynamodb.rake
Created October 29, 2012 16:32
Rake task to manage DynamoDB tables
namespace :dynamodb do
desc "Create DynamoDB tables"
task :create => :environment do
puts "Creating tables in the #{Rails.env} environment..."
Rails.application.eager_load! # Force the loading of modules
prefix = AWS::Record.table_prefix # Table name prefix
tables = AWS::DynamoDB.new.tables # Create an AWS connection
@mikhailov
mikhailov / 0. nginx_setup.sh
Last active April 2, 2024 14:57
NGINX+SPDY with Unicorn. True Zero-Downtime unless migrations. Best practices.
# Nginx+Unicorn best-practices congifuration guide. Heartbleed fixed.
# We use latest stable nginx with fresh **openssl**, **zlib** and **pcre** dependencies.
# Some extra handy modules to use: --with-http_stub_status_module --with-http_gzip_static_module
#
# Deployment structure
#
# SERVER:
# /etc/init.d/nginx (1. nginx)
# /home/app/public_html/app_production/current (Capistrano directory)
#
@olivierlacan
olivierlacan / sublime-text-2-settings.json
Last active January 11, 2024 15:38
Basic Sublime Text 2 settings for Rails development
{
"use_simple_full_screen": false,
// calculates indentation automatically when pressing enter
"auto_indent": true,
// sets the colors used within the text area (default)
// see https://github.com/olivierlacan/monokaim to download
// the customized Monokai I use.
"color_scheme": "Packages/Color Scheme - Default/Monokaim.tmTheme",
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=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')