Skip to content

Instantly share code, notes, and snippets.

View mdcpepper's full-sized avatar

Mike Pepper mdcpepper

View GitHub Profile
@mpdude
mpdude / fix-php-cs.yml
Created May 20, 2022 08:57
Run PHP-CS-Fixer on PRs and commit/push back changes
# .github/workflows/fix-php-cs.yml
on:
pull_request:
name: Coding Standards
jobs:
open-pr-for-cs-violations:
name: PHP-CS-Fixer
runs-on: ubuntu-20.04
@ireade
ireade / sw.js
Last active October 7, 2023 20:56
Handle broken images with the service worker
self.addEventListener('install', (e) => {
e.waitUntil(
caches.open("precache").then((cache) => cache.add("/broken.png"))
);
});
function isImage(fetchRequest) {
return fetchRequest.method === "GET" && fetchRequest.destination === "image";
}
@mattbrailsford
mattbrailsford / aspect-ratio.js
Last active January 18, 2019 18:55
Tailwind CSS Aspect Ratio plugin
const _ = require('lodash');
module.exports = function({ ratios, options, variants }) {
return function({ addUtilities, e }) {
const opts = Object.assign({}, {
orientedRatios: false,
invertedRatios: false
}, options);
@TheLarkInn
TheLarkInn / puppetteer-get-coverage.js
Created June 30, 2018 22:44
Get's coverage data from a url using puppetteer.
const puppetteer = require("puppeteer");
/**
* @param {string} pageUrl The URL that you want to gather coverage data for
*/
const unusedCode = async pageUrl => {
const browser = await puppetteer.launch();
console.log("browser launched");
const page = await browser.newPage();
console.log("new page created");
OpenSimplexNoise noise;
int[][] result;
float t, c;
float ease(float p) {
return 3*p*p - 2*p*p*p;
}
float ease(float p, float g) {
// gif by dave — enjoy! :)
int[][] result;
float t, c;
float ease(float p) {
return 3*p*p - 2*p*p*p;
}
float ease(float p, float g) {
int[][] result;
float t, c;
float ease(float p) {
return 3*p*p - 2*p*p*p;
}
float ease(float p, float g) {
if (p < 0.5)
return 0.5 * pow(2*p, g);
@beesandbombs
beesandbombs / bloom.pde
Created May 24, 2017 23:33
blooming dodecahedron
// by david whyte :)
int[][] result;
float t, c;
float ease(float p) {
return 3*p*p - 2*p*p*p;
}
float ease(float p, float g) {
@Markyparky56
Markyparky56 / OpenSimplexNoise.hpp
Last active April 29, 2022 20:10 — forked from digitalshadow/OpenSimplexNoise.cs
OpenSimplex Noise Refactored for C++
#pragma once
/*******************************************************************************
OpenSimplex Noise in C++
Ported from https://gist.github.com/digitalshadow/134a3a02b67cecd72181
Originally from https://gist.github.com/KdotJPG/b1270127455a94ac5d19
Optimised by DigitalShadow
This version by Mark A. Ropper (Markyparky56)
*******************************************************************************/
#include <array>
#include <vector>
@iben12
iben12 / 1_Laravel_state-machine.md
Last active August 12, 2023 08:36
Laravel: State-machine on Eloquent Model

Implementing State Machine On Eloquent Model*

* Update (12.09.2017): I have improved the trait so that it can be used with objects other than Eloquent Models.

Some days ago I came across a task where I needed to implement managable state for an Eloquent model. This is a common task, actually there is a mathematical model called "Finite-state Machine". The concept is that the state machine (SM) "can be in exactly one of the finite number of states at any given time". Also changing from one state to another (called transition) depends on fulfilling the conditions defined by its configuration.

Practically this means you define each state that the SM can be in and the possible transitions. To define a transition you set the states on which the transition can be applied (initial conditions) and the only state in which the SM should be after the transition.

That's the theory, let's get to the work.