Skip to content

Instantly share code, notes, and snippets.

@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.
<?php
$xml = new SimpleXMLElement(
'<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/">
<channel>
</channel>
</rss>');
@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))
@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 / pi.example_plugin.php
Created December 31, 2013 14:50
EE Monkee_patch
<?php
$plugin_info = array(
'pi_name' => 'example_plugin',
'pi_version' => '0.1',
'pi_author' => 'John Doe',
'pi_author_url' => '',
'pi_description' => '',
'pi_usage' => '',
);
@GDmac
GDmac / database_DB_driver.php
Last active December 29, 2015 15:19
Codeigniter profiler, where are the queries coming from ?
<?php
// from http://php.net/manual/en/function.debug-backtrace.php#111255
// adapted for codeigniter
// database/DB_driver.php method query()
//...
// Save the query for debugging
if ($this->save_queries == TRUE)
{
$this->queries[] = $sql . "\n# ".get_caller_info();
@GDmac
GDmac / EE_ftp.php
Last active December 29, 2015 01:59 — forked from davist11/Ftp.php
Call with $this->EE->load->library('my_ftp'); It will load CI_ftp and replace $this->EE->ftp with your ftp class
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
require_once(BASEPATH . 'libraries/Ftp.php');
class EE_FTP extends CI_FTP {
var $timeout = 90;
/**
* FTP Connect
@GDmac
GDmac / patch_commit_52e32c475952.patch
Last active December 28, 2015 03:29
CI merge cache, QB/AR no escape
diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php
index f0fe96c35622a77066952d6a23fc526044590df7..d912540b5e2cd825b705088bee2497ba72fd04aa 100644
--- a/system/database/DB_query_builder.php
+++ b/system/database/DB_query_builder.php
@@ -2561,14 +2561,30 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
{
$qb_variable = 'qb_'.$val;
$qb_cache_var = 'qb_cache_'.$val;
- $qb_new = $this->$qb_cache_var;
-
@GDmac
GDmac / _readme.md
Last active December 24, 2015 16:39
ExpressionEngine Core_member add-on

Core_member

an ExpressioneEngine add-on

Core Member is a Mash-up of the old Freemember plugin and cp-login code. This add-on was developed for a hobby-group website that uses EE-Core and to allow member-only templates and members-only content.

Members can be added and edited in the control panel, by the admin. This plugin provides only some very basic member functionality like: login, logout, forgot password, reset password and change password.