Skip to content

Instantly share code, notes, and snippets.

View phptek's full-sized avatar

Russ Michell phptek

View GitHub Profile
@phptek
phptek / switchphp
Created June 21, 2018 01:03
switchphp
#!/bin/bash
# Assumes Apache httpd
# Russell Michell 2018 <[email protected]>
from=$1
to=$2
update-alternatives --set php /usr/bin/php$to && a2dismod php$from && a2enmod php$to && service apache2 restart
<?php
use SilverStripe\Forms\TextField;
use SilverStripe\View\Requirements;
class YouTubeField extends TextField {
/**
* @var string
* @config
<?php
$wanted = array(2, 4, 6);
$not_wanted = array(3, 5);
$candidates_w = $candiates_nw = [];
for ($i=0; $i < 100; $i++)
{
foreach ($wanted as $w_permid) {
if ($w_permid & $i) {
A SilverStripe locale module base don the categories stipulated in GNU's "Locale Categories" ala: https://www.gnu.org/savannah-checkouts/gnu/libc/manual/html_node/Locale-Categories.html
Talks to see:
* http://scaleconf.co.nz/talks/BethanyMacri.html (8/10)
* http://scaleconf.co.nz/talks/PaulStack.html (7/10)
* http://scaleconf.co.nz/talks/JonahKowall.html (8/10)
* http://scaleconf.co.nz/talks/JohnClegg.html (8/10)
* http://scaleconf.co.nz/talks/DustinWhittle.html (7/10)
* http://scaleconf.co.nz/talks/TravisBischel.html (5/10)
* http://scaleconf.co.nz/talks/KaraHatherly.html (8/10)
* http://scaleconf.co.nz/talks/AlvaroVidela.html (5/10)
PSR-2 says...
* Indentation: 4 spaces
* Newline: UNIX LF
* End of line: No whitespace
* End of file: Single newline (Why? Historical tooling reasons)
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.
@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
{
@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)
/**
* 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
*/