Skip to content

Instantly share code, notes, and snippets.

View marciobarrios's full-sized avatar

Marcio Barrios marciobarrios

View GitHub Profile
@marciobarrios
marciobarrios / .aliases
Last active January 14, 2020 07:40
Dotfiles
# Git
alias listTags="git tag -l --sort=v:refname | tail -n8"
alias branches="git for-each-ref --count=30 --sort=-committerdate refs/heads/ --format='%(refname:short)'"
# Other
alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'"
# Alias based on this post: https://remysharp.com/2018/08/23/cli-improved
alias cat="bat"
alias ping="prettyping"
@marciobarrios
marciobarrios / get_commit_hours_by_author.txt
Created July 19, 2019 08:58
Git command to show a list of commits across the different hours of a day for an specific author (https://gist.github.com/bessarabov/674ea13c77fc8128f24b5e3f53b7f094)
git log --author="Linus Torvalds" --date=iso | perl -nalE 'if (/^Date:\s+[\d-]{10}\s(\d{2})/) { say $1+0 }' | sort | uniq -c|perl -MList::Util=max -nalE '$h{$F[1]} = $F[0]; }{ $m = max values %h; foreach (0..23) { $h{$_} = 0 if not exists $h{$_} } foreach (sort {$a <=> $b } keys %h) { say sprintf "%02d - %4d %s", $_, $h{$_}, "*"x ($h{$_} / $m * 50); }'
function usePersistedState(key, defaultValue) {
const [state, setState] = React.useState(
() => JSON.parse(localStorage.getItem(key)) || defaultValue
);
useEffect(() => {
localStorage.setItem(key, JSON.stringify(state));
}, [key, state]);
return [state, setState];
@marciobarrios
marciobarrios / squarespace_automatic_index.js
Last active July 16, 2019 22:24
Script para generar automáticamente un índice en Squarespace para los posts sobre guías de viaje
(function() {
if (/guia-para-viajar/.test(window.location.pathname) || /ruta-de-/.test(window.location.pathname)) {
if (/^Guía para viajar/.test(document.querySelector(".entry-title").textContent)) {
let index = ""
const h2 = document.querySelectorAll("h2")
h2.forEach(item => {
const content = item.textContent
if (!/^Datos básicos/.test(content)) {
import { useEffect } from "react"
export const useMount = fn => useEffect(fn, [])
import ReactDOM from 'react-dom'
// ...
componentDidMount() {
document.addEventListener('click', this.handleClickOutside, true)
}
componentWillUnmount() {
document.removeEventListener('click', this.handleClickOutside, true)
@marciobarrios
marciobarrios / settings.js
Last active March 5, 2023 15:25
Minimal UI for Visual Code
{
"editor.minimap.enabled": false, // removes minimap
"editor.renderWhitespace": "none", // removes whitespace chars
"editor.renderIndentGuides": false, // removes indent guides
"editor.renderLineHighlight": "none", // removes line highlight
"editor.overviewRulerBorder": false, // removes border from overview ruler (located on the right, same position as the scrollbar)
"editor.hideCursorInOverviewRuler": true, // hides cursor mark in the overview ruler
"editor.folding": false, // removes the folding feature
"editor.occurrencesHighlight": false, // removes highlights occurrences (still works when you select a word)
"editor.matchBrackets": false, // removes the highlight of matching brackets (I use Subtle Match Brackets extension for this)
@marciobarrios
marciobarrios / .gitconfig
Created March 6, 2017 18:17
Git config (place in ~/.gitconfig)
[filter "lfs"]
required = true
clean = git-lfs clean %f
smudge = git-lfs smudge %f
[user]
name = Marcio Barrios
email = [email protected]
[alias]
co = checkout
br = branch
@marciobarrios
marciobarrios / Brewfile
Created March 6, 2017 18:07
Brewfile generated by bundle package
tap 'caskroom/cask'
tap 'homebrew/bundle'
tap 'homebrew/core'
tap 'homebrew/services'
tap 'phrase/brewed'
tap 'thoughtbot/formulae'
brew 'autoconf'
brew 'libpng'
brew 'freetype'
brew 'fontconfig'
@marciobarrios
marciobarrios / 1.scopes.js
Last active November 24, 2020 14:01
Practical frontend interview
(function() {
var a = b = 5;
})();
console.log(b);
// 1. What will be printed on the console?
// 2. Rewrite the code to return the same result but with the variable declarations separated
// 3. Enable strict mode to explicitly reference the scope