This file contains hidden or 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
import * as http from "http" | |
const PORT = 1337 | |
type Request = http.IncomingMessage & { | |
params?: Map<String, String> | |
} | |
const routeResolver = async (routes: Map<string, Function> = new Map(), req: http.IncomingMessage, res: http.ServerResponse) => { | |
const requestPaths: string[] = req.url.split("/").filter(path => path.length > 0) |
This file contains hidden or 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 | |
# TO CONVERT A SERVICEACCOUNT FILE IN BASE64 AND SAVE IT TO A VARIABLE | |
# RUN: "CI_GCLOUD_SERVICE_ACCOUNT_BASE64=$(base64 ./xapps-terraform.json)" | |
# TO CONVERT A SERVICEACCOUNT BASE64 TO FILE AND USE IT WITH CLI SDK | |
echo $CI_GCLOUD_SERVICE_ACCOUNT_BASE64 | base64 -d > ./serviceaccount.json | |
wget https://dl.google.com/dl/cloudsdk/release/google-cloud-sdk.tar.gz |
This file contains hidden or 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
import * as os from "os" | |
import * as cluster from "cluster" | |
import { bootstrap } from "./server" | |
const numCpus = os.cpus().length | |
const handleFork = () => { | |
const worker = cluster.fork() | |
worker.addListener("exit", (code) => { | |
if (code !== 0) handleFork() | |
}) |
This file contains hidden or 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 language = "pt-BR" | |
// formatting lists | |
const vehicles = ["Car", "Bike", "Airplan"] | |
new Intl.ListFormat(language, { style: "long", type: "conjunction" }).format(vehicles) | |
// formatting units | |
const kmTraveled = 10000 | |
new Intl.NumberFormat(language, { style: "unit", unit: "kilometer" }).format(kmTraveled) |
This file contains hidden or 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
import { writeFile, readFile } from "fs/promises" | |
export const save = async (data) => { | |
const currentData = await read("./../database.json") | |
currentData.push(data) | |
await writeFile(databaseFile, JSON.stringify(currentData)) | |
} | |
export const read = async (filename) => { | |
const { pathname: databaseFile } = new URL(filename, import.meta.url) |
This file contains hidden or 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
// IMPORT DEPENDENCIES | |
const stream = require("stream") | |
const AWS = require('aws-sdk'); | |
const fs = require('fs'); | |
const s3 = new AWS.S3(); | |
// DOWNLOAD STREAM EXAMPLE | |
const s3download = (bucketName, keyName, localDest) => { |
This file contains hidden or 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
#instala uma imagem mysql na versão 5.7 atribuindo um volume existente | |
docker run -d --name mysql --restart always -p 3306:3306 -v mysql-volume:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=mysql-secret-pw mysql:5.7 --default-authentication-plugin "mysql_native_password" | |
#instala uma imagem redis na versão alpine atribuindo um volume existente | |
docker run -d --name redis --restart always -p 6379:6379 -v redis-volume:/var/lib/redis redis:alpine redis-server --requirepass "redis-secret-pw" |
This file contains hidden or 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
# 1) check if is everything ok on local machine using docker-compose | |
docker-compose up | |
# 2) run aws configure and set your credentials | |
aws configute | |
# or import your csv configuration | |
aws configure import --csv file://$PDW/aws-profile-credentials.csv | |
# 3) check if your credentials is currecly imported and configured | |
aws configure list |
This file contains hidden or 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
// The returned ID can be passed on image field on model | |
const uploadFileBinary = async (binary, uuid) => { | |
const fileInfo = { name: uuid } | |
const metas = {} | |
const { optimize } = strapi.plugins.upload.services['image-manipulation']; | |
const { buffer, info } = await optimize(binary); | |
const formattedFile = await strapi.plugins.upload.services.upload.formatFileInfo( | |
{ | |
filename: uuid + '.png', |
This file contains hidden or 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
import 'package:equatable/equatable.dart'; | |
import 'package:meta/meta.dart'; | |
class UserEntity extends Equatable { | |
final String id; | |
final String username; | |
final String password; | |
final List<LinkEntity> links; | |
UserEntity({ | |
@required this.id, |
NewerOlder