Skip to content

Instantly share code, notes, and snippets.

View maxcelos's full-sized avatar
💭
Looking for awesomeness

Marcelo Silva maxcelos

💭
Looking for awesomeness
View GitHub Profile
@maxcelos
maxcelos / laravel-echo-vanillajs.js
Created September 29, 2023 14:58
Simple implementation of Laravel Echo in vanilla JS
import Echo from 'laravel-echo';
import Pusher from 'pusher-js';
import axios from 'axios';
const token = 'your-access-token'
const authUrl = 'your-api-url/api/broadcasting/auth'
const pusherKey = 'your-pusher-key'
const pusherCluster = 'mt1'
const userId = 1
const privateChannel = 'App.Models.User.' + userId
DROP FUNCTION IF EXISTS BIG_SEC_TO_TIME;
DELIMITER $$
CREATE FUNCTION BIG_SEC_TO_TIME(SECS BIGINT)
RETURNS TEXT
READS SQL DATA
DETERMINISTIC
BEGIN
DECLARE HEURES TEXT;
DECLARE MINUTES CHAR(5);
DECLARE SECONDES CHAR(5);
@maxcelos
maxcelos / php_array_flatten.md
Created December 29, 2021 13:01
Convert multidimensional array to simple array with keys
flatten(array $array, $keyPrefix = ''): array
{
    $return = [];

    foreach ($array as $key => $value) {
        $key = trim($keyPrefix . '_' . $key, '_');

        if (is_array($value)){
 $return = array_merge($return, flatten($value, $key));
@maxcelos
maxcelos / wildcard-ssl-certbot
Created September 29, 2021 23:33
How to create a wildcard ssl with Certbot
certbot certonly \
--manual \
--preferred-challenges=dns \
--email your@email.com \
--server https://acme-v02.api.letsencrypt.org/directory \
--agree-tos \
-d *.your-domain.com -d our-domain.com
/**
* Script simples para importação de dados de cotação da Bovespa
*
* Requisitos:
* - Node.js instalado
* - instalar as dependencias: npm install extract-zip moment request
*
* Exemplo de uso: node script_simples_importaca_cota_hist_bovespa.js 05022019
*
* Post relacionado: https://albertosouza.net/artigos/22-importando-dados-bovespa
@maxcelos
maxcelos / .alias
Created November 3, 2020 02:51
Useful alias for artisans
alias a="php artisan"
alias lc="php artisan config:clear && php artisan view:clear && php artisan cache:clear && php artisan route:clear && composer dumpautoload"
alias cda="composer dumpautoload"
alias g="git"
alias gc="git add . && git commit -m"
alias dev="~/Documents/dev"
alias p="pstorm"
alias c="composer"
alias cr="composer require"
@maxcelos
maxcelos / nubankOfx2Csv.php
Last active September 22, 2020 03:16
Converte extrato NuConta de OFX para CSV
<?php
$ofx = $argv[1] ?? null;
if (! $ofx)
echo 'Origin file missing';
$output = $argv[2] ?? 'extrato.csv';
$ofx = @file_get_contents($ofx);
@maxcelos
maxcelos / laravel_nginx
Created June 18, 2020 20:19
Nginx vhost setup for laravel applications
server {
# Porta WEB
listen 80;
listen [::]:80;
# Nome do servidor
server_name example.com;
# Diretorio de Log
access_log /var/log/nginx/access.log;
@maxcelos
maxcelos / consultaTaxaB3.php
Created October 23, 2019 23:41
Consulta a taxa de emonumentos para swing trade pessoa física no Laravel
<?php
// Consulta a taxa de emonumentos para swing trade pessoa física no Laravel
$html = @file_get_contents('http://www.b3.com.br/pt_br/produtos-e-servicos/tarifas/listados-a-vista-e-derivativos/renda-variavel/tarifas-de-acoes-e-fundos-de-investimento/a-vista/');
$html = explode("Taxa de negociação, taxa de liquidação e taxa de registro", $html);
$html = explode("Faixas de volume para daytrade", $html[1]);