Skip to content

Instantly share code, notes, and snippets.

View rotexdegba's full-sized avatar

Rotimi Ade rotexdegba

View GitHub Profile
@rotexdegba
rotexdegba / mem-consumption-tests.php
Created May 26, 2015 21:45
PHP Script to Benchmark Memory Consumtion on Common Array / Object / String Memory Consumption
<?php
ini_set('memory_limit', '1024M');
function test(){
$index = 0;
//Case 1
$a = '';
@rotexdegba
rotexdegba / common-ubuntu-software-i-use.md
Last active September 28, 2017 20:31
A list of applications I normally use on my Ubuntu or Mint Desktop Machines.
@rotexdegba
rotexdegba / remove-old-linux-kernels.sh
Last active September 9, 2016 22:37
remove old linux kernels in a debian flavored linux distro like ubuntu, mint, etc.
dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge
@rotexdegba
rotexdegba / linux-rails-and-redmin-in-ubuntu-1604-mint18.txt
Last active December 3, 2023 15:49
Installing Rails and Redmine in Ubuntu 16.04 LTS / Linux Mint 18
# Make sure you have already installed apache and mysql;
# 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 \
libmagickcore-dev libmagickwand-dev

See https://cheatsheetseries.owasp.org/, it's more comprehensive and up to date

PHP Security checklist

Basic

  • Strong passwords are used.
  • Passwords stored safely.
  • register_globals is disabled.
@rotexdegba
rotexdegba / format-bytes.php
Created October 13, 2016 04:35
Format Bytes to Readable Unit
<?php
function formatSizeUnits($bytes)
{
if ($bytes >= 1073741824)
{
$bytes = number_format($bytes / 1073741824, 2) . ' GB';
}
elseif ($bytes >= 1048576)
{
$bytes = number_format($bytes / 1048576, 2) . ' MB';
@rotexdegba
rotexdegba / phpword-view-template-for-promis2.0.php
Created July 5, 2017 22:23
phpword-view-template-for-promis2.0
<?php
$phpword_writer_wrapper = new \Promis2\PhpWordWriterWrapper();
// New Word document
$phpWord = new \PhpOffice\PhpWord\PhpWord();
// Do stuff with $phpWord
// ............
// ............
@rotexdegba
rotexdegba / named-js-functions.js
Last active December 12, 2017 20:55
How to execute a JavaScript function when I have its name as a string
// 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")' );
@rotexdegba
rotexdegba / old-collection.php
Created May 13, 2018 06:59
Old Collection Class
<?php
/**
*
* A collection of Cfs_Model_Base_Record records.
* @package Cfs_Model
*
*/
class Cfs_Model_Base_Collection extends Solar_Sql_Model_Collection {
/**