Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Leonardo Dutra leodutra

🏠
Working from home
View GitHub Profile
@leodutra
leodutra / headset-setup-bt.sh
Created Aug 1, 2021
Bluetooth headset/ headphone Ubuntu 20.04 - tested with Sony WH-1000XM4 - shell script
View headset-setup-bt.sh
#!/bin/sh
sudo add-apt-repository ppa:eh5/pulseaudio-a2dp
sudo apt update
sudo apt install libldac \
libavcodec-extra58 \
libfdk-aac1 \
bluez \
pulseaudio \
pulseaudio-modules-bt \
@leodutra
leodutra / create-mapping-sample.js
Last active Jul 24, 2021
Create array doing mapping sample
View create-mapping-sample.js
Array.from({ length: 130 }, (_, i) => (i + 2) * 5000).reverse()
@leodutra
leodutra / formatPrice.js
Last active Jul 24, 2021
Format price using Intl.NumberFormat
View formatPrice.js
const formatPrice = ({
price,
fraction = 2,
currency = 'USD',
currencyDisplay = 'symbol', // 'narrowSymbol' is not supported by Safari yet
locale = 'en-US',
signDisplay = 'auto',
...props
}) => {
if (isNaN(Number(price))) {
@leodutra
leodutra / - npm license values
Last active May 16, 2021 — forked from kemitchell/-
npm license values
View - npm license values
74925 NONE
54706 MIT
9268 ISC
3050 BSD
1521 BSD-2-CLAUSE
791 APACHE-2.0
699 APACHE 2.0
392 BSD-3-CLAUSE
364 WTFPL
346 UNKNOWN
@leodutra
leodutra / repo-rinse.sh
Created May 7, 2021 — forked from nicktoumpelis/repo-rinse.sh
Cleans and resets a git repo and its submodules
View repo-rinse.sh
git clean -xfd
git submodule foreach --recursive git clean -xfd
git reset --hard
git submodule foreach --recursive git reset --hard
git submodule update --init --recursive
@leodutra
leodutra / settings.json
Last active Jul 10, 2021
VSCode - Visual Studio Code settings
View settings.json
{
"editor.tabSize": 4,
"[javascript]": {
"editor.tabSize": 2,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascriptreact]": {
"editor.tabSize": 2,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
@leodutra
leodutra / replaceStrByRender.js
Last active Feb 12, 2021
React - replace string by render or component
View replaceStrByRender.js
const escapeRegExp = str => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
const replaceStrByRender = (str, substr, render) => {
if (!str || !substr) return str
const parts = str.split(new RegExp(`(${escapeRegExp(substr)})`))
let index = 0
for (let i = 1; i < parts.length; i += 2) {
parts[i] = render(parts[i], index++)
}
return parts.filter(x => x)
@leodutra
leodutra / .gitlfstracks
Created Dec 25, 2020 — forked from bdombro/.gitlfstracks
Git LFS Default Tracks - Common binary file extensions
View .gitlfstracks
"To include this, run `cat .gitlfstrack | xargs git lfs track`"
"*.3ds"
"*.3g2"
"*.3gp"
"*.7z"
"*.a"
"*.aac"
"*.adp"
"*.ai"
"*.aif"
@leodutra
leodutra / git-delete-local-branches.sh
Last active Dec 16, 2020
Delete unused local branches ( Git )
View git-delete-local-branches.sh
#!/bin/sh
# Good ref: https://devconnected.com/how-to-clean-up-git-branches/
# lists branches that can be deleted/pruned on your local. An option --dry-run is needed
git remote prune origin --dry-run
# In order to clean up remote tracking branches,
# meaning deleting references to non-existing remote branches,
# use the “git remote prune” command and specify the remote name
git remote prune origin
@leodutra
leodutra / leo-pulseeffects-preset.json
Last active Apr 2, 2020
Leo's PulseEffects preset (Sony MDR-7506)
View leo-pulseeffects-preset.json
{
"spectrum": {
"show": "true",
"n-points": "150",
"height": "100",
"use-custom-color": "true",
"fill": "true",
"show-bar-border": "true",
"scale": "1",
"exponent": "1",