Skip to content

Instantly share code, notes, and snippets.

View rosswintle's full-sized avatar

Ross Wintle rosswintle

View GitHub Profile
@rosswintle
rosswintle / Live.js
Created March 2, 2024 15:23
A PHP file watching watching server and JS reloading script for local development
/*
Live.js - One script closer to Designing in the Browser
Written for Handcraft.com by Martin Kool (@mrtnkl).
Updated by Ross Wintle (https://rw.omg.lol) to:
- Use EventSource for server-sent events
- Use async/await
- Use fetch instead of XMLHttpRequest for requests
- Be a JS class
- Use a hash of the HTML to check for content changes
@rosswintle
rosswintle / watch.sh
Last active March 2, 2024 14:56
File watcher shell script - for use with front-end polling script
#!/bin/bash
##
## This script watches for changes in the specified directories and runs the build
## script when changes are detected.
##
## It writes a .modified_time file to the root of the project. This contains the
## timestamp of the last modification time.
##
## This is intended to be used with a front-end script that polls for changes
@rosswintle
rosswintle / live.js
Created March 2, 2024 14:56
JavaScript tool to poll for changes on the server and reload page or assets - based on Live.js
/*
Live.js - One script closer to Designing in the Browser
Written for Handcraft.com by Martin Kool (@mrtnkl).
Updated by Ross Wintle (https://rw.omg.lol) to:
- Use async/await
- Use fetch instead of XMLHttpRequest
- Be a JS class
- Use a separate, project-global modified-time file to check for changes
@rosswintle
rosswintle / build.php
Last active February 8, 2024 20:34
A VERY simple PHP static HTML generator that does a single-level extend, and includes with variable passing and that's about it.
<?php
/*
* Input: files matching src/pages/*.html
* Output: public/*.html
*
* Pages can extend a template by calling:
*
* extend(string $relativeTemplatePath, array $variables)
*
* at the start and:
@rosswintle
rosswintle / AppNavigationMenu.php
Last active September 13, 2023 21:45
Laravel Jetstream Livewire Navigation Menu
<?php
/**
* This class extends the base NavigationClass provided by Jetstream.
* Note that the base class includes the navigation-menu.blade.php
*/
namespace App\Http\Livewire;
class AppNavigationMenu extends \Laravel\Jetstream\Http\Livewire\NavigationMenu
{
@rosswintle
rosswintle / composer.json
Last active July 7, 2022 15:16
WordPress using Composer: composer.json template
{
"name": "your_organisation_or_name/your_project_name",
"repositories": [
{
"type": "composer",
"url": "https://wpackagist.org",
"only": [
"wpackagist-plugin/*",
"wpackagist-theme/*"
]
@rosswintle
rosswintle / spam-pixel.php
Created March 26, 2021 10:23
WordPress Spam Pixel code for WP Forms
<?php
/**
* Plugin Name: Spam Pixel
* Description: This simple plugin integrates Ross's spam pixel idea with WP Forms
* Author: Ross Wintle
* Author URI: https://rosswintle.uk
* Text Domain: spam-pixel
* Domain Path: /languages
* Version: 0.1.0
*
@rosswintle
rosswintle / Stats.php
Created May 17, 2017 08:42
Simple Laravel Service Container/Provider example
<?php
// This is the Stats class I wanted to create. It lives in app/Stats.php, but could be anywhere that the AutoLoader will recognise it
namespace App;
use App\Action;
use Carbon\Carbon;
/**
@rosswintle
rosswintle / wp-full-screen-editor-killer.user.js
Last active February 10, 2022 17:11
WordPress full-screen editor killer
// ==UserScript==
// @name WordPress Full Screen Editor killer
// @namespace http://rosswintle.uk/
// @version 0.1
// @description Auto-removes the full screen editor on WordPress sites
// @author Ross Wintle
// @match https://*/*
// @match http://*/*
// @grant none
// ==/UserScript==
@rosswintle
rosswintle / feedbin-center.js
Created February 7, 2022 22:56
Feedbin: Keep selected centered
// ==UserScript==
// @name Feedbin: Keep selected centered
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Keeps the selected item vertically centered in Feedbin
// @author Ross Wintle
// @match https://feedbin.com/
// @icon https://www.google.com/s2/favicons?domain=feedbin.com
// @grant none
// ==/UserScript==