Skip to content

Instantly share code, notes, and snippets.

Avatar
💡
You Found Your Solution.

Mr Alexandre ELISÉ application2000

💡
You Found Your Solution.
View GitHub Profile
View Design Patterns: Adapter vs Facade vs Bridge.md

The three design patterns (Adapter, Facade and Bridge) all produce the result of a clean public API. The difference between the patterns are usually due to a subtle context shift (and in some cases, a behavioural requirement).

Adapter

The primary function of an Adapter is to produce a unified interface for a number of underlying and unrelated objects.

You will notice this pattern being utilised in many applications. For example, ActiveRecord (the popular Ruby ORM; object-relational mapping) creates a unified interface as part of its API but the code underneath the interface is able to communicate with many different types of databases. Allowing the consumer of the API to not have to worry about specific database implementation details.

The principle structure of this pattern is:

@application2000
application2000 / automate-require-composer-suggests.sh
Created January 16, 2019 13:11
No more tedious task. Even though this little bash script is improvable It might help you out. Have a nice day!
View automate-require-composer-suggests.sh
#!/bin/bash
MY_PACKAGE_NAME="$1"
MY_COMPOSER_BIN="$(which composer)"
for p in $(cat ${MY_COMPOSER_BIN} suggests ${MY_PACKAGE_NAME});
do
${MY_COMPOSER_BIN} require --dev "$p";
done;
@application2000
application2000 / edit.php
Created January 12, 2019 02:32 — forked from sanderpotjer/edit.php
Template override for improved Joomla article submission form
View edit.php
<?php
/**
* @package Article Form override for Joomla 3
* @copyright Copyright (c) 2014 Sander Potjer - www.perfectwebteam.nl
* @license GNU General Public License version 3 or later
*/
defined('_JEXEC') or die;
JHtml::_('behavior.keepalive');
@application2000
application2000 / f_format_text.sql
Created November 17, 2018 18:43
Replace part of a given text with a chosen character.
View f_format_text.sql
DELIMITER $$
CREATE FUNCTION f_format_text(str VARCHAR (255), replacement VARCHAR(1), ply TINYINT(3), bias DECIMAL(5,2)) RETURNS VARCHAR(255)
BEGIN
DECLARE treshold INT;
DECLARE len INT;
SET len = LENGTH(str);
SET treshold = FLOOR(ply*bias*len);
RETURN (
SELECT REPLACE(str, SUBSTRING(str,treshold), REPEAT(replacement, ((len - treshold) + 1)))
@application2000
application2000 / index.html
Created July 30, 2018 21:26
Wow! You are so Texty!!!
View index.html
<html>
<head>
<script src="https://aframe.io/releases/0.8.2/aframe.min.js"></script>
</head>
<body>
<a-scene>
<a-text id="saymyname" position="-1 2.5 -4" value="Type to touch my heart..." color="hotpink" opacity="1.0">
<a-animation attribute="color" dur="1000" direction="alternate" easing="linear" from="rgb(255,0,0)" to="rgb(255,105,180)" repeat="indefinite"></a-animation>
@application2000
application2000 / index.html
Created July 26, 2018 20:15
Twisted Cube Dimension
View index.html
<html>
<head>
<script src="https://aframe.io/releases/0.8.2/aframe.min.js"></script>
</head>
<body>
<a-scene>
<a-entity id="cubes" rotation="45 45 0" position="0 1.5 -3" scale="0.5 0.5 0.5">
<a-box position="-1 1 -1"></a-box>
<a-box position="-1 1 1"></a-box>
<a-box position="-1 -1 1"></a-box>
View cube-dimension.markdown
@application2000
application2000 / how-to-set-up-stress-free-ssl-on-os-x.md
Created December 3, 2017 15:09 — forked from jed/how-to-set-up-stress-free-ssl-on-os-x.md
How to set up stress-free SSL on an OS X development machine
View how-to-set-up-stress-free-ssl-on-os-x.md

How to set up stress-free SSL on an OS X development machine

One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.

Most workflows make the following compromises:

  • Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.

  • Use production SSL certificates locally. This is annoying

@application2000
application2000 / envoyer_email_version_texte_et_html_avec_api_jmail_joomla_3.md
Created November 15, 2017 20:33
Obtenez un meilleur score et limiter les pourriels. En utilisant cette astuce. Envoyer un courriel en version texte et html avec JMail api de Joomla! 3.
View envoyer_email_version_texte_et_html_avec_api_jmail_joomla_3.md

Envoyer un courriel en version texte et html avec l'api JMail de Joomla! 3

Je suis tombé sur ce problème et voici ce qui a fonctionné pour moi:

$mailer = JFactory::getMailer();
$mailer->setSender($sender);
$mailer->addRecipient($recipient);
$mailer->isHtml($is_html);
$mailer->CharSet  = 'UTF-8';

$mailer->Encoding = 'base64';

@application2000
application2000 / 99-custom-opcache-php.ini
Created October 30, 2017 22:12
Using this file and adjust settings with your setup to improve php overall performance without having to change your code. For performance one should first fix his or her code before using such "fancy sugar" techniques.
View 99-custom-opcache-php.ini
opcache.enable=1
opcache.memory_consumption=512
opcache.max_accelerated_files=50000
opcache.interned_strings_buffer=8
opcache.enable_cli=1
opcache.fast_shutdown=1
opcache.revalidate_freq=10