Skip to content

Instantly share code, notes, and snippets.

Lucas andreybleme

View GitHub Profile
@andreybleme
andreybleme / cli.js
Created Apr 12, 2019
andreybleme.com | Criando uma CLI para fazer deploy de sites estáticos
View cli.js
let rootFolder = '.'
program
.command('deploy')
.option('-b, --bucket <s>', 'Bucket name', setBucket)
.option('-k, --key <s>', 'AWS Key', setKey)
.option('-s, --secret <s>', 'AWS Secret', setSecret)
.option('-r, --root <s>', 'Root path', setRootFolder)
.option('-e, --ignore <items>', 'Ignore files', setIgnore)
.action(function () {
@andreybleme
andreybleme / cli.js
Created Apr 12, 2019
andreybleme.com | Criando uma CLI para fazer deploy de sites estáticos
View cli.js
let ignored = []
program
.command('deploy')
.option('-b, --bucket <s>', 'Bucket name', setBucket)
.option('-k, --key <s>', 'AWS Key', setKey)
.option('-s, --secret <s>', 'AWS Secret', setSecret)
.option('-e, --ignore <items>', 'Ignore files', setIgnore)
.action(function () {
s3Services.setAwsCredentials(awsCredentials)
@andreybleme
andreybleme / cli.js
Created Apr 11, 2019
andreybleme.com | Criando uma CLI para fazer deploy de sites estáticos
View cli.js
#!/usr/bin/env node
const program = require('commander')
const s3Services = require('./app/s3Services')
const filesystem = require('./app/filesystem')
const awsCredentials = {
region: 'us-east-1',
accessKeyId: '',
secretAccessKey: ''
@andreybleme
andreybleme / s3Services.js
Created Apr 11, 2019
andreybleme.com | Criando uma CLI para fazer deploy de sites estáticos
View s3Services.js
const AWS = require('aws-sdk')
const filesystem = require('./filesystem')
function setAwsCredentials(awsCredentials) {
// altera credenciais
}
function createBucket(bucketParams, staticHostParams) {
// cria o bucket
}
@andreybleme
andreybleme / filesystem.js
Created Apr 11, 2019
andreybleme.com | Criando uma CLI para fazer deploy de sites estáticos
View filesystem.js
const fs = require('fs')
const path = require('path')
const mime = require('mime')
function getAllFilesFrom(currentDirPath, callback) {
fs.readdirSync(currentDirPath).forEach(function (name) {
const filePath = path.join(currentDirPath, name)
const stat = fs.statSync(filePath)
if (stat.isFile()) {
@andreybleme
andreybleme / cli.js
Created Apr 11, 2019
andreybleme.com | Criando uma CLI para fazer deploy de sites estáticos
View cli.js
#!/usr/bin/env node
const program = require('commander')
const s3Services = require('./app/s3Services')
const awsCredentials = {
region: 'us-east-1',
accessKeyId: '',
secretAccessKey: ''
}
@andreybleme
andreybleme / s3Services.js
Created Apr 11, 2019
andreybleme.com | Criando uma CLI para fazer deploy de sites estáticos
View s3Services.js
const AWS = require('aws-sdk')
function setAwsCredentials(awsCredentials) {
AWS.config.update(awsCredentials)
}
function createBucket(bucketParams, staticHostParams) {
const s3 = new AWS.S3()
s3.createBucket(bucketParams, function(err, data) {
if (err) {
@andreybleme
andreybleme / cli.js
Created Apr 11, 2019
andreybleme.com | Criando uma CLI para fazer deploy de sites estáticos
View cli.js
#!/usr/bin/env node
const program = require('commander')
const awsCredentials = {
region: 'us-east-1',
accessKeyId: '',
secretAccessKey: ''
}
@andreybleme
andreybleme / RpgGameClient.java
Created Feb 5, 2019
andreybleme.com | Regactoring RPG Game
View RpgGameClient.java
public void runGame() {
System.out.print(ANSI_CYAN + " WELCOME TO RPG GAME " + ANSI_RESET);
menuLoop: while (true) {
System.out.print("\n\nType the number of an option below to continue: ");
System.out.print(ANSI_BLUE + "\n 1" + ANSI_RESET +" New Game");
System.out.print(ANSI_BLUE + "\n 2" + ANSI_RESET +" Load Game");
System.out.print(ANSI_BLUE + "\n 9" + ANSI_RESET +" Exit");
System.out.print(ANSI_BLUE + "\n\n > " + ANSI_RESET);
@andreybleme
andreybleme / NewGameCommand.java
Created Feb 5, 2019
andreybleme.com | Refactoring RPG Game
View NewGameCommand.java
public class NewGameCommand extends Command {
public NewGameCommand(String input) {
super(input);
}
@Override
public void execute() {
try {
Character character = new Character(input);
You can’t perform that action at this time.