Skip to content

Instantly share code, notes, and snippets.

Rotimi Ade rotexdegba

Block or report user

Report or block rotexdegba

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@rotexdegba
rotexdegba / rector.yaml
Last active Jan 17, 2020
A yaml file containing base Rector configuration setting to be used by the Rector tool on all my php projects
View rector.yaml
# rector.yaml
imports:
# - { resource: 'vendor/rector/rector/config/set/code-quality/code-quality.yaml' }
# - { resource: 'vendor/rector/rector/config/set/php/php52.yaml' }
# - { resource: 'vendor/rector/rector/config/set/php/php53.yaml' }
# - { resource: 'vendor/rector/rector/config/set/php/php54.yaml' }
# - { resource: 'vendor/rector/rector/config/set/php/php55.yaml' }
# - { resource: 'vendor/rector/rector/config/set/php/php56.yaml' }
# - { resource: 'vendor/rector/rector/config/set/php/php70.yaml' }
# - { resource: 'vendor/rector/rector/config/set/php/php71.yaml' }
@rotexdegba
rotexdegba / html5-input-type-number-2-decimal-places.html
Last active Jul 8, 2019
Html5 Input field for currency to 2 decimal places
View html5-input-type-number-2-decimal-places.html
<!DOCTYPE html>
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<form method="post" id="add-edit-form" class="add-edit-form" enctype="multipart/form-data" action="http://localhost:8887/listing-types/edit/2">
<label for="name">Name<span style="color: red;"> *</span></label>
@rotexdegba
rotexdegba / new-in-php-7-X.md
Created Jun 18, 2019
A list of changes in PHP 7.0+ all on one page
View new-in-php-7-X.md

New Stuff in PHP 7.0

  1. Scalar type definitions: they come in two flavours: coercive (default) and strict. The following types for parameters can now be enforced (either coercively or strictly): strings (string), integers (int), floating-point numbers (float), and booleans (bool). They augment the other types introduced in PHP 5: class names, interfaces, array and callable.
    • https://blog.programster.org/php-strict-types
    • Typed pass-by-reference Parameters gotcha: Declared types of reference parameters are checked on function entry, but not when the function returns, so after the function had returned, the argument's type may have changed. For example:
    <?php
    function array_baz(array &$param)
    {
    	$param = 1;
@rotexdegba
rotexdegba / object-has-get-property.php
Created Jun 28, 2018
Object Property Detection and Object Property Value Retrieval
View object-has-get-property.php
<?php
/**
*
* A robust way of retrieving the value of a a specified property in
* an instance of a class.
*
* Works with \stdClass objects created from arrays with numeric key(s)
* (the value of the propertie(s) with numeric key(s) in such \stdClass
* objects will be retrieved by this function).
*
View old-collection.php
<?php
/**
*
* A collection of Cfs_Model_Base_Record records.
* @package Cfs_Model
*
*/
class Cfs_Model_Base_Collection extends Solar_Sql_Model_Collection {
/**
@rotexdegba
rotexdegba / base-class-for-collections.php
Last active Apr 21, 2018
Typed Collection Examples in PHP
View base-class-for-collections.php
<?php
abstract class GenericCollection implements \ArrayAccess, \Countable, \IteratorAggregate {
protected $collection_items;
/**
*
* ArrayAccess: does the requested key exist?
*
* @param string $key The requested key.
@rotexdegba
rotexdegba / named-js-functions.js
Last active Dec 12, 2017
How to execute a JavaScript function when I have its name as a string
View named-js-functions.js
// see also https://stackoverflow.com/questions/359788/how-to-execute-a-javascript-function-when-i-have-its-name-as-a-string
window.example = function () { alert('hello world'); };
//or
name = 'example';
window[name] = function () { alert('hello world'); };
//or
window[name] = new Function( 'alert("hello world")' );
View phpword-view-template-for-promis2.0.php
<?php
$phpword_writer_wrapper = new \Promis2\PhpWordWriterWrapper();
// New Word document
$phpWord = new \PhpOffice\PhpWord\PhpWord();
// Do stuff with $phpWord
// ............
// ............
You can’t perform that action at this time.