Skip to content

Instantly share code, notes, and snippets.

View andrewdalpino's full-sized avatar

Andrew DalPino andrewdalpino

View GitHub Profile
@andrewdalpino
andrewdalpino / Laravel Permissions Policy Middleware
Last active April 20, 2021 05:46
Sets the Permissions-policy response header. By default, opt out of 'interest cohorts' a.k.a. targeted advertising.
<?php
namespace App\Http\Middleware;
use Illuminate\Http\Request;
class PermissionsPolicy
{
/**
* Handle the request and return a response.
<?php
$results = [];
$results[0] = gmp_init(1);
$results[1] = gmp_init(1);
$n = $argv[1] ?? 1000;
if ($n < 2 || $n > PHP_INT_MAX) {
throw new InvalidArgumentException('N cannot be less than 2 or greater than ' . number_format(PHP_INT_MAX) . '.');
<?php
$n = $argv[1] ?? 1000;
$data = [
//
];
/**
* Sort an array by recursively merging a left and right sub array in order.
@andrewdalpino
andrewdalpino / PHP SplStack vs SplQueue vs Array
Last active August 13, 2023 10:39
This is a performance benchmark comparing PHP SplStack, SplQueue, and plain array performance for insert and read/remove operations.
<?php
namespace PhpBenchmarks;
use SplStack;
use SplQueue;
const NUM_TEST_ITEMS = 100000;
const DATA_SIZE = 32; //Bytes.
@andrewdalpino
andrewdalpino / white_elephant_2017.ino
Last active December 15, 2017 03:24
Degeneratesmas 2017 White Elephant Gift - Trippy Arduino Disco Light
/*
White elephant gift for Degeneratesmas 2017
By: Andrew DalPino
*/
#include <Metro.h>
#include <Adafruit_NeoPixel.h>
#include <Bounce2.h>
#define PIXEL_PIN 3