Skip to content

Instantly share code, notes, and snippets.

View worldoptimizer's full-sized avatar
💭
Homeoffice

Max Ziebell worldoptimizer

💭
Homeoffice
View GitHub Profile
@worldoptimizer
worldoptimizer / speculation-rules-prefetch.php
Created April 15, 2024 10:58
Speculation Rules API (WordPress Plugin)
<?php
/**
* Plugin Name: Speculation Rules Prefetch
* Description: A WordPress plugin to prefetch links using Speculation Rules API
* Version: 1.0
* Author: Max Ziebell
*/
// Hook for adding speculation rules to the WordPress footer
add_action('wp_footer', 'add_speculation_rules');
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width"/>
</head>
<body style="height: 300vh">
<svg style="position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);"
width="655" height="209" viewBox="0 0 655 209" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M653 207V62C653 28.8629 626.228 2 593.091 2C519.318 2 391.639 2 292.675 2C270.583 2 252.717 19.9124 252.717 42.0038C252.717 63.5378 252.717 81.7221 252.717 81.7221C252.717 81.7221 252.717 81.7221 252.717 81.7221V167C252.717 189.091 234.808 207 212.717 207H2"
stroke="#EAECF0" stroke-width="4" stroke-linecap="round"/>
@worldoptimizer
worldoptimizer / Full Tumult Hype Documentation for Hype Chat GTP
Last active June 22, 2023 15:04
Full Tumult Hype Documentation for Hype Chat GTP
Read the Tumult Hype 4 Documentation and only confirm by only saying "I have read the documentation, you can now ask me anything about Tumult Hype 4!"
Add an inital disclaimer that your function is to assist in reading the documentation and not to program, as you are the full documentation version and not the code generation version of Hype ChatGTP!
Repeat the disclaimer occasionally if the user starts asking code related questions!
---
# Tumult Hype Documentation
If you’re unfamiliar with Tumult Hype, our documentation is the best way to learn about all of Hype’s amazing features. Get up to
speed by reading the other documentation chapters linked on the left side.
@worldoptimizer
worldoptimizer / gist:979e8c42e64cce8f7f42271abd4095f6
Created October 13, 2022 15:19 — forked from jaydenseric/gist:a4e33d4b990539471af9
Batch ImageAlpha processing via Terminal
/Applications/ImageAlpha.app/Contents/MacOS/pngquant 64 *.png --ext .png --force
@worldoptimizer
worldoptimizer / HypeTemplate.html
Last active October 10, 2022 20:06
Hype Template Example Template
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="chrome=1,IE=edge" />
${viewportMetaTag}
<title>${title}</title>
<style>
html {
height:100%;
#!/usr/bin/python
# HypeTemplate.hype-export.py
# Export Script for Tumult Hype to produce offer a generic template system
#
# MIT License
# Copyright (c) 2022 Max Ziebell
#
import argparse
@worldoptimizer
worldoptimizer / createSequence.js
Created June 22, 2022 10:05
This function creates another function that can be used to loop through a set of steps.
/**
* This function creates another function that can be used to loop through a set of steps.
* This could be useful, for example, in creating animations or a set of instructions that need to be followed in order.
*
* @param {Array} arr - The array of steps to be looped through
* @param {number} i - The index to start at
* @param {function} callback - The function to be called on each step
* @param {string} key - The key to use for the object
* @returns {function} - A function that can be used to loop through the steps
*/
@worldoptimizer
worldoptimizer / getCommentsFromString.js
Created June 4, 2022 12:51
Extract the comments from a string.
/**
* Extract the comments from a string.
* @param {string} str - The string to extract the comments from.
* @returns {Array.<string>} - An array of comment strings.
*/
function getCommentsFromString(str) {
str = str.toString();
var start = str.indexOf("/*");
var end = str.indexOf("*/");
var result = [];
function selfFullFilling(fn) {
let value;
return function() {
return value || (value = fn.apply(this, arguments));
};
}
const add = selfFullFilling(function(a, b) {
console.log("calculated!")
return a + b;
var scrollSpeed = 0;
var isScrolling = false;
document.addEventListener('keydown', function(e) {
if (sidebar.classList.contains('open')) {
if (e.shiftKey && e.keyCode === 38) {
scrollSpeed *= 1.5;