Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View TiagoGouvea's full-sized avatar

Tiago Gouvêa TiagoGouvea

View GitHub Profile
@TiagoGouvea
TiagoGouvea / gist:5b709c922871bc0c3a88f142ad55fc4a
Created January 12, 2024 17:03
HTML entities decode for Google App Script
function htmlEntitiesDecode(input) {
entities.forEach(function(substitution) {
var regex = new RegExp(substitution.entity, 'g');
input = input.replace(regex, substitution.character);
});
return input;
}
const entities = [
{ entity: "À", character: "À" },
@TiagoGouvea
TiagoGouvea / MigrationFresh.js
Created January 13, 2021 11:51
Adonis migration:fresh command with optional seed, that recreates the schema from scratch and seed data
'use strict';
const { Command } = require('@adonisjs/ace');
const Seeder = require('../../database/seeds/Seeder');
const ace = require('@adonisjs/ace');
class MigrationFresh extends Command {
/**
* Command signature
*/
@TiagoGouvea
TiagoGouvea / MigrationFresh.js
Created January 13, 2021 11:50
// You must add this command to your start/app.js ... const commands = ['App/Commands/MigrationFresh']; ...
'use strict';
const { Command } = require('@adonisjs/ace');
const Seeder = require('../../database/seeds/Seeder');
const ace = require('@adonisjs/ace');
class MigrationFresh extends Command {
/**
* Command signature
*/
@TiagoGouvea
TiagoGouvea / docker-compose.yml
Created July 7, 2020 10:49
Docker compose para Wordpress local com PhpMyAdmin, montando a pasta local "wp-content"
version: '3.3'
services:
db:
image: mysql:5.7
volumes:
- db:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: wordpress
@TiagoGouvea
TiagoGouvea / config.sh
Last active May 1, 2020 20:31
Updated config file to help create a remote instance, build and deploy a docker project to Google Cloud Platform
#!/usr/bin/env bash
## Google cloud config
PROJECT="node-docker-gcp"
ZONE="us-central1-a"
## Instance settings
INSTANCE_NAME="my-compute-instance"
### Instance creation settings
@TiagoGouvea
TiagoGouvea / build-push-update.sh
Last active May 2, 2020 14:38
Script to build and push a docker image, and remotely pull and update instance, on Google Cloud Platform
#!/usr/bin/env bash
echo -e "\nDeploy remote instance"
echo -e "\n# 1/4 - Loading and setting options..."
## Show commands (if you want to check, uncomment it)
#set -x
## Stop on errors
set -e
@TiagoGouvea
TiagoGouvea / remote-setup.sh
Created May 1, 2020 19:41
Script to setup a send a file to a instance on Google Cloud Platform and run it
#!/usr/bin/env bash
echo -e "\nSetup remote instance"
echo -e "\n# 1/3 - Loading and setting options..."
## Show commands (if you want to check, uncomment it)
#set -x
## Stop on errors
set -e
@TiagoGouvea
TiagoGouvea / local-setup.sh
Last active May 2, 2020 14:35
Script to setup a instance do run docker on Google Cloud Platform
#!/usr/bin/env bash
## Show commands (if you want to check, uncomment it)
##set -x
## Stop on errors
set -e
## Include config
source config.sh
@TiagoGouvea
TiagoGouvea / Dockerfile
Created April 26, 2020 22:04
Simplest docker file ever seen
FROM node:10-alpine
WORKDIR /home/node/app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 8080
CMD [ "node", "index.js" ]
@TiagoGouvea
TiagoGouvea / index.js
Created April 26, 2020 22:02
Simplest node script
var http = require('http');
var handleRequest = function(request, response) {
response.writeHead(200);
response.end("I'm alive");
}
var www = http.createServer(handleRequest);
var port = process.env.PORT || 8080;
www.listen(port, function () {
console.log("Node server listening at port "+port);
});