Skip to content

Instantly share code, notes, and snippets.

View hebertcisco's full-sized avatar
🎯
Focusing

Hebert F. Barros hebertcisco

🎯
Focusing
View GitHub Profile
@hebertcisco
hebertcisco / docker-start-list-of-containers.ps1
Created April 4, 2022 19:21
Start a list of docker containers with Powershell
#!/usr/bin/env pwsh
$Command = 'docker start'
$ContainerName = 'example', 'example2', 'example3'
foreach ($Container in $ContainerName) {
$Exec = $Command + ' ' + $Container
Invoke-Expression $Exec
}
Exit-PSSession
function getTimeRemaining(endtime) {
let time = Date.parse(endtime) - Date.parse(new Date().toDateString());
const THOUSAND = 1000;
const HOURS_IN_DAY = 24;
const MINUTES_IN_HOUR = 60;
const SECONDS_IN_MINUTE = MINUTES_IN_HOUR;
let seconds = Math.floor(time / THOUSAND % SECONDS_IN_MINUTE);
let minutes = Math.floor(
type TypeGetTimeRemaining = {
total: number;
days: number;
hours: number;
minutes: number;
seconds: number;
};
function getTimeRemaining(endtime: string): TypeGetTimeRemaining {
let time = Date.parse(endtime) - Date.parse(new Date().toDateString());
@hebertcisco
hebertcisco / sortNumbers.ts
Created March 25, 2022 13:47
Number ordering in JavaScript not working? Solved.
const seq = [11, 12, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1];
function sortNumbers(arrayOfNumbers: number[]) {
return arrayOfNumbers.sort((x, y) => x - y);
}
sortNumbers(seq);
#!/usr/bin/env pwsh
function Docker-Build() {
$AppName = Read-Host -Prompt "Enter the name of the application: "
$Executor = 'docker '
$ExecutorArgs = 'build -t'
$GetArgsFinal = Read-Host -Prompt "Build to production OR development?: "
$ArgsFinal = '--target ' + $GetArgsFinal + ' .'
$Command = $Executor + $ExecutorArgs + ' ' + $AppName + ' ' + $ArgsFinal
@hebertcisco
hebertcisco / node.js-macos.yml
Created December 22, 2021 16:57
MACOS Pipeline to build nodejs Aplications
name: Node.js CI on Darwin
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
jobs:
build:
@hebertcisco
hebertcisco / moneyFormat.ts
Created December 4, 2021 13:47
Formatting Money Using Intl
import Intl from 'intl';
import 'intl/locale-data/jsonp/pt-BR';
export const moneyFormat = (value: number) => {
return new Intl.NumberFormat('pt-BR', {
style: 'currency',
currency: 'BRL',
}).format(value);
};
@hebertcisco
hebertcisco / dateFormat.ts
Created December 4, 2021 13:45
Date Formatting Using Intl
import Intl from 'intl';
import 'intl/locale-data/jsonp/pt-BR';
export const dateFormat = (value: number | Date | undefined) => {
if (value) {
const date = new Date(value);
return Intl.DateTimeFormat('pt-BR', {
year: 'numeric',
month: 'numeric',
day: 'numeric',
@hebertcisco
hebertcisco / getLastMonths.ts
Created December 4, 2021 13:43
Funtion to get the last months as string eg: 'jan'
export const getLastMonths = (many: number): string[] => {
const months = [];
const currentMonth = new Date().getMonth();
for (let i = 0; i < many; i++) {
months.push(
new Date(new Date().setMonth(currentMonth - i)).toLocaleString(
'default',
{ month: 'short' },
),
);
@hebertcisco
hebertcisco / ArmazenandoJSON.js
Created April 10, 2021 22:06
Armazenando dados JSON
// Armazenando dados:
meuObj = {nome: "Hebert", idade: 19, cidade: "Gyn"};
meuJSON= JSON.stringify(meuObj );
localStorage.setItem("testJSON", meuJSON);
// Recuperando dados:
text = localStorage.getItem("testJSON");
obj = JSON.parse(text);
document.getElementById("demo").innerHTML = obj.name;