Skip to content

Instantly share code, notes, and snippets.

View tomschlick's full-sized avatar

Tom Schlick tomschlick

View GitHub Profile
name: 'php-cs-fixer'
on:
- push
jobs:
php-cs-fixer:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
@tomschlick
tomschlick / Environments to bypass .htpasswd protection
Created November 8, 2009 08:30
This allows you to set certain urls/domains that are allowed to bypass a htpasswd protection layer, which is very useful for multiple environment setups (developement, staging, production)
#allows a single uri through the .htaccess password protection
SetEnvIf Request_URI "/testing_uri$" test_uri
#allows everything if its on a certain host
SetEnvIf HOST "^testing.yoursite.com" testing_url
SetEnvIf HOST "^yoursite.com" live_url
Order Deny,Allow
AuthName "Restricted Area"
AuthType Basic
<?php
trait NullableDate
{
/**
* Transform the date for display, add timezone if available
*
* @param string $field_name
*
* @param string $format
PidFile = /var/run/hhvm.pid
Eval {
Jit = true
JitWarmupRequests = 3
}
Log {
Level = Debug
Header = true
<?php
// other content
'providers' => array(
'Illuminate\Foundation\Providers\ArtisanServiceProvider',
'Illuminate\Auth\AuthServiceProvider',
'Illuminate\Cache\CacheServiceProvider',
'Illuminate\Foundation\Providers\CommandCreatorServiceProvider',
@tomschlick
tomschlick / Initials Avatar
Created September 17, 2013 19:40
Simple example for creating an avatar based on the user's initials and a background color
<?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);
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:1397070
Created November 27, 2011 06:10
Conditional .htpasswd
#allows a single uri through the .htaccess password protection
SetEnvIf Request_URI "/testing_uri$" test_uri
#allows everything if its on a certain host
SetEnvIf HOST "^testing.yoursite.com" testing_url
SetEnvIf HOST "^yoursite.com" live_url
Order Deny,Allow
AuthName "Restricted Area"
AuthType Basic
@tomschlick
tomschlick / gist:3991659
Created November 1, 2012 04:10
Composer Include in Fuelphp 1.x
// Composer
require dirname(COREPATH).'/vendor/autoload.php';
@tomschlick
tomschlick / gist:3991627
Created November 1, 2012 04:01
Demo Composer File
{
"config": {
"vendor-dir": "fuel/vendor"
},
"minimum-stability": "dev",
"require": {
"php": ">=5.3.6",
"mexitek/phpcolors": "*",
"nategood/httpful": "*",