Skip to content

Instantly share code, notes, and snippets.

@coelhucas
coelhucas / macos_gmail.md
Last active October 8, 2024 19:14 — forked from roubles/EmailOSXCommandLine.md
Send email from OSX Command line using gmail as SMTP
@coelhucas
coelhucas / what-forces-layout.md
Created June 26, 2024 15:20 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent

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.
@coelhucas
coelhucas / final_example.js
Last active October 16, 2021 20:06
javascript reduce
const components = [
{
name: 'Button',
styles: {
color: 'white',
backgroundColor: 'black',
borderRadius: '20px'
}
},
{
@coelhucas
coelhucas / a11y_studies.js
Created September 28, 2021 21:00
Accessibility studies
// Use this: https://contrast-ratio.com/
/**
* Gets relative luminance from 8-bit RGB color
*/
function getRelativeLuminance(r8bit, g8bit, b8bit) {
const rsRGB = r8bit / 255;
const gsRGB = g8bit / 255;
const bsRGB = b8bit / 255;
@coelhucas
coelhucas / gipply.sh
Last active February 4, 2021 20:57
Gipply takes an URL to a diff and applies with a git apply. Helps to quickly customize dwm, for instance.
#!/bin/bash
url="$1"
# Check if received parameter
if [ -z "$url" ]
then
echo "URL to apply .diff must be supplied"
exit
fi
echo "Applying ${url}..."
#!/usr/bin/env python3
#
# MIT License
#
# Copyright (c) 2020 Victor Gama de Oliveira <hey@vito.io>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
{
"odata.metadata":"http://ott.online.meo.pt/Catalog/v7/$metadata#Channels",
"odata.count":"152",
"value":[
{
"Id":98910,
"Title":"11",
"IsAdult":false,
"InPromotion":false,
"PromotionDescription":null,
{
"config":{
"url":"http://localhost:3000/api/v1.0/bff-plataforma/clientes",
"method":"post",
"data":"{\"nome\":\"lucas\",\"email\":\"lucas@a.co\",\"telefone\":\"(24) 99868-4321\",\"renda\":\"8.391.823,12\"}",
"headers":{
"Accept":"application/json, text/plain, */*",
"Content-Type":"application/json;charset=utf-8"
},
"baseURL":"http://localhost:3000/api",