Skip to content

Instantly share code, notes, and snippets.

@rotexdegba
rotexdegba / linux-rails-and-redmin-in-ubuntu-1604-mint18.sh
Last active Oct 14, 2020
Installing Rails and Redmine in Ubuntu 16.04 LTS / Linux Mint 18
View linux-rails-and-redmin-in-ubuntu-1604-mint18.sh
# Make sure you have already installed apache and mysql;
# see https://gist.github.com/rotexdegba/d0cab757b5194a58c93db5ab6df7dc67
# for instructions.
# install rails
# https://help.ubuntu.com/lts/serverguide/ruby-on-rails.html
sudo apt install rails
# install comman dependencies
sudo apt-get install build-essential patch ruby-dev zlib1g-dev liblzma-dev make libmysqlclient-dev imagemagick \
@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 / linux-disk-usage.php
Last active Apr 20, 2020
Linux Disk Usage PHP Script
View linux-disk-usage.php
<?php
include_once './vendor/autoload.php';
use jc21\CliTable;
use jc21\CliTableManipulator;
// HOW TO USE:
// copy script ( linux-disk-usage.php ) to a folder on your system and cd to that folder
// composer require jc21/clitable
// php linux-disk-usage.php
@rotexdegba
rotexdegba / rector.yaml
Last active Jan 21, 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 / creating-new-sites-apache2.md
Last active Dec 8, 2019
How to enable new sites in apache2 on ubuntu 16.04 / Mint 18
View creating-new-sites-apache2.md

sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/mynewsite.conf

<VirtualHost *:80>
    ServerName rotimi.dev
	ServerAlias *.rotimi.dev
	ServerAdmin savedrotex@gmail.com
    DocumentRoot /var/www/html/promis-2.0/public

	ErrorLog /var/www/html/promis-2.0/logs/apache-error.log
@rotexdegba
rotexdegba / dropdown-list-in-a-cell-phpexcel.php
Created Nov 21, 2013
How to add drop down list to a cell in PHPExcel
View dropdown-list-in-a-cell-phpexcel.php
<?php
$objValidation = $objPHPExcel->getActiveSheet()->getCell("C$curr_row")->getDataValidation();
$objValidation->setType( PHPExcel_Cell_DataValidation::TYPE_LIST );
$objValidation->setErrorStyle( PHPExcel_Cell_DataValidation::STYLE_INFORMATION );
$objValidation->setAllowBlank(false);
$objValidation->setShowInputMessage(true);
$objValidation->setShowErrorMessage(true);
$objValidation->setShowDropDown(true);
$objValidation->setErrorTitle('Input error');
$objValidation->setError('Value is not in list.');
@rotexdegba
rotexdegba / download-full-copy-of-website-via-wget.sh
Last active Aug 14, 2019
How to download a full copy of a website for offline reading via wget
View download-full-copy-of-website-via-wget.sh
wget --wait=20 --mirror --convert-links --page-requisites --no-parent -U Mozilla http://www.website.com/
# OR
wget --wait=20 --mirror --convert-links --adjust-extension --page-requisites --no-parent -U Mozilla http://www.website.com/
@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 / center-jquery-dialog.php
Last active Oct 3, 2018
Centering a JQuery Dialog
View center-jquery-dialog.php
<script type="text/javascript">
//<![CDATA[
jQuery.noConflict();
jQuery(
function() {
// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
//jQuery( "#dialog:ui-dialog" ).dialog( "destroy" );
jQuery( "#dialog-form" ).dialog({
autoOpen: false,
height: 600,
You can’t perform that action at this time.