Skip to content

Instantly share code, notes, and snippets.

View Potherca's full-sized avatar
🤔
I wonder what this button does…

Ben Peachey Potherca

🤔
I wonder what this button does…
View GitHub Profile
@Potherca
Potherca / composer-checker.php
Created May 3, 2017 07:46
Validate that a project does not require certain composer packages as dependencies. (Rough first draft).
<?php
/**
* This file contains a first rough draft of logic to validate that a project
* does not require certain composer packages as dependencies.
*
* It validates this by checking the project's `composer.lock` file.
*
* Usage:
* php composer-checker.php
@Potherca
Potherca / README.md
Last active May 7, 2017 00:22
Script to setup and install the KunstmaanBundlesCMS to Heroku.

For a hack-session at my current employer we thought it would be fun to see how quickly/easily we could get a version of the KunstMaan CMS deployed on Heroku.

This was in part to evaluate the CMS, but also to familiarize people with Heroku. In order to reproduce the process, I settled for creating a bash script and updating it with each new step I went through.

How hard could it be, right? Turns out that things weren't as simple as one might think.

The CMS does try to make it as easy as possible to get up and running. It offers a clean setup that can be gotten by running the composer create-project command.

From there, a few steps are needed to be made to get things in order to run on Heroku:

@Potherca
Potherca / Event.php
Last active June 3, 2017 21:19
The code from "PHP Bits: Visual Debt" https://laracasts.com/series/php-bits/episodes/1
<?php
final class Event implements EventInterface
{
protected $events = [];
public function listen(string $name, callable $handler) : void
{
$this->events[$name][] = $handler;
}
@Potherca
Potherca / function.ivsprintf.php
Last active July 12, 2017 11:53
PHP `vsprintf` function with string interpolation.
<?php
/**
* In PHP, `sprintf` and family do not support string interpolation.
* Inspired by this `isprintf` implementation: https://gist.github.com/frenck/5b08f3a6c983ff7b7e36
* I was curious if I could make a "cleaner" version.
*
* @author Potherca <potherca@gmail.com>
* @copyright 2017 Potherca
* @license GPLv3
* @version 0.1.0
@Potherca
Potherca / blocksite-allow-with-password-enhancement.js
Created August 27, 2017 13:57
Changes the functionality of the "Enter password to allow" screen of the "BlockSite" Chrome extension to permanently allow a domain.
/* Add dependencies needed to call `addPageToStorage` */
$('head').append('<script src="chrome-extension://eiimnmioipafcokbfikbljfdeojpcgbh/options.js"></script>');
$('body').append('<span id="login_label" style="display:none;"></span>');
trackButton = function(){};
init = function(){};
/* Define our custom event handler */
function handleLoginEvent(event) {
if(event.keyCode === undefined || event.keyCode === 13){
@Potherca
Potherca / store-vendor-outside-dropbox.md
Last active August 31, 2017 09:52
Storing vendor directories outside of Dropbox.

The problem

As a developer, I have a lot of small projects. Proof-of-concepts, simple tools, examples to help explain things.

In order to synchronize these across different computers, the projects directories all live in Dropbox.

Recently it occurred to me that this means all of the vendor code also lives in Dropbox.

Scope of the problem

@Potherca
Potherca / dabblet.css
Created September 7, 2017 13:34
Font size in pseudo element bug in IE
/**
* Font size in pseudo element bug in IE
*/
.element {
font-size: 1em;
}
.element::before {
font-size: 0.7em;
@Potherca
Potherca / README-autowire-traits-in-symfony..md
Last active September 20, 2017 13:33
Example of how a trait can be used to add secondary functionality to classes in Symfony.

Introduction

Example of how a trait can be used to add secondary functionality to classes in Symfony.

(The names of the class files have been changed to lower-case so the this file is shown first in the gist.)

Rational

@Potherca
Potherca / README-amount-of-code-for-the-comparison-of-clamp-functions.md
Last active September 21, 2017 11:04
Amount of code for the comparison of various styles of writing a `clamp` function in PHP Raw
@Potherca
Potherca / README.md
Last active October 6, 2017 14:27
Traits that offer helper functions to be used from PHPUnit TestCases.

⚠️ This project now lives in it's own repository on github ⚠️

Traits for PHPUnit Testcases

Traits that offer helper functions to be used in PHPUnit TestCases.

Introduction