This file contains hidden or 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
$ s3cmd get s3://us-east-1.elasticmapreduce/libs/s3distcp/1.latest/s3distcp.jar | |
$ hadoop jar ./s3distcp.jar --src s3a://<bucket>/input/ --dest=s3a://<bucket>/output |
This file contains hidden or 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
$ wget http://ufpr.dl.sourceforge.net/project/s3tools/s3cmd/1.6.1/s3cmd-1.6.1.tar.gz | |
$ tar xzf s3cmd-1.6.1.tar.gz | |
$ cd s3cmd-1.6.1 | |
$ sudo python setup.py install | |
$ ./s3cmd --configure | |
# Add in your Access and secret keys | |
# Enter through the remaining prompts | |
# Save configuration |
This file contains hidden or 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
# in you sites-available files | |
# gzip all asset requests | |
location ^~ /assets/ { | |
gzip_static on; | |
expires max; | |
add_header Cache-Control public; | |
add_header Access-Control-Allow-Origin *; | |
} | |
location ~* ^.+\.(jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|mp3|flv|mpeg|avi|eof|ttf|woff|woff2)$ { |
This file contains hidden or 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
config.middleware.insert_before 0, "Rack::Cors" do | |
allow do | |
origins '*' | |
resource '*', :headers => :any, :methods => [:get, :post, :options] | |
end | |
end |
This file contains hidden or 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
nano /etc/ssh/sshd_config # change PermitRootLogin to no and PasswordAuthentication to no | |
sudo service ssh restart | |
sudo apt-get update | |
sudo apt-get install ntp ufw git fail2ban default-jre nodejs | |
sudo dpkg-reconfigure tzdata | |
sudo ufw default deny incoming | |
sudo ufw default allow outgoing | |
sudo ufw allow 22/tcp | |
sudo ufw allow 80/tcp | |
sudo ufw allow 443/tcp |
This file contains hidden or 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 g scaffold email from:string body:text to:string subject:string |
This file contains hidden or 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 EmailsController < ApplicationController | |
## | |
# Receive the AWS post, validate the token and pass to our model method | |
def incoming | |
if params[:token] && (params[:token] == 'test_token') | |
@email = Email.process_incoming_email(params[:message_id]) | |
if @email.valid? | |
render text: 'email created', status: :created | |
else |
This file contains hidden or 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 Email < ActiveRecord::Base | |
def self.process_incoming_email(message_id) | |
obj = AWS::S3.new.buckets['my-email-bucket'].objects[message_id] | |
contents = obj.read | |
from = contents.match(/(?<=From: )(.*?)(?=\n)/).try(:to_s) | |
to = contents.match(/(?<=To: )(.*?)(?=\n)/).try(:to_s) | |
subject = contents.match(/(?<=Subject: )(.*?)(?=\n)/).try(:to_s) | |
body = contents.match(/(?<=Content-Type: text\/html; charset\=UTF-8)(.*?)(?=--)/m).try(:to_s) | |
self.create( |
This file contains hidden or 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
config.before do | |
WebMock.disable_net_connect!(allow_localhost: true) | |
stub_request(:get, "https://my-email-bucket.s3.amazonaws.com/test") | |
.to_return(status: 200, body: File.read('spec/support/lambda_email')) | |
end |
This file contains hidden or 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
var AWS = require('aws-sdk'); | |
var https = require('https'); | |
exports.handler = function(event, context) { | |
var sesNotification = event.Records[0].ses; | |
var messageId = sesNotification.mail.messageId; | |
var receipt = sesNotification.receipt; | |
var from = sesNotification.mail.commonHeaders.from[0]; | |
var appUrl = 'https://www.example.com' |
NewerOlder