Skip to content

Instantly share code, notes, and snippets.

View phptek's full-sized avatar

Russ Michell phptek

View GitHub Profile
/**
*
* Determines if the current page has any translations.
*
* "Translation" means:
*
* >=1 of a page's translated fields e.g. `Title_ar_EG` is populated, And/Or
* >=1 of a page's `has|many_xxx` related classes, itself has >=1 translated + populated field(s), And/Or
* >=1 of a page's arbitrary ORM calls to a DataObject sub-class, itself has >=1 translated & populated field(s)
*
# PHPStorm Issues
## Environment
Ubuntu 14.04 / phpStorm 9.0.2 / OpenJDK 1.7.0_79 / Acer Aspire TimelineX
## Bugs
The IDE occassionally stalls such that I can no longer edit, or make any changes whatsoever to any
tabs that remain open. Neither can I move the caret around using up/down keys. If I switch to another project (in the same window) I cannot
Random notes from PHP Conf NZ 2015
* What core PHP functionality relies on SPL? (Core PHP5 interfaces for everyday use: http://php.net/manual/en/intro.spl.php)
* Take another look at Generators (Reduced memory footprint vs std iteration: http://php.net/manual/en/language.generators.overview.php)
* Look at File();
* Look at Pthreads proper multithreading
* What are co-routines again?
* ZTS Zend Thread Safety
* Performance:
- Measure TTFB
How to configure phpStorm with EditorConfig and PHPMD:
-----------------------------------------------------
PHPMD:
------
phpmd (PHP Mess Detector) is a static analysis tool that will find issues in your code you never knew you had. Your code will still run, follow a few of phpmd's recommendations though and it will be better!
phpmd is already bundled and enabled in phpstorm, but in order to more easily manage versions and add custom rulesets, you should do the following:
@phptek
phptek / gist:c03e2530bdd8b491988b
Created December 16, 2015 23:56
EditorConfig
# Deviate Ltd EditorConfig file
#
# Place this file at the root of your project customisations and rename it: .editorconfig
#
# See: https://en.wikipedia.org/wiki/Newline
# See: http://editorconfig.org/
#
[*.php]
charset = utf-8
/**
* Generate an array of records on reverse class relationships set through a DataExtension.
* E.g. Some DataExtension provides its extended objects with a ManyMany component called 'Fooz'.
*
* On deletion of an extended record, if as we should, we can ensure we clean-up properly and
* remove the relation to the deleted record in the join table.
*
* @param string $manyManyComponentName
* @return array
*/
@phptek
phptek / TUNEZ
Last active March 29, 2021 02:19
Susana Feat Espen Gulbrandsen: "Connection" (Myon & Shane 54 Monsterless Mix) http://www.di.fm/tracks/69386/vocaltrance
Karel: "Transit" http://www.di.fm/tracks/698255/classictrance
Pulser Feat Molly Bankcroft: "In Deep" http://www.di.fm/tracks/56820/vocaltrance
Three Drives: "Greece 2000" (g&m remix) http://www.di.fm/tracks/75438/classictrance
Ferry Corsten feat. Guru: "Junk": http://www.di.fm/tracks/87356/trance
Gods Kitchen Summer Trance CD2: http://www.di.fm/tracks/91421/classictrance
Push: "Tranzy State Of Mind": http://www.di.fm/tracks/29727/classictrance
Cygnus X: "The Orange Theme": http://www.di.fm/tracks/67438/classictrance
Dave Angel "Balance Selections 007" (Soundcloud)
@phptek
phptek / PHP-statics.txt
Created May 24, 2016 09:09
Various uses of PHP's "static" keyword.
PHP's "statics"
1. Static methods within a class.
Note: Allows dev's to encapsulate similar methods within a class, but with the "benefit" of easy access by means of global scope.
Reference: http://php.net/manual/en/language.oop5.static.php
Example:
class Foo
{
Debugging:
"Never, ever assume you think you know where a bug comes from". I have seen developers arbitrarly put in break points and debug statements
and then work there way forwards to the point at which the error manifests. Don't do this, precisely becuase your break point or debug statement *is* arbitrary*.
Becuase the framework or library you're using may have poorly understood or poorly documented, unpredicatable
or plain broken behaviour, then place your breakpoints or add your logging there first and only then work your way forwards.
UX:
"Always assume your user is deaf, dumb, blind and stupid." No offence meant *whatsoever*. If you can get your project to be used by someone of this ilk, you've already won.
PSR-2 says...
* Indentation: 4 spaces
* Newline: UNIX LF
* End of line: No whitespace
* End of file: Single newline (Why? Historical tooling reasons)