Skip to content

Instantly share code, notes, and snippets.

View erickhaendel's full-sized avatar
🎯
Focusing

Erick Haendel erickhaendel

🎯
Focusing
View GitHub Profile
@erickhaendel
erickhaendel / Lista de bancos Brasileiros
Last active August 29, 2015 14:21
Lista de Bancos - PHP Array
<?php
//Lista de bancos brasileiros
$banks = array(
array('code' => '001', 'name' => 'Banco do Brasil'),
array('code' => '003', 'name' => 'Banco da Amazônia'),
array('code' => '004', 'name' => 'Banco do Nordeste'),
array('code' => '021', 'name' => 'Banestes'),
array('code' => '025', 'name' => 'Banco Alfa'),
array('code' => '027', 'name' => 'Besc'),
array('code' => '029', 'name' => 'Banerj'),
This fails because the types of bcrypt hashes being generated from php and node are different. Laravel generates the $2y$ while node generates the $2a$. But the good news is the only difference between 2a and 2y are their prefixes.
So what you can do is make one of the prefix similar to the other. Like:
$phpGeneratedHash = '$2y$10$jOTwkwLVn6OeA/843CyIHu67ib4RixMa/N/pTJVhOjTddvrG8ge5.';
$nodeGeneratedHash = '$2a$10$ZiBH5JtTDtXqDajO6f4EbeBIXGwtcGg2MGwr90xTH9ki34SV6rZhO';
To something like:
$phpGeneratedHash = '$2y$10$jOTwkwLVn6OeA/843CyIHu67ib4RixMa/N/pTJVhOjTddvrG8ge5.';
User Model (file)
module.exports = function(sequelize, DataTypes){
var User = sequelize.define(
'User', {
name: {
type: DataTypes.STRING,
allowNull: false
}
},
@erickhaendel
erickhaendel / diffExludeDays.js
Created January 23, 2019 19:53
Diferença entre datas em dias - Excluindo dias da semana
// Dia inicial
var start = new Date("2018-01-01");
// Dia final
var finish = new Date("2018-02-01");
// Adicionar tempo em milisegundos - 1 dia
var dayMilliseconds = 1000 * 60 * 60 * 24;
var diff = 0;
while (start.getTime() <= finish.getTime()) {
var day = start.getDay();
@erickhaendel
erickhaendel / named_export.js
Created September 11, 2019 03:01
Named Export Example
// Imports
// Ex. importando um named export
import { MyComponent } from "./MyComponent";
// Ex. importando multiplos named exports
import { MyComponent, MyComponent2 } from "./MyComponent";
// Ex. Alterando o nome do modulo importado usando "as":
import { MyComponent2 as MyNewComponent } from "./MyComponent";
// Arquivo com os componentes para exportação
// Exports do arquivo ./MyComponent.js
// Use MainComponents.MyComponent e MainComponents.MyComponent2
import * as MainComponents from "./MyComponent";
Olá desenvolvedor(a), ter um certificado SSL em um ambiente de desenvolvimento local, é um requisito para a realização de testes em algumas API's de intermediação de pagamento, como por exemplo o Pagseguro. A configuração do ambiente utilizando o Xampp e o Google Chrome era realativamente simples, com meia dúzia de comandos no Prompt você já estava com seu localhost respondendo à partir da requisição https. O problema é que à partir da versão 58 do Chrome os processos anteriores deixaram de funcionar, o que deixou muita gente de cabelo em pé.
Isso acontece porque, à partir da versão 58, o Chrome passa a não reconhecer certificados SSL assinados à partir do CN (Common Name), e reconhecer apenas certificados assinados à partir do SAN (Subject Alternative Name).
Depois de muita pesquisa, em foruns e sites especializados, encontrei uma forma bem simples de se instalar o certificado. Por enquanto testei apenas no Windows, porém em breve vou testar também no Linux! Então vamos lá.
O primeiro passo é baixar e ins
@erickhaendel
erickhaendel / virtual_host_mamp.md
Last active March 14, 2020 20:10
Virtual Host - MAMP

While googling, I found these steps to easily create virtual hosts on MAMP:

Open your console in mac and edit your hosts file like this

sudo vim /etc/hosts

This opens a system file that contains the following line:

@erickhaendel
erickhaendel / gist:1c43c58c880468467dd5c8528f976e7f
Last active March 26, 2020 02:44
Generate Release/Debug Keystores.md

Android: Generate Release/Debug Keystores

DEBUG RELEASE ANDROID KEYSTORE

Generate Keystores

To generate keystores for signing Android apps at the command line, use:

$ keytool -genkey -v -keystore my-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000

A debug keystore which is used to sign an Android app during development needs a specific alias and password combination as dictated by Google. To create a debug keystore, use:

@erickhaendel
erickhaendel / auto.js
Last active April 7, 2020 20:51
Gamersclub medalhas
// COLOCAR DENTRO DA LISTA (LIST) DE CODIGOS SEPARADOS POR VIRGULA E ENTRE ASPAS
// EX:
// var list = ['CODE_1' , 'CODE_2' , 'CODE_3']
var list = [
];
function sleep(ms) {