Skip to content

Instantly share code, notes, and snippets.

View moiseshilario's full-sized avatar
✌️

Moisés Hilario Rodrigues moiseshilario

✌️
View GitHub Profile
@moiseshilario
moiseshilario / reduce_dock_autohide_animation.bash
Created December 10, 2021 19:05
Reduce the Dock autohide animation (MacOS)
# Increase speed of the animation
defaults write com.apple.dock autohide-time-modifier -float 0.35;killall Dock
# remove the delay
defaults write com.apple.Dock autohide-delay -float 0;killall Dock
@moiseshilario
moiseshilario / useFacebook.js
Last active April 21, 2020 22:53
Custom hook to load facebook sdk on React
import { useEffect, useState } from 'react'
const appId = process.env.REACT_APP_FACEBOOK_APP_ID || 'dev_app_id'
const useFacebook = () => {
const [fbSdkLoaded, setFbSdkLoaded] = useState(false)
useEffect(() => {
setupFacebook()
// eslint-disable-next-line react-hooks/exhaustive-deps
@moiseshilario
moiseshilario / cookie.js
Created June 24, 2019 17:43
Handle Cookie JS
@moiseshilario
moiseshilario / deletelocalbranches.sh
Created November 29, 2018 15:54
Delete local branches (git)
# Delete branches that are already merged (but master/development/stage)
git branch --merged | egrep -v "(^\*|master|development|stage)" | xargs git branch -d
# Delete all local branches (but master/development/stage)
git branch | egrep -v "(^\*|master|development|stage)" | xargs git branch -D
@moiseshilario
moiseshilario / slideDragAnimation.js
Created November 7, 2018 18:32
Slide drag animation
// ===================================
// ============ Slide ================
// ===================================
/*
<div class"i-slides">
<div class="i-slide"></div>
<div class="i-slide"></div>
<div class="i-slide"></div>
...
@moiseshilario
moiseshilario / browserDetection.js
Created October 3, 2018 20:08
Browser Detection
function BrowserDetection() {
//Check if browser is IE
if (navigator.userAgent.search('MSIE') !== -1) {
console.log('IE');
}
//Check if browser is Chrome
else if (navigator.userAgent.search('Chrome') !== -1) {
console.log('Chrome');
}
//Check if browser is Firefox
@moiseshilario
moiseshilario / regex.js
Last active July 30, 2018 20:13
Repeated number regex
// Regex to get any repeated numbers in a string
var repeatedNumber = /(\d)\d*\1/
/*
(\d) -> first group (a number in this case) that will be checked by \1
\d* -> any quantity of digits between the number to be checked and the "checker"
\1 -> same stuff that is in the 1st group (in this case, a digit = \d)
e.g
00:
@moiseshilario
moiseshilario / debounce.js
Created March 6, 2018 12:51
Debounce function
const debounce = (func, wait, immediate) => {
let timeout
return function() {
const context = this
const args = arguments
const later = () => {
timeout = null
if(!immediate) func.apply(context, args)
;(function companyNameFromEmail(emailElement, companyElement, $) {
const DEBOUNCE_TIME = 250
const COMPANY_REGEX = /(?<=@).+(?=\.)/
const $companyField = $(companyElement)
const $companyParagraph = $companyField.closest('p')
$companyParagraph.hide()
const toTitleCase = (string) => (
;(function addSecuritySeals(element, $) {
const styleRules = `
#version-2 #confirm-order-step-bottom { width: auto; }
#version-2 #confirm-order-step-bottom .step { margin: 3px; }
.seals {
display: flex;
justify-content: space-between;
}