Skip to content

Instantly share code, notes, and snippets.

View kelvearagao's full-sized avatar

Kelve Aragão kelvearagao

  • XP Inc
  • São Paulo - SP
View GitHub Profile
@kelvearagao
kelvearagao / dateEn.js
Created January 6, 2016 18:15
Função javascript para converter a data do formato brasileiro para formato inglês.
/**
* Recebe um data no formato dd/mm/yyyy e retorna yyyy-mm-dd.
*
* @param string date - Data no formato 'dd/mm/yyyy'.
* @return string - Data no formato 'yyyy-mm-dd'.
*/
function dateToEN(date)
{
return date.split('/').reverse().join('-');
}
@kelvearagao
kelvearagao / index.html
Created October 13, 2017 14:44
Select2: Infinite Scroll with Local Array Data
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="select2.css" rel="stylesheet">
</head>
<body>
<div>

Problem

I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.
@kelvearagao
kelvearagao / copyToClipboard.js
Created November 13, 2020 19:27
receives data as an argument and copies it to the clipboard
const copyToClipboard = data => {
const el = document.createElement('textarea');
el.value = data;
el.setAttribute('readonly', '');
el.style.position = 'absolute';
el.style.left = '-9999px';
document.body.appendChild(el);
el.select();
@kelvearagao
kelvearagao / debounce.js
Created January 28, 2020 12:43
RxJs: redux-observable and buffer debounce
export const startWsEpic = action$ => action$.pipe(
ofType(START_WS),
mergeMap(action => {
const source$ = ws(action.payload).pipe(share())
return source$.pipe(
takeUntil(action$.ofType(STOP_WS)),
buffer(source$.pipe(debounceTime(100))),
map(data => updateData(data)),
catchError(() => of(updateDataError()))
# git subtree push --prefix server heroku heroku-master
# heroku logs --tail
# heroku restart -a server-gq
@kelvearagao
kelvearagao / javascript-file-download.html
Created September 8, 2018 03:54
Realizando download via javascript!
<!DOCTYPE html>
<html>
<head>
<title>testing download</title>
</head>
<body>
<h1>testing download</h1>
<button onclick="fetch('GET', 'http://127.0.0.1:8080/public/downloads.zip', true)">new version</button>
<br><br>
@kelvearagao
kelvearagao / nginx-vh.conf
Created November 11, 2017 16:17
EasyPHP + Nginx + CakePHP + Virtual Host
#virtual-host
server {
listen 8585;
server_name 127.0.0.1;
root "C:/Users/kelve/workspace/doacoes-sustentacao-2017/app/webroot";
index index.php;
location "/" {
@kelvearagao
kelvearagao / git-conflicts.sh
Created June 21, 2017 00:21
Comandos para resolução de conflitos com git
# prevalecer a versão do branch atual
$ git checkout --ours <path do arquivo>
# prevalecer a versão do outro branch
$ git checkout --theirs <path do arquivo>
# voltar pra versão inicial do conflito
$ git checkout -m <path do arquivo>
@kelvearagao
kelvearagao / gist:b454ebed7466a8edbb19ad439d04f234
Created December 9, 2016 18:17
Fechar processo no windows pesquisando a porta
C:\Users\username>netstat -o -n -a | findstr 0.0:3000
TCP 0.0.0.0:3000 0.0.0.0:0 LISTENING 3116
C:\Users\username>taskkill /F /PID 3116