Skip to content

Instantly share code, notes, and snippets.

View danieledep's full-sized avatar
👾

dan.dep danieledep

👾
  • Reggio Emilia
View GitHub Profile
@Accudio
Accudio / main.js
Created September 25, 2024 14:02
Shopify + Laravel Mix + Async Alpine for dynamic imports
/**
* This is added to your `main.js` file, the one that imports and runs Async Alpine. Make sure that
* it runs before any `import()` functions by putting as high as possible. That may mean adding it to
* a static import if your other static imports dynamically import immediately.
*/
__webpack_public_path__ = window.assetsPath;
/**
* If you want to automatically register all components within a certain directory as async, you can do
* that with `require.context()` and the fourth param as 'weak'. Add this to your main.js file and
@OrionReed
OrionReed / dom3d.js
Last active June 3, 2025 17:52
3D DOM viewer, copy-paste this into your console to visualise the DOM topographically.
// 3D Dom viewer, copy-paste this into your console to visualise the DOM as a stack of solid blocks.
// You can also minify and save it as a bookmarklet (https://www.freecodecamp.org/news/what-are-bookmarklets/)
(() => {
const SHOW_SIDES = false; // color sides of DOM nodes?
const COLOR_SURFACE = true; // color tops of DOM nodes?
const COLOR_RANDOM = false; // randomise color?
const COLOR_HUE = 190; // hue in HSL (https://hslpicker.com)
const MAX_ROTATION = 180; // set to 360 to rotate all the way round
const THICKNESS = 20; // thickness of layers
const DISTANCE = 10000; // ¯\\_(ツ)_/¯
@pablogiralt
pablogiralt / shopify-handlelize-javascript-function.js
Last active February 6, 2024 13:57
Shopify handlelize function in javascript
// handlelize in liquid: https://github.com/Shopify/liquid/blob/63eb1aac69a31d97e343822b973b3a51941c8ac2/performance/shopify/shop_filter.rb#L100
// how to handlelize in js: https://ricardometring.com/javascript-replace-special-characters
function handlelize (str) {
str = str.normalize('NFD').replace(/[\u0300-\u036f]/g, '') // Remove accents
.replace(/([^\w]+|\s+)/g, '-') // Replace space and other characters by hyphen
.replace(/\-\-+/g, '-') // Replaces multiple hyphens by one hyphen
.replace(/(^-+|-+$)/g, '') // Remove extra hyphens from beginning or end of the string
.toLowerCase(); // To lowercase
from tkinter import *
from PIL import ImageTk,Image
import time
import os
targetImageWidth = 850
targetImageHeight = 400
inputImageWidth = 0
inputImageHeight = 0
attribute float direction;
attribute vec2 distances;
attribute float vertexThickness;
attribute vec3 nextPosition;
attribute vec3 previousPosition;
varying vec2 vUv;
const bool miter = false;
const float miterLimit = 8.0;
// note : if you're on github gist and want to copy paste this code, you can click on the "Raw" button
// and then do Ctrl A, Ctrl C, Ctrl V
// (code below by Kurt Spencer, slightly modified code to run as Processing tab)
// maybe you should rather use this new (improved) version of the noise instead : https://github.com/KdotJPG/OpenSimplex2
/*
* OpenSimplex Noise in Java.
* by Kurt Spencer
*
* v1.1 (October 5, 2014)