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
// you can write to stdout for debugging purposes, e.g. | |
// console.log('this is a debug message'); | |
function solution(A) { | |
// write your code in JavaScript (Node.js 8.9.4) | |
const merge_sort = (A) => { | |
//https://gist.github.com/paullewis/1982121 | |
function sort(array) { |
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
/* question A, | |
params : A = [1,6,4,5,8,10] | |
return : sum max triangle sides | |
a + b > c | |
*/ | |
const solution = (A)=>{ | |
const find_triplet = (sorted_arr) => { | |
for (let i = sorted_arr.length - 1; i > 1; i--) { | |
const c = sorted_arr[i] |
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
// find the missing number 1- 1000 | |
const min =0, max=1000; | |
let arr = new Array(max).fill(0).map((v,k)=> k); | |
const erase = Math.floor(Math.random() * (max - min + 1)) + min; | |
arr.splice(erase,1); | |
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 | |
#curl -LJO https://gist.github.com/niradler/0fbd94573d1efb2b467fbfb90cba2297/raw | |
#chmod +x deploy.sh | |
cd ~/app/devresources | |
git commit -am "pull" | |
git pull --force |
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 aws = require('aws-sdk'); | |
const { AWS_KEY, AWS_SECRET } = process.env; | |
var sqs = new aws.SQS({ accessKeyId: AWS_KEY, secretAccessKey: AWS_SECRET, region: 'us-east-1' }); | |
const QueueUrl = ''; | |
const enablesPolling = (ReceiveMessageWaitTimeSeconds = "5") => new Promise ((resolve,reject) => { | |
const params = { | |
Attributes: { | |
ReceiveMessageWaitTimeSeconds, | |
}, |
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 apt-get update | |
sudo apt-get upgrade | |
usermod -aG sudo ghost | |
su - ghost | |
sudo apt-get install nginx | |
sudo ufw allow 'Nginx Full' | |
sudo apt-get install mysql-server | |
# To set a password, run | |
sudo mysql | |
# and login to your Ubuntu user again |
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 exec = require('child_process').exec; | |
const shell = (cmd) => { | |
const script = exec(cmd, | |
(error, stdout, stderr) => { | |
if (error !== null) { | |
console.error(error); | |
} | |
}); | |
script.stdout.pipe(process.stdout); | |
} |
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
version: '2.1' | |
services: | |
mongo: | |
container_name: mongo | |
image: mongo | |
volumes: | |
- /data/db/mongo | |
ports: | |
- '27017:27017' |
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
#for dev and prod stage, dont forget to install jq | |
aws apigateway get-rest-apis | jq '.items[].id' | sed s/\"// | sed s/\”// > api_ids.txt | |
for i in $(cat api_ids.txt); | |
do aws apigateway get-export --parameters extensions='postman' --rest-api-id $i --stage-name prod --export-type swagger ./apis/lambda/prod/$i.json; | |
echo $i ; | |
done ; | |
for i in $(cat api_ids.txt); | |
do aws apigateway get-export --parameters extensions='postman' --rest-api-id $i --stage-name dev --export-type swagger ./apis/lambda/dev/$i.json; |