Skip to content

Instantly share code, notes, and snippets.

View prestarocket's full-sized avatar

Adonis Karavokyros prestarocket

View GitHub Profile
@MWarCZ
MWarCZ / IntersectionObserverWithDirection.js
Last active November 4, 2024 06:17
Intersection observer with detection of vertical scroll direction.
function createIntersectionObserver(callback, opts = { root: null, rootMargin: '0px', threshold: 0}) {
var previousY = new Map();
var observer = new IntersectionObserver(function(entries, observer){
console.log(entries);
entries.forEach(function (entry) {
var currY = entry.boundingClientRect.y;
var prevY = previousY.get(entry.target);
if(currY<prevY) { /* scroll down */ entry.scrollDirectionY = 'down'; }
@PululuK
PululuK / combination_generator.php
Last active January 22, 2021 20:31
Combination genrator
<?php
require(dirname(__FILE__).'/config/config.inc.php');
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
die('êtes vous sûre de réaliser cette action ?? Veuillez soovergarder votre base de données avant');
@tkadlec
tkadlec / perf-diagnostics.css
Last active August 17, 2024 19:33
CSS used to highlight potential performance issues
:root {
--violation-color: red; /* used for clear issues */
--warning-color: orange; /* used for potential issues we should look into */
}
/* IMAGES */
/*
* Lazy-Loaded Images Check
* ====
@colbyfayock
colbyfayock / loading.css
Created May 2, 2020 19:43
CSS Loading Animation
/**
* Loading Animation Snippet
*/
.loading {
color: transparent;
background: linear-gradient(100deg, #eceff1 30%, #f6f7f8 50%, #eceff1 70%);
background-size: 400%;
animation: loading 1.2s ease-in-out infinite;
}
@addyosmani
addyosmani / lazyload.html
Last active November 8, 2022 11:00
Native image lazy-loading with a cross-browser fallback
<img data-src="unicorn.jpg" loading="lazy" alt=".." class="lazyload"/>
<script>
// Select all images with the class "lazyload"
const images = document.querySelectorAll("img.lazyload");
// Check if the browser supports the "loading" attribute
if ('loading' in HTMLImageElement.prototype) {
// If so, we'll update all <img src> to point to the data-src instead
images.forEach(img => {
img.src = img.dataset.src;
@bessfernandez
bessfernandez / setting-up-html-storybook-app.md
Last active September 11, 2024 16:04
How to setup a simple Storybook HTML demo app

icon-storybook-default

Storybook for HTML

Storybook is all about writing stories. A story usually contains a single state of one component, almost like a visual test case.

Typically you see Storybook used for React or other frameworks, but the library has recently introduced the option to use HTML for your Storybook projects. As a prototyping tool or playground this is great! No larger scale knowledge of other frameworks needed.

Install Storybook HTML

@campusboy87
campusboy87 / example-bem-menu.html
Last active October 13, 2023 11:55
Преобразует дефолтное меню WordPress в меню на основе методологии БЭМ с помощью только фильтров меню
<ul class="menu menu--main menu--horizontal">
<li class="menu-node menu-node--main_lvl_1 menu-node--active">
<a href="#" class="menu-link menu-link--active">Пункт 1</a>
<ul class="menu menu--dropdown menu--vertical">
<li class="menu-node menu-node--main_lvl_2">
<a href="#" class="menu-link">Подпункт 1.1</a>
</li>
<li class="menu-node menu-node--main_lvl_2">
<a href="#" class="menu-link">Подпункт 1.2</a>
</li>
@ezirmusitua
ezirmusitua / javascript-resize-debounce.js
Last active September 1, 2023 13:14
[Debounce window resize event] Debounce window resize event #javascript #frontend #perfermance
/* --------------------------------------------
* Detect device orientation
* and trigger changes based on it
--------------------------------------------*/
function updateOrientation() {
// Detect whether device supports orientationchange event, otherwise fall back to the resize event
// Genius solution from http://stackoverflow.com/a/2307936
let supportsOrientationChange = "onorientationchange";
let orientationEvent = supportsOrientationChange ? "orientationchange" : "resize";
let newAngle = null;
@julienbourdeau
julienbourdeau / clean-prestashop-db.sql
Last active September 3, 2024 09:18
Clean PrestaShop database - Drop old and unless data
# Delete all logs
TRUNCATE ps_log;
# Delete old connection data (only used for stats)
# change 2016-02-01 00:00:00 according to you needs
DELETE c, cs
FROM ps_connections c
LEFT JOIN ps_connections_source cs ON (c.id_connections = cs.id_connections)
WHERE c.date_add < '2016-02-01 00:00:00';