Skip to content

Instantly share code, notes, and snippets.

View lucasltv's full-sized avatar
🏠
Working from home

Lucas Vieira lucasltv

🏠
Working from home
  • Campinas SP - Brazil
View GitHub Profile
@lucasltv
lucasltv / chunk.ts
Created April 30, 2021 12:28
Chunke JSON Array Data
export function chunkData(array: unknown[], chunk = 10) {
let i, j;
const newArray = [];
for (i = 0, j = array.length; i < j; i += chunk) {
newArray.push(array.slice(i, i + chunk));
}
return newArray;
}
@lucasltv
lucasltv / ngxdisable.sh
Created February 20, 2021 03:30
Nginx scripts for enable and disabling a site. This will create or destroy a symlink between a real config file in /etc/nginx/sites-available and a symlink in /etc/nginx/sites-enabled.
#!/usr/bin/env bash
# run: bash ngxdisable.sh <your site at sites-available>
if [ $EUID -ne 0 ]; then
echo "You must be root: \"sudo ngxdis\""
exit 1
fi
# -z str: Returns True if the length of str is equal to zero.
if [ -z "$1" ]; then
echo "Please choose a site."
@lucasltv
lucasltv / launch.json
Created February 5, 2021 14:55
VSCODE config file for local debugger Alexa skill
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Alexa Skill (Node.js)",
"type": "node",
"request": "launch",
"program": "${workspaceFolder}/node_modules/ask-sdk-local-debug/dist/LocalDebuggerInvoker.js",
"preLaunchTask": "tsc: watch - tsconfig.json",
"args": [
@lucasltv
lucasltv / .gitignore
Created January 27, 2021 21:01 — forked from iffy/.gitignore
Example using electron-updater with `generic` provider.
node_modules
dist/
yarn.lock
wwwroot
@lucasltv
lucasltv / .zshrc
Created April 17, 2020 20:56
Bash function to show MACOS notification
function alert() {
local notification_command="display notification \"$2\" with title \"$1\" subtitle \"$3\" sound name \"$4\""
osascript -e "$notification_command"
}
@lucasltv
lucasltv / envValidatorService.js
Created March 2, 2020 02:58
Function to validate if all of env keys are present in your .env file (use dotenv dependency for parse data).
const dotenv = require('dotenv');
const fs = require('fs');
const path = require('path');
const envSampleFilename = ".env.example"; //Create your own .env.example at root with dummy data and commit this file.
const envSample = fs.readFileSync(path.join(process.cwd(), envSampleFilename)).toString();
const buf = Buffer.from(envSample)
const sampleConfig = dotenv.parse(buf); // will return an object
const envsToValidade = Object.keys(sampleConfig);
module.exports = {
@lucasltv
lucasltv / start_mongo_replica_set.sh
Created October 23, 2019 02:35
Start MONGO local DEV in replica set
#MONGOD REPLICASET: https://docs.mongodb.com/manual/tutorial/deploy-replica-set-for-testing/
export MONGO_DIR=~/mongodb
mongod --replSet rs0 --port 27017 --bind_ip localhost --dbpath ${MONGO_DIR}/rs0-1 --logpath "${MONGO_DIR}/rs0-1.log" --smallfiles --oplogSize 128 --fork &
mongod --replSet rs0 --port 27018 --bind_ip localhost --dbpath ${MONGO_DIR}/rs0-2 --logpath "${MONGO_DIR}/rs0-2.log" --smallfiles --oplogSize 128 --fork &
mongod --replSet rs0 --port 27019 --bind_ip localhost --dbpath ${MONGO_DIR}/rs0-3 --logpath "${MONGO_DIR}/rs0-3.log" --smallfiles --oplogSize 128 --fork
# Login via mongo shell:
# rsconf = {
# _id: "rs0",
@lucasltv
lucasltv / bd3d4befe38185704bf0fc875e9deed6|configuration.json
Last active September 16, 2020 05:57
Visual Studio Code Settings Sync Gist
{"contents":{"launch":{"version":"0.2.0","configurations":[{"type":"node","request":"launch","name":"Launch Program","program":"${workspaceFolder}/start"}]}},"overrides":[],"keys":["launch.version","launch.configurations"]}