Skip to content

Instantly share code, notes, and snippets.

View alexalannunes's full-sized avatar
👨‍💻
I'm coding

Alex Alan Nunes alexalannunes

👨‍💻
I'm coding
View GitHub Profile
@alexalannunes
alexalannunes / index.js
Created July 26, 2022 18:32
validate cell of array matrix
var csv = [
["id", "nome", "cidade_id"],
[23, "alex", "pereiro"],
[23, "alex", "pereiro"],
[23, "alex", 3],
]
const col= csv[0][2] // cidade_id
const cel = typeof csv[3][2]; // 3
https://askubuntu.com/a/1062404/1386875
@alexalannunes
alexalannunes / index.js
Last active October 19, 2021 17:30
get route by children routes [test]
const routes = [
{
route: '/registers/company',
childrens: [
"/registers/company/:companyId/edit",
"/registers/company/new",
]
}
]
@alexalannunes
alexalannunes / gist:57a056db8bedced2acc142a1da7c6d02
Last active October 1, 2021 12:07
id generator with while
function a(size = 21) {
let urlAlphabet = "sys_abcdefghijklmnopqrstuvwxyz0123456789";
const length = urlAlphabet.length;
let id = "";
// A compact alternative for `for (var i = 0; i < step; i++)`.
let i = size;
while (i--) {
// `| 0` is more compact and faster than `Math.floor()`.
id += urlAlphabet[(Math.random() * length) | 0];
}
@alexalannunes
alexalannunes / index.js
Created September 23, 2021 15:48
replace vars to value in some text
const vars = [{
name: '{CLIENTE_NOME}',
value: 'Alex Alan Nunes'
}, {
name: '{DATA}',
value: new Date().toLocaleString()
}, {
name: '{PERIODO}',
value: 'manha'
}];
function mask(value, pattern) {
let i = 0;
return pattern.replace(/#/g, () => value[i++]||'');
}
mask('08111998', '##/##/####');
// '08/11/1998'
@alexalannunes
alexalannunes / index.php
Last active July 5, 2021 16:46
fill missing dates with ZERO
<?php
$d1 = '2021-07-01';
$d2 = '2021-07-10';
$dados = [
[
"data" => "2021-07-01",
"value" => 10,
],
@alexalannunes
alexalannunes / scrollable.css
Last active June 17, 2021 12:30
animation slide reverse css
* {
box-sizing: content-box
}
.main {
width: 100%;
margin: 0 auto;
display: flex;
border:1px solid #ccc;
}
.left, .right {
@alexalannunes
alexalannunes / regex-file.js
Last active May 12, 2021 12:02
regex to treat file reading
// [1]: ^#.+ => regex para remover comentarios
// [2]: ^\s*$ ou (\n|\s)$ => regex para remover linhas em branco
// [3]: (.+[a-z]|\n)$ => regex para verificar chave sem igual (=)
// file.cfg
// [1]
#######################################################################################
## Anonymous ##
#######################################################################################
account.1.anonymous_call.server_base_only =
@alexalannunes
alexalannunes / my.config.eslint.json
Created March 31, 2021 15:40
my little rules of eslint
"rules": {
"arrowParens": "always",
"bracketSpacing": true,
"endOfLine": "lf",
"htmlWhitespaceSensitivity": "css",
"insertPragma": false,
"jsxBracketSameLine": false,
"jsxSingleQuote": false,
"printWidth": 220,
"proseWrap": "preserve",