Skip to content

Instantly share code, notes, and snippets.

@luislobo14rap
luislobo14rap / bug-regex-chrome.js
Created December 30, 2022 12:45
bug-regex-chrome.js
// bug regex uses on chrome
// bug
const regex = /./g;
console.log(regex.test('a')) // true
console.log(regex.test('a')) // false
// no bug
const regex = /./g;
console.log(cloneRegex(regex).test('a')) // true
@luislobo14rap
luislobo14rap / getScrolls.js
Created October 10, 2022 00:30
getScrolls.js
// getScrolls.js v1
const getScrolls = {
element: window,
x: 'scrollX',
y: 'scrollY'
};
if (!('scrollX' in window && 'scrollY' in window)) {
if ('pageXOffset' in window && 'pageYOffset' in window) {
getScrolls.x = 'pageXOffset';
getScrolls.y = 'pageYOffset';
@luislobo14rap
luislobo14rap / flex-center.css
Last active May 6, 2023 03:17
flex-container.css
/* flex-center.css v1 */
.flex-center {
align-items: center;
display: flex;
justify-content: center;
}
@luislobo14rap
luislobo14rap / bs4-media.css
Created October 10, 2022 00:30
bs4-snippets.txt
/* bs4-media.css v1 */
text-align: center;
@media all and(min-width:576px){
text-align: center;
}
@media all and(min-width:768px){
text-align: center;
}
@media all and(min-width:992px){
text-align: center;
@luislobo14rap
luislobo14rap / setTimesout.js
Last active May 11, 2023 12:12
setTimesout.js
// setTimesout.js v2
function setTimesout(function_ = (time, index) => {}, repeats = [0]) {
repeats = repeats.sort((a, b) => {
return a - b
})
for (let i = 0; i < repeats.length; i++) {
setTimeout(() => {
function_(time = repeats[i], index = i)
}, repeats[i])
}
@luislobo14rap
luislobo14rap / mixin-bs4-width-classes.scss
Created October 10, 2022 00:30
mixin-bs4-width-classes.scss
/* mixin-bs4-width-classes.scss v1.0.1 */
$widths:
1
2
3
;
$bs4GridExtended:
576px
768px
@luislobo14rap
luislobo14rap / getScrollbarSize.js
Created October 10, 2022 00:30
getScrollbarSize.js
// getScrollbarSize.js v1
const cssText = '#scrollbar-size{height:99px;overflow:scroll;position:absolute;top:-9999px;width:99px}',
head = document.getElementsByTagName('head')[0] || document.body.parentNode.children[0],
style = document.createElement('style'),
scrollSizeDiv = document.createElement('div'),
scrollbarSize = undefined;
style.setAttribute('type', 'text/css');
style.setAttribute('rel', 'stylesheet');
if (!('styleSheet' in style)) {
style.appendChild(document.createTextNode(cssText));
@luislobo14rap
luislobo14rap / is.js (only for detect chrome in mac and ios).js
Created September 15, 2020 15:25
is.js (only for detect chrome in mac and ios).js
/*!
* is.js 0.9.0
* Author: Aras Atasaygin. Adapted by Luis Lobo
*/
// define 'is' object and current version
let is = {};
is.VERSION = '0.9.0';
// store navigator properties to use later
@luislobo14rap
luislobo14rap / capitalize.js
Created September 6, 2020 15:47
capitalize.js
// capitalize.js v1
function capitalize(text){
return text.replace(/\w/g, function(match){
return match.toUpperCase();
});
};
@luislobo14rap
luislobo14rap / px-to-mm.js
Created September 1, 2020 12:38
px-to-mm.js
// px-to-mm.js v1
function pxToMm(px){
return px * 0.2645833333;
};