Skip to content

Instantly share code, notes, and snippets.

Avatar

Tom Schlick tomschlick

View GitHub Profile
View php-cs-fixer.yml
name: 'php-cs-fixer'
on:
- push
jobs:
php-cs-fixer:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
View NullableDate.php
<?php
trait NullableDate
{
/**
* Transform the date for display, add timezone if available
*
* @param string $field_name
*
* @param string $format
@tomschlick
tomschlick / gist:bf5d0437cd21780b4c2b
Created Jun 27, 2014
Cartalyst Stripe Package - Metered Billing Proposal
View gist:bf5d0437cd21780b4c2b

Right now Stripe allows you to add additional invoice items to a subscription when it is charged. For example, say I was a hosting company. I would have the base subscription rate of $20/server/month and then a rate of $0.10/GB of bandwitdth. I may also allow the user to have 10GB free per month in bandwith before the per GB charge takes effect.

Right now that bandwidth can be added manually to the stripe invoice before charging by monitoring the webhooks but it would be really helpful to provide the stripe package those metrics via the events system and for the package to figure out the costs itself.

How I would see it working is that the package would have a new table for these items with a plan ID, metric name, cost per unit and free allowance.

When the stripe event "invoice.created" is captured you the package would fire a "calculating_metered_costs" event (or something similar) that would allow the app to hook into and say that the bandwidth metric for the user is at 25GB.

The package would then cal

View keybase.md

Keybase proof

I hereby claim:

  • I am tomschlick on github.
  • I am tomschlick (https://keybase.io/tomschlick) on keybase.
  • I have a public key whose fingerprint is 5229 1B39 A2EE 92B4 9651 A0C2 1620 7AFA 1D44 7FF8

To claim this, I am signing this object:

View app.php
<?php
// other content
'providers' => array(
'Illuminate\Foundation\Providers\ArtisanServiceProvider',
'Illuminate\Auth\AuthServiceProvider',
'Illuminate\Cache\CacheServiceProvider',
'Illuminate\Foundation\Providers\CommandCreatorServiceProvider',
View hhvm.hdf
PidFile = /var/run/hhvm.pid
Eval {
Jit = true
JitWarmupRequests = 3
}
Log {
Level = Debug
Header = true
@tomschlick
tomschlick / Initials Avatar
Created Sep 17, 2013
Simple example for creating an avatar based on the user's initials and a background color
View Initials Avatar
<?php
$string = 'TS';
$imagine = new Imagine\Gd\Imagine();
$size = new Imagine\Image\Box($imgsize, $imgsize);
$color = new Imagine\Image\Color('#333', 100);
$image = $imagine->create($size, $color);
View gist:4645323
Before posting this article I sent it out to a few friends to give me a reality check. I got enough thumbs up to feel confident posting it, but Chris Hartjes asked me to check outside for the "wahmbulance". I understand that this article is pointless, which to be fair - is the point.
PHP is well known for having an inconsistent API when it comes to PHP functions. Anyone with an anti-PHP point of view will use this as one of their top 3 arguments for why PHP sucks, while most PHP developers will point out that they don't really care. This is mostly because we're either used to it, have a god-like photographic memory or our IDE handles auto-complete so it's a moot point. For me I'm not too fussed because I spend more time trying Googling words like recepie (see, I got that wrong) recipe than I ever spend looking up PHP functions.
Another big thing that anti-PHP folks laugh about is the lack of scalar objects, so instead of $string->length() you have to do strlen($string).
ANOTHER thing that people often joke
@tomschlick
tomschlick / gist:3991659
Created Nov 1, 2012
Composer Include in Fuelphp 1.x
View gist:3991659
// Composer
require dirname(COREPATH).'/vendor/autoload.php';
@tomschlick
tomschlick / gist:3991627
Created Nov 1, 2012
Demo Composer File
View gist:3991627
{
"config": {
"vendor-dir": "fuel/vendor"
},
"minimum-stability": "dev",
"require": {
"php": ">=5.3.6",
"mexitek/phpcolors": "*",
"nategood/httpful": "*",