Skip to content

Instantly share code, notes, and snippets.

View adriancmiranda's full-sized avatar
🌱
Today, what did you do for you tomorrow?

Adrian Miranda adriancmiranda

🌱
Today, what did you do for you tomorrow?
View GitHub Profile
@adriancmiranda
adriancmiranda / debounce.ts
Created December 22, 2023 20:47 — forked from ca0v/debounce.ts
Typescript Debounce
// ts 3.6x
function debounce<T extends Function>(cb: T, wait = 20) {
let h = 0;
let callable = (...args: any) => {
clearTimeout(h);
h = setTimeout(() => cb(...args), wait);
};
return <T>(<any>callable);
}
@adriancmiranda
adriancmiranda / tsconfig-all.js
Created December 17, 2023 18:51 — forked from er-ant/tsconfig-all.js
tsconfig.json with comments and explanations
{
// Config for IDE to reload
"compileOnSave": true,
"exclude": [
// Specifies an array of filenames or patterns that should be skipped when resolving include.
// Default:
// ["node_modules", "bower_components", "jspm_packages"], plus the value of outDir if one is specified.
"**/*.spec.ts",
"node_modules"
],
@adriancmiranda
adriancmiranda / .__init.md
Created January 28, 2023 23:51 — forked from rickyalmeidadev/.__init.md
vite + react + @swc/jest
yarn create vite
@adriancmiranda
adriancmiranda / vitals.js
Created January 27, 2023 18:25 — forked from daliborgogic/vitals.js
[POC] Sending Vite.js Core Web Vitals to Google Analytics
const transformer = options => ({
apply: 'post',
transform({ code, isBuild }) {
if (!isBuild) return code
return code.replace('</body>', `<script defer type="module">
const KEY = 'ga:user'
const UID = (localStorage[KEY] = localStorage[KEY] || Math.random() + '.' + Math.random())
const onError = err => console.error('[vite vitals] ', err)
const onDebug = (label, payload) => console.log(label, payload)
@adriancmiranda
adriancmiranda / .gitlab-ci.yml
Created December 16, 2022 23:10 — forked from superjose/.gitlab-ci.yml
This is an example of a .gitlab-ci.yml that is required for Continuous Integration on GitLab projects.
# Reference: https://www.exclamationlabs.com/blog/continuous-deployment-to-npm-using-gitlab-ci/
# GitLab uses docker in the background, so we need to specify the
# image versions. This is useful because we're freely to use
# multiple node versions to work with it. They come from the docker
# repo.
# Uses NodeJS V 9.4.0
image: node:9.4.0
# And to cache them as well.

Disable HTML Form Input Autocomplete and Autofill

  1. Add autocomplete="off" onto <form> element;
  2. Add hidden <input> with autocomplete="false" as a first children element of the form.
<form autocomplete="off" method="post" action="">
    <input autocomplete="false" name="hidden" type="text" style="display:none;">
    ...
@adriancmiranda
adriancmiranda / au.lua
Created October 31, 2022 15:26 — forked from numToStr/au.lua
Neovim autocmd in lua
--
-- Move this file to your neovim lua runtime path ie. ~/.config/nvim/lua/au.lua
--
local cmd = vim.api.nvim_command
local function autocmd(this, event, spec)
local is_table = type(spec) == 'table'
local pattern = is_table and spec[1] or '*'
local action = is_table and spec[2] or spec
if type(action) == 'function' then
@adriancmiranda
adriancmiranda / bash_strict_mode.md
Created October 1, 2022 18:39 — forked from mohanpedala/bash_strict_mode.md
set -e, -u, -o, -x pipefail explanation
export function doInputMask(value: string, pattern: string, placeholder?: string) {
const strippedValue = value.replace(/[^0-9]/g, '');
const chars = strippedValue.split('');
let count = 0;
let formatted = '';
for (let id = 0; id < pattern.length; id += 1) {
const item = pattern[id];
if (chars[count]) {
if (/\*/.test(item)) {
formatted += chars[count];
@adriancmiranda
adriancmiranda / rollup-typescript.md
Created May 20, 2022 15:09 — forked from aleclarson/rollup-typescript.md
The best Rollup config for TypeScript libraries

Features

🔥 Blazing fast builds
😇 CommonJS bundle
🌲 .mjs bundle
.d.ts bundle + type-checking
🧐 Source maps

Install