Skip to content

Instantly share code, notes, and snippets.

View mooyoul's full-sized avatar
👨‍💻
working from somewhere

MooYeol Prescott Lee mooyoul

👨‍💻
working from somewhere
View GitHub Profile
@mooyoul
mooyoul / store-buffer.js
Created February 17, 2017 21:01
store-buffer.js
'use strict';
const request = require('request');
const AWS = require('aws-sdk');
const s3 = new AWS.S3({apiVersion: '2006-03-01', region: 'ap-northeast-2'});
// fetch binary from `url` and upload to s3 using `key` as object key
const store = (url, key) => {
return new Promise((resolve, reject) => {
@mooyoul
mooyoul / store-buffer.js
Created February 17, 2017 21:01
store-buffer.js
'use strict';
const request = require('request');
const AWS = require('aws-sdk');
const s3 = new AWS.S3({apiVersion: '2006-03-01', region: 'ap-northeast-2'});
// fetch binary from `url` and upload to s3 using `key` as object key
const store = (url, key) => {
return new Promise((resolve, reject) => {
@mooyoul
mooyoul / store.js
Last active February 17, 2017 20:27
Fetch file from url and store to s3
'use strict';
const request = require('request');
const AWS = require('aws-sdk');
const s3 = new AWS.S3({apiVersion: '2006-03-01', region: 'ap-northeast-2'});
// fetch binary from `url` and upload to s3 using `key` as object key
const store = (url, key) => {
return new Promise((resolve, reject) => {
@mooyoul
mooyoul / request-stream-pipe-demo.js
Created February 16, 2017 21:50
disposed request stream data
'use strict';
const http = require('http');
const url = require('url');
const request = require('request');
const server = http.createServer((req, res) => {
const destUrl = req.url.slice(1);
if (!destUrl) {
@mooyoul
mooyoul / http-proxy.js
Created February 16, 2017 10:47
http-proxy.js
'use strict';
const http = require('http');
const request = require('request');
const server = http.createServer((req, res) => {
request({
method: 'GET',
url: 'http://www.naver.com'
}).on('error', (e) => {
@mooyoul
mooyoul / nexmo-simple-demo.js
Last active January 23, 2017 20:05
Nexmo Simple Demo
'use strict';
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));
app.use((req, res, next) => {
console.log('Got request, %s %s', req.method, req.url, req.ip, req.headers);
@mooyoul
mooyoul / consul-example.tf
Created December 30, 2016 23:18
Terraform 101 - Module Outputs
variable "access_key" {}
variable "secret_key" {}
variable "region" {
default = "ap-northeast-2"
}
variable "key_name" {}
variable "key_path" {}
provider "aws" {
access_key = "${var.access_key}"
@mooyoul
mooyoul / consul-example.tf
Created December 30, 2016 19:54
Terraform 101 - Modules
variable "access_key" {}
variable "secret_key" {}
variable "region" {
default = "ap-northeast-2"
}
variable "key_name" {}
variable "key_path" {}
provider "aws" {
access_key = "${var.access_key}"
@mooyoul
mooyoul / example.tf
Created December 29, 2016 16:18
Terraform 101 - Output Variables
provider "aws" {
access_key = "${var.access_key}"
secret_key = "${var.secret_key}"
region = "${var.region}"
}
resource "aws_instance" "example" {
ami = "${lookup(var.amis, var.region)}"
instance_type = "t2.micro"
@mooyoul
mooyoul / example.tf
Created December 28, 2016 20:39
Terraform 101 - Maps
provider "aws" {
access_key = "${var.access_key}"
secret_key = "${var.secret_key}"
region = "${var.region}"
}
resource "aws_instance" "example" {
ami = "${lookup(var.amis, var.region)}"
instance_type = "t2.micro"