Skip to content

Instantly share code, notes, and snippets.

View leonardokl's full-sized avatar

Leonardo Luiz leonardokl

View GitHub Profile
@leonardokl
leonardokl / tts.js
Last active April 7, 2017 00:49
tts.js
/* global SpeechSynthesisUtterance */
const speechSynthesis = window.speechSynthesis
const synthesizeSpeech = (text, { lang = 'pt-BR' } = {}) => {
const utterThis = new SpeechSynthesisUtterance(text)
const voices = speechSynthesis.getVoices()
const selectedVoice = voices.find(i => i.lang === lang)
utterThis.voice = selectedVoice
@leonardokl
leonardokl / index.html
Created June 3, 2017 18:05
Display Webcam Stream
<!DOCTYPE html>
<html>
<head>
<title>Display Webcam Stream</title>
<style>
body {
margin: 0;
}
#webcam {
@leonardokl
leonardokl / sh.js
Last active February 5, 2018 23:33
A function that spawns a new process using the given command, logging the stdout and stderr.
const cp = require('child_process')
/**
* A function that spawns a new process using the given command, logging the stdout and stderr.
*
* @param {String} command
* @param {Array} args
* @return {Promise}
* @example
*
@leonardokl
leonardokl / README.md
Created October 11, 2017 20:12
Convetional ChangeLog Prefixes

Convetional ChangeLog Prefixes

  • feat: A new feature

  • fix: A bug fix

  • BREAKING CHANGE: A breaking change

  • docs: Documentation only changes

@leonardokl
leonardokl / npm-version-cheatsheet.md
Last active July 2, 2024 08:09
npm version cheatsheet

NPM VERSION

Bump a package version

major (Breaking Change)

# version 1.0.0
$ npm version major # 2.0.0
$ npm version premajor # 2.0.0-0
@leonardokl
leonardokl / intall.sh
Last active May 28, 2019 13:18
install.sh
#!/usr/bin/env bash
sudo apt-get update
sudo apt-get install git \
apt-transport-https \
ca-certificates \
curl \
software-properties-common \
ssh-keygen
@leonardokl
leonardokl / AbortController.js
Last active January 13, 2020 09:48
AbortController implementation with XMLHttpRequest - https://codesandbox.io/s/92vnjok08r
class AbortError extends Error {
name = "AbortError";
message = "Aborted";
}
class AbortSignal extends EventTarget {
aborted = false;
}
class AbortController {
@leonardokl
leonardokl / Modal.tsx
Last active June 17, 2019 16:46
Improving react-semantic-ui modal acessibility
import React from 'react';
import FocusLock from 'react-focus-lock';
import { Modal as SemanticModal, ModalProps } from 'semantic-ui-react';
const ModalLock: React.FC<ModalProps> = ({ children, className, ...props }) => (
<FocusLock returnFocus className={className} lockProps={props}>
{children}
</FocusLock>
);
@leonardokl
leonardokl / formatList.js
Last active December 27, 2019 19:43
Format Text List
export const formatList = list =>
list.reduce((acc, text, index) => {
if (index === 0) return text;
return acc.concat(`${!list[index + 1] ? ' and' : ','} ${text}`);
}, '');
@leonardokl
leonardokl / README.md
Last active August 11, 2020 23:22
Planing Poker
Valor Tempo
0 não precisa ser feita
1 menos de 1h
2 uma manhã
3 uma tarde
5 um dia
8 2 ou 3 dias
13 5 dias
20 quebrar a tarefa