Skip to content

Instantly share code, notes, and snippets.

View gugadev's full-sized avatar
🌐
Web & Mobile

Gustavo García gugadev

🌐
Web & Mobile
View GitHub Profile
@gugadev
gugadev / what-forces-layout.md
Created September 14, 2020 23:04 — 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
@gugadev
gugadev / launch.json
Created February 2, 2020 14:43 — forked from cecilemuller/launch.json
Run ts-node in VSCode Debugger
{
"version": "0.2.0",
"configurations": [
{
"name": "Node Inspector",
"type": "node",
"request": "launch",
"args": ["${workspaceRoot}/src/service.ts"],
"runtimeArgs": ["-r", "ts-node/register"],
"cwd": "${workspaceRoot}",
@gugadev
gugadev / flatten-array.js
Created January 21, 2020 18:03
Flatten an array with n deep levels.
const source = [[1, 2, [3, [4]]], 5]
const flatArray = (src) => {
const flattened = []
function isArray(value) {
return value instanceof Array
}
// do not modify the original array, instead, clone it
@gugadev
gugadev / ios-chrome-devtools.md
Created September 24, 2019 14:53 — forked from james2doyle/ios-chrome-devtools.md
Enable remote debugging on the iOS simulator using Chrome Dev Tools

Install the tools:

brew install ios-webkit-debug-proxy

Run the simulator. And choose an iOS 10 device. The chrome remote debugging doesn't work with iOS 11 yet.

Enable the inspector

@gugadev
gugadev / style.css
Created September 17, 2019 18:22 — forked from Kvaibhav01/style.css
CSS file for Material ripple effect without JS
.container {
background-color: #c1c1c1;
height: 500px;
display: flex;
justify-content: center;
align-items: center;
}
.btn {
background-color: orange;
@gugadev
gugadev / camelToKebab.js
Created September 8, 2019 01:36 — forked from nblackburn/camelToKebab.js
Convert a string from camel case to kebab case.
module.exports = (string) => {
return string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2').toLowerCase();
};
@gugadev
gugadev / accordion.component.ts
Last active August 7, 2019 20:03
Pacífico Elements snippets
import { Component } from '@angular/core'
import '@pacificoseguros/elements/accordion'
import '@pacificoseguros/elements/typography'
import '@pacificoseguros/elements/number'
import '@pacificoseguros/icons/ambulance'
@Component({
selector: 'app-accordion-demo',
templateUrl: './accordion.html'
})
@gugadev
gugadev / ce-pragma.ts
Last active December 2, 2023 07:44
custom-elements-jsx-pragma
import React, { FunctionComponent, ReactChild } from 'react'
const listeners = Symbol('jsx-web-comp/event-listeners')
const eventPattern = /^onEvent/
const toKebabCase = (str: string): string => str.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2').toLowerCase()
export default function jsx (type: string | FunctionComponent, props: Record<string, any>, ...children: ReactChild[]) {
const isCustomElement = customElements.get(type as string)
const newProps = { ...props }
@gugadev
gugadev / observables.ts
Last active January 18, 2019 16:37
RxJs Observables
import chalk from 'chalk';
import {
Observable,
Observer,
Subscription,
Subject,
Subscriber,
ConnectableObservable,
BehaviorSubject,
ReplaySubject,
@gugadev
gugadev / README.md
Last active October 26, 2018 17:20
IP Locator
yarn install
yarn run shit --ip=<ip here>