Skip to content

Instantly share code, notes, and snippets.

View mdcpepper's full-sized avatar

Mike Pepper mdcpepper

View GitHub Profile
@anowell
anowell / auth_controller.rs
Last active August 18, 2024 06:20
Axum Auth: jwt token, accepts either Authz bearer or session cookie
use argon2::{Argon2, PasswordHash};
use axum_extra::extract::cookie::{Cookie, SameSite};
use axum_extra::extract::CookieJar;
async fn login_user(
ctx: State<ApiContext>,
Json(data): Json<LoginUser>,
) -> Result<(CookieJar, Json<LoginResponse>)> {
let user = models::user::get_user_pass_hash(&ctx.db, &data.email)
.await?
@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 May 28, 2024 19:17
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 July 7, 2024 06:37 — 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>