Skip to content

Instantly share code, notes, and snippets.

@AmyStephen
AmyStephen / Women.md
Last active April 20, 2022 03:34
THIS JUST IN: @webandphp Embrace Women in an attempt to Enhance PHPness and Boost Subscriptions

THIS JUST IN: @WebandPHP Embrace Women in an attempt to Enhance PHPness and Boost Subscriptions

< sarcasm >

(PHP) -- A massive sexist storm spanning the globe dumped thousands of foreign messages on unsuspecting geeks as they watched as their tweet stream, normally depicting handy references to JS resources, object oriented design structures and REGEX utilities, turned into a thick sludge of sadness and despair, dividing the community.

Observers agreed, the divide also provided a distinct benefit by making easy work of identifying and arresting misogynist asshats who threaten the very fabric of a community, a community known for communicating using curly brackets, semi-colons and now, with PHP 5.3, namespaces.

Those detained now await no trail, but are able to exercise their right to a quick tagging and permanent display on the Geek Feminist Wiki.

@AmyStephen
AmyStephen / ProxyPattern.php
Last active December 13, 2018 15:26
Example Proxy Pattern implementation in PHP. The example implements an HTTP Proxy using cURL. Try it out on a local server by downloading and opening the page in your browser.
<?php
/**
* @package Design Patterns
* @copyright 2013 Amy Stephen. All rights reserved.
* @license MIT
*
* Proxy Pattern
*
* A proxy pattern creates an entry point which interacts behind the scenes with other objects.
* Can be useful for implementing access control, to implement lazy loading of resource intensive
@AmyStephen
AmyStephen / 1. Molajo.php
Created April 29, 2011 23:01
Administrator Entry Point: Site Router: Molajo (Top) comparison to Joomla! 1.6 (Bottom)
<?php
/**
* @version things.php
* @package Molajo
* @subpackage Entry point
* @copyright Copyright (C) 2011 Individual Molajo Contributors. All rights reserved.
* @license GNU General Public License Version 2, or later http://www.gnu.org/licenses/gpl.html
*/
defined('MOLAJO') or die;
$current_folder = basename(dirname(__FILE__));
@AmyStephen
AmyStephen / bepositive.php
Last active July 6, 2018 13:10
In Defense of Positive Logic over Happy Path
<?php
/**
* Option 1: Happy Path (! $this)
*/
// 1. The world begins.
if (! $this) {
$result = 'No complaints. This is easy to understand and follow.';
@AmyStephen
AmyStephen / LocalWriteTest.php
Last active June 15, 2018 20:05
Delete all files and folders in a directory
<?php
$this->path = BASE_FOLDER . '/x/y/z';
if (file_exists($this->path)) {
$objects = new RecursiveIteratorIterator (
new RecursiveDirectoryIterator($this->path),
RecursiveIteratorIterator::SELF_FIRST);
$directories = array();
@AmyStephen
AmyStephen / Performance.sql
Created July 20, 2013 14:54
To use EXPLAIN or PROCEDURE ANALYSE in phpMyAdmin
// Normal query
SELECT a.id, a.title, b.category
FROM table a,
table b
WHERE a.category_id = b.category_id
// EXPLAIN http://dev.mysql.com/doc/refman/5.0/en/using-explain.html
EXPLAIN SELECT a.id, a.title, b.category
@AmyStephen
AmyStephen / Files.php
Last active July 5, 2017 17:47
General purpose folder and file processing for copy, move, delete, and size calculation
<?php
/**
* File class
*
* @package Molajo
* @copyright 2013 Amy Stephen. All rights reserved.
* @license MIT, GPL v2 or later
*/
namespace Molajo;
@AmyStephen
AmyStephen / tabs.html
Created January 24, 2014 14:10
Foundation 5 - Tabs with embedded grid
<!DOCTYPE html>
<!--[if IE 8]>
<html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Molajo</title>
<link rel="stylesheet" href="/Css/normalize.css">
<?php
/**
* Cat Class
*
* @package Test
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @copyright 2013 Amy Stephen. All rights reserved.
*/
namespace Animal;
@AmyStephen
AmyStephen / wtf.php
Created October 7, 2013 22:37
How do you determine if a value is an Integer?
<?php
// Case 1 Produces:
// int_of_value: 0 is equal to value: dog
$value = 'dog';
$int_of_value = (int) $value;
if ($int_of_value == $value) {
echo 'int_of_value: ' . $int_of_value . ' is equal to value: ' . $value;