Skip to content

Instantly share code, notes, and snippets.

View phptek's full-sized avatar

Russ Michell phptek

View GitHub Profile
@phptek
phptek / IPFS
Last active December 12, 2018 23:27
1. Censorship resistant resource access.
Govts turn off the internet. (Egypt 2014). Use of peer to peer resource access allows N geographically proximate users accesss to the same file or resources, assuming at least one peer has downloaded them already, for everyone else to get it through them.
2. Broken Links.
The original tenets of the web are violated daily: Links to corporate-supplied services and resources are taken down when censored or when that service goes down or when that corporate goes out of business, or when a hitherto free resource is hidden behind a paywall. Burning books anyone?
3. Verifiability.
@phptek
phptek / depcheck.sh
Created November 29, 2018 20:17
Shell script to check for security vulnerabilities in composer and node deps
#!/bin/bash
#
# Russell Michell 2018 <russellmichell@catalyst.net.nz>
#
# What is this?
#
# Provides an indication of any security vulnerabilities in a project's composer and npm dependencies
errors_npm=0
errors_cmp=0
@phptek
phptek / switchphp
Created June 21, 2018 01:03
switchphp
#!/bin/bash
# Assumes Apache httpd
# Russell Michell 2018 <russellmichell+usevagrant@catalyst.net.nz>
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
{