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 / ThemeInterface.php
Created April 18, 2013 21:13
Theme Interface
<?php
/**
* Template Interface
*
* @package Molajo
* @copyright 2013 Amy Stephen. All rights reserved.
* @license http://www.opensource.org/licenses/mit-license.html MIT License
*/
namespace Molajo\Theme\Api;
@AmyStephen
AmyStephen / DatabaseInterface2.php
Last active December 16, 2015 18:09
Database Interface without SQL Object Interaction
<?php
/**
* Database Interface
*
* @package Molajo
* @copyright 2013 Amy Stephen. All rights reserved.
* @license http://www.opensource.org/licenses/mit-license.html MIT License
*/
namespace Molajo\Database\Api;
/**
* Mime types - list by http://www.webmaster-toolkit.com/mime-types.shtml
*/
$mime_types = array(
'.3dm' => 'x-world/x-3dmf',
'.3dmf' => 'x-world/x-3dmf',
'.a' => 'application/octet-stream',
'.aab' => 'application/x-authorware-bin',
'.aam' => 'application/x-authorware-map',
<?php
/**
* Mimetype for your file - requires PHP 5.3, not enabled on default by Windows
*/
$php_mime = finfo_open(FILEINFO_MIME);
$this->mime_type = strtolower(finfo_file($php_mime, $this->your_file_path_and_name));
finfo_close($php_mime);
// Thanks for great discussion from Ben Ramsey, Anthony Ferrara, Dave Reid, Jarvis Badgley
@AmyStephen
AmyStephen / PHP Unit Testing with $_FILES and move_uploaded_file.php
Last active December 16, 2015 23:59
I ran into a couple of challenges for how to unit test my FileUpload package.: mocking $_FILES and PHP function "move_uploaded_file." What I ended up doing was establishing a property named $file_array in my upload class. In the constructor, I set that property to the value contained in $_FILES. Then, I allowed it to be overridden by the value i…
<?php
/**
* $files_array contains $_FILE superglobal
*
* Helps with Unit Testing
*
* @var array
*/
protected $file_array = array();
@AmyStephen
AmyStephen / Translations with Anonymous Function.php
Last active December 17, 2015 02:49
Translations with Anonymous Function
<?php
namespace Molajo;
{
/** Translation Class */
class Language implements LanguageInterface
{
public function translate($key)
{
@AmyStephen
AmyStephen / StandardInjector.php
Created May 17, 2013 05:35
Uses Reflection to extract Constructor Parameters
<?php
/**
* Standard Dependency Injector
*
* @package Molajo
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @copyright 2013 Amy Stephen. All rights reserved.
*/
namespace Molajo\IoC\Handler;
<?php
class ConfigurationInjector extends CustomInjector implements InjectorInterface
{
/**
* Constructor
*
* @param array $option
*
* @since 1.0
*/
@AmyStephen
AmyStephen / 1 Authentication.php
Last active December 17, 2015 21:09
Example of one way to avoid HTML rendering in your class. From https://twitter.com/AmyStephen/status/339777707695030272
<?php
/**
* Generate a token and email a temporary link to change password and sends to user
*
* @param string $session_id
* @param string $username
*
* @return $this|void
* @since 1.0