Skip to content

Instantly share code, notes, and snippets.

@GDmac
GDmac / rfc.md
Last active August 29, 2015 13:57
Mobile sharing buttons (app or website)

Sharing on the mobile platform

Many smartphone users (probably most) use dedicated apps for their social sharing. However, when clicking on a share button on websites, the user is redirected to the website instead of to the app for twitter and facebook. This document tries to offer an alternative route for sharing on mobile.

User story and technique

  1. When a user clicks the share button for the first time
    ask if he/she wants to use an app or to go to the website.
    Use local storage (jstorage) or cookies to store user preferences.
  2. When the user wants to use the app, use a small script to verify
@GDmac
GDmac / Readme.md
Last active August 29, 2015 14:01
Protected Pages Bolt.cm extension

ProtectedPages extension

Make sections of your site (template) accessible to members only.

Quick Setup

Create a template with a loginform and the processform tag. The form should at least provide username, password and action. e.g.:

@GDmac
GDmac / hello.php
Created May 25, 2014 10:52
Simple request
<?php
$req = parse_url($_SERVER['REQUEST_URI']);
// querystring
isset($req['query']) ? parse_str($req['query'], $req['query_arr']) : $req['query_arr'] = array();
// route
$req['route'] = substr($_SERVER['PHP_SELF'], strlen($_SERVER['SCRIPT_NAME']));
@GDmac
GDmac / pi.debug_override.php
Created June 22, 2014 08:55
Debug Override plugin, disable ExpressionEngine template debugging from a template
<?php
$plugin_info = array(
'pi_name' => 'debug_override',
'pi_version' =>'1.0',
'pi_author' =>'GDmac',
'pi_author_url' => '',
'pi_description' => '',
'pi_usage' => '{exp:debug_override override="all|ajax"} default is override on ajax calls',
);
@GDmac
GDmac / rollyourown.php
Created March 27, 2019 21:48 — forked from mathiasverraes/rollyourown.php
We don't need no DIC libs / we don't need no deps control
<?php
// Context: I'm trying to argue that DI (and DIC) are great, and DIC libs suck.
// Happy to be proven wrong!
final class Router {
private $dependencies;
public function __construct (Dependencies $dependencies) {
$this->dependencies = $dependencies;
// You might say that this is Service Locator, but it's not. This router is toplevel,
// and toplevel must have access to dependencies. After that it can all just bubble nicely using proper DI.
@GDmac
GDmac / upload_example.php
Created April 1, 2019 18:13
composing objects and make methods and objects testable
<?php
require_once __DIR__ . '/../vendor/autoload.php';
$uploadHandler = new \Acme\FileUpload\UploadHandler();
$uploadHandler
->setFormFieldName('upload')
->setTargetDirectory(__DIR__ . '/../uploads')
->addValidator(new JpegFileTypeValidator())
->addValidator(new maxFileSizeValidator(4096))