Skip to content

Instantly share code, notes, and snippets.

View enrico-atzeni's full-sized avatar

Enrico Atzeni enrico-atzeni

View GitHub Profile
@enrico-atzeni
enrico-atzeni / crawl.sh
Last active March 11, 2023 14:36 — forked from antoineMoPa/crawl.sh
Bash Web Crawler
#!/bin/bash
# bash web crawler
# $ bash crawl.sh http://example.com 1
# NOTE: this version ignores static files, see in last pipe of the visit function
# TODO:
# 1. avoid loops by calling same urls ony once per entire script
# 2. do not use txt lists
@enrico-atzeni
enrico-atzeni / hourpicker.js
Last active July 13, 2022 18:56
Javascript circular hour picker
((els) => {
function HPicker(el) {
var self = this;
this.wrapSize = Math.max(parseInt(el.getAttribute('data-size') || 0), 100);
this.mainFontSize = this.wrapSize / 10;
this.spaceForCirculareText = 1.3;
this.canvasSize = this.wrapSize - 2*(this.mainFontSize * this.spaceForCirculareText);
el.insertAdjacentHTML("afterEnd",
@enrico-atzeni
enrico-atzeni / blur-mouse.js
Created June 15, 2022 15:05
Simple in-console mouse-following blur circle
document.body.insertAdjacentHTML("beforeEnd",'<div id="blurme" style="position: fixed;z-index: 999;background: rgba(255,255,255,.1);height: 100px;width:100px;margin:-50px 0 0 -50px;backdrop-filter: blur(5px);border-radius: 5em;"></div>');window.bbb = document.getElementById('blurme');document.body.onmousemove = (e) => {window.bbb.style.left=e.clientX+"px";window.bbb.style.top=e.clientY+"px"}
@enrico-atzeni
enrico-atzeni / lovelace-card-image-updater.js
Last active January 12, 2022 14:37
A simple (and very basic) javascript snippet to auto refresh, forcing a new file fetch (ignoring browser cache) for lovelace card images. Put this file into config/www folder and load in into your dashboard using frontend: extra_module_url setting in the main configuration.yml file
(function(){
function getShadowRoots(wrap) {
if (!wrap) return [];
var found = [];
var els = wrap.querySelectorAll('*');
for (var i=0; i < els.length; i++) {
if (els[i].shadowRoot) found.push(els[i].shadowRoot);
}
return found;
@enrico-atzeni
enrico-atzeni / ea-jquery-lazyloader.js
Last active September 24, 2018 12:24
javascript + jQuery advanced image lazyloader
// LAZY LOAD FOR IMAGES
// make it global so minifier can minify correctly
window.doLoadLazy = function(){};
var initLazyLoad = function(){
// set this as the preload you want to have to load image before they appear in the viewport
// accepts only INT
var offsetPreLoad = 200;