Skip to content

Instantly share code, notes, and snippets.

@thmarra
thmarra / icsParser.js
Created November 21, 2025 15:11
Transform .ics file to a .csv file
class Logger {
static log(message) {
console.log(message);
}
}
function receiveFileOnConsole(icsPath, importAllDates, fromDate, toDate) {
try {
Logger.log("Reading ICS file from path: " + icsPath);
@thmarra
thmarra / wsl.txt
Last active November 4, 2022 14:23
WSL failures
> wsl --shutdown
> wsl
Logon failure: the user has not been granted the requested logon type at this computer.
> powershell restart-service vmcompute
> wsl
OK
WSL issue: https://github.com/microsoft/WSL/issues/5401
@thmarra
thmarra / StrategyPattern.php
Last active November 25, 2021 12:39
Exemplo de como utilizar o design pattern Stategy com PHP
<?php
/**
* O Strategy é um padrão de projeto comportamental que permite que você defina uma família de algoritmos,
* coloque-os em classes separadas, e faça os objetos deles intercambiáveis.
*
* O padrão Strategy sugere que você pegue uma classe que faz algo específico em diversas maneiras diferentes e extraia
* todos esses algoritmos para classes separadas chamadas estratégias.
*
@thmarra
thmarra / CustomException.php
Created November 24, 2021 20:57
Como criar exceptions customizadas com PHP
<?php
/**
* Dentre algumas formas diferentes, é possível definir o código e mensagem de uma exception customizada podemos usar o
* método construtor ou apenas sobrescrever o valor padrão das variáveis $message e $code que já estão presentes na classe
* Exception nativa do PHP.
*
*
* Para chamar esse arquivo basta executar:
* php CustomException.php
@thmarra
thmarra / mybasics_ubuntu_20-04.sh
Last active December 13, 2020 20:23
Packages to get after installing ubuntu 20.04
#!/bin/bash
# sudo ./mybasics_ubuntu_20-04.sh
read -p "What is your username? " username
echo "Updating system"
apt update -y
apt upgrade -y
@thmarra
thmarra / php_composer_docker.md
Last active November 30, 2020 12:51
How to use composer without dockerfile and docker-compose
@thmarra
thmarra / directives.js
Created August 21, 2020 15:00
Vue directive / javascript function to parse a file size in bytes to human-readable string
Vue.directive('formatBytes', function (el, binding) {
const v = parseInt(binding.value)
let c = "0.00 B"
if (v > 0) {
var e = Math.floor(Math.log(v) / Math.log(1024));
c = (v / Math.pow(1024, e)).toFixed(2) + ' ' + ' KMGTP'.charAt(e) + 'B';
}
el.innerHTML = c
})
@thmarra
thmarra / UdemyToTrello.iim
Created October 20, 2019 21:18
Macro para copiar cursos da Udemy para o Trello
VERSION BUILD=1005 RECORDER=CR
SET !ERRORIGNORE YES
SET !EXTRACT_TEST_POPUP NO
' Tab 1 - Udemy
TAB T=1
SET !VAR1 ""
SET !VAR2 ""
' var = "0" -> quantos cards já existem na coluna
@thmarra
thmarra / numeros_amigos.py
Created October 3, 2019 16:17
Números amigos
'''
Dizemos que dois números são amigos se cada um deles é igual a soma dos divisores do
outro.
Um exemplo de números amigos são 284 e 220, pois os divisores de 220 são 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 e 110.
Efetuando a soma destes números obtemos o resultado 284.
1 + 2 + 4 + 5 + 10 + 11 + 20 + 22 + 44 + 55 + 110 = 284
Os divisores de 284 são 1, 2, 4, 71 e 142, efetuando a soma destes números obtemos o
@thmarra
thmarra / docker-compose.yml
Created September 16, 2019 20:52
Docker for Elasticsearch + Kibana (v.7.3.2)
version: '3'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.3.2
volumes:
- ./esdata:/usr/share/elasticsearch/data
environment:
- cluster.name=docker-cluster
- bootstrap.memory_lock=true