This file contains 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
const restify = require('restify'); | |
const plugins = require('restify-plugins'); | |
const nodemailer = require('nodemailer'); | |
const ses = require('nodemailer-ses-transport'); | |
require('dotenv').config(); | |
const mailerTransport = nodemailer.createTransport(ses({ | |
accessKeyId: process.env.AWS_ACCESS_KEY_ID, | |
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY |
This file contains 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
RESTIFY_SEVER_PORT=8080 |
This file contains 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
.env |
This file contains 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
const restify = require('restify'); | |
const plugins = require('restify-plugins'); | |
require('dotenv').config() | |
const server = restify.createServer(); | |
server.use(plugins.acceptParser(server.acceptable)); | |
server.use(plugins.bodyParser()); |
This file contains 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
const restify = require('restify'); | |
const plugins = require('restify-plugins'); | |
const server = restify.createServer(); | |
server.use(plugins.acceptParser(server.acceptable)); | |
server.use(plugins.bodyParser()); | |
server.post('/sum', (req, res, next) => { | |
res.send(200, req.body.reduce((a, b) => a + b, 0)); |
This file contains 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
{ | |
"name": "sum12factor", | |
"version": "1.0.0", | |
"description": "sum12factor", | |
"main": "index.js", | |
"scripts": { | |
"test": "node test" | |
}, | |
"author": "Guilherme Viebig <[email protected]>", | |
"license": "ISC", |
This file contains 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
sudo yum install unzip python-pip -y && \ | |
wget https://github.com/s3tools/s3cmd/archive/master.zip && \ | |
unzip master.zip && \ | |
cd s3cmd-master && \ | |
sudo python setup.py install && \ | |
cd .. && \ | |
s3cmd --configure | |
# Pipe example | |
# mysqldump ... | s3cmd put - s3://bucket/file-name.sql |
This file contains 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
#!/bin/bash | |
args=("$@") | |
token=${args[0]} | |
number=${args[1]} | |
message=${args[2]} | |
numbers=(${number//,/ }) | |
for i in "${!numbers[@]}" |
This file contains 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 Promise = require('bluebird'); | |
function sleep(milliseconds) { | |
var start = new Date().getTime(); | |
for (var i = 0; i < 1e7; i++) { | |
if ((new Date().getTime() - start) > milliseconds){ | |
console.log(milliseconds) | |
return milliseconds | |
break; | |
} |
This file contains 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 assert = require('assert'); | |
var fs = require('fs'); | |
var restify = require('restify'); | |
var server = restify.createServer(); | |
server.put('/:name', function (req, res, next) { | |
var stream = fs.createWriteStream('/tmp/' + req.params.name); | |
req.pipe(stream); | |
req.once('end', function () { |