Skip to content

Instantly share code, notes, and snippets.

View rotexdegba's full-sized avatar

Rotimi Ade rotexdegba

View GitHub Profile
@rotexdegba
rotexdegba / podman-tutorial.md
Created February 26, 2024 20:34
Podman Tutorial

Podman Tutorials


@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
@rotexdegba
rotexdegba / new-in-php-7-X.md
Created June 18, 2019 17:02
A list of changes in PHP 7.0+ all on one page

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 / rmdirRecursive.php
Created January 28, 2023 23:15
Recursive Directory Deletion PHP
<?php
function rmdirRecursive(string $dir) {
$iter = new RecursiveDirectoryIterator($dir, FilesystemIterator::SKIP_DOTS);
$it = new RecursiveIteratorIterator($iter, RecursiveIteratorIterator::CHILD_FIRST);
foreach($it as $file) {
if ($file->isDir()) {
@rotexdegba
rotexdegba / remove-old-snaps.sh
Created January 28, 2023 03:36
Remove old snap apps from any linux distro with snapd enabled
#!/bin/bash
#Removes old revisions of snaps
#CLOSE ALL SNAPS BEFORE RUNNING THIS
set -eu
LANG=en_US.UTF-8 snap list --all | awk '/disabled/{print $1, $3}' |
while read snapname revision; do
snap remove "$snapname" --revision="$revision"
done
@rotexdegba
rotexdegba / in-array-optimizations.php
Last active September 9, 2022 01:12
Alternative implementation of in_array using either isset or array_key_exists. This approach requires restructuring the original array.
<?php
//This isset optimization is not suitable for arrays that contains null values.
/*
$a = array('a' => null);
isset($a['a']); // Will be FALSE
array_key_exists('a', $a); // Will be TRUE
*/
$total = 10000;
$paragraph = 'this is a sentence. Crud! $$$$!';
@rotexdegba
rotexdegba / div-with-multiple-background-images.js
Last active August 24, 2022 20:13
Use JQuery to enable multiple background images for a div with the images being displayed at a specified interval
// Tested with jQuery v3.3.1
$( document ).ready(function() {
var doVisualUpdates = true;
document.addEventListener('visibilitychange', function(){
doVisualUpdates = !document.hidden;
});
// code below changes the background every 10 seconds for the div with id back-overlay-slider
@rotexdegba
rotexdegba / xdebug-netbeans.md
Last active August 17, 2022 23:08
Debugging PHP with Xdebug in Netbeans 8.2
  • Make sure xdebug is enabled in your php installation
  • The following lines worked for me in my php.ini with PHP 7.2 on Windows 10
[xdebug]
zend_extension ="php_xdebug-2.6.1-7.2-vc15-x86_64.dll"
;xdebug.remote_enable=1
;xdebug.remote_handler=dbgp
;xdebug.remote_mode=req
;xdebug.remote_host=127.0.0.1
;xdebug.remote_port=9000

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.