Skip to content

Instantly share code, notes, and snippets.

View ProjectOrangeBox's full-sized avatar
👨‍💻
Open to Opportunities

Don Myers ProjectOrangeBox

👨‍💻
Open to Opportunities
  • Philadelphia, Pa
View GitHub Profile
Bash Shell Find Out If a Variable Is Empty Or Not
Let us see syntax and examples in details. The syntax is as follows for if command:
if [ -z "$var" ]
then
echo "\$var is empty"
else
echo "\$var is NOT empty"
fi
OR
@ProjectOrangeBox
ProjectOrangeBox / PHP CleanUp Class
Last active June 11, 2020 17:22
Clean up files in a folder based on regular expression and days as well as database table based on datetime stamp
<?php
class cleanUp
{
static public function folder(string $folder, string $fileRegEx, int $days, bool $recusive = true): int
{
$count = 0;
if (!\FS::file_exists($folder)) {
throw new \Exception('Folder "' . $folder . '" not found.');
@ProjectOrangeBox
ProjectOrangeBox / MySql Backup & Remove
Last active June 18, 2020 13:00
MySql Backup & Remove - with slight modifications
#!/bin/bash
# Script will output dumps for all databases using seperate files
# Derived from this post: http://www.cyberciti.biz/faq/ubuntu-linux-mysql-nas-ftp-backup-script/
USER="local_backup_script"
PASSWORD="LocalBackupScript#429"
HOST="localhost"
MYSQL="$(which mysql)"
MYSQLDUMP="$(which mysqldump)"
GZIP="$(which gzip)"
@ProjectOrangeBox
ProjectOrangeBox / base62.php
Last active April 12, 2021 11:33
base 62 encode / decode
function base62_encode($num) {
$b = 62;
$base = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$r = $num % $b ;
$res = $base[$r];
$q = floor($num/$b);
while ($q) {
$r = $q % $b;
$q = floor($q/$b);
<?php
function table(string $filename): array
{
$fp = fopen($filename, 'r');
if ($fp === false) {
die('could not open file' . chr(10));
}
@ProjectOrangeBox
ProjectOrangeBox / Install Node and Gulp
Created April 30, 2021 17:51
CSS / JS / PUG Gulp files for standard PHP project
Install Gulp
https://nodejs.org/en/
* Install Node
Node.js v12.16.1 to /usr/local/bin/node
npm v6.13.4 to /usr/local/bin/npm
<?php
class readCsv implements Iterator
{
const ROW_SIZE = 8192;
protected $handle = NULL;
protected $currentRow = NULL;
protected $rowCounter = NULL;
protected $hasHeader = null;
@ProjectOrangeBox
ProjectOrangeBox / PHP FS
Last active June 29, 2022 18:41
File System Wrappers based on ROOT folder
<?php
/**
* File System Functions
*
* File System Abstraction which automatically
* works in a given root path
*
* Can be added with composer by adding a composer.json file with:
*
<?php
/**
*
* This content is released under the MIT License (MIT)
*
* @author Don Myers
* @license http://opensource.org/licenses/MIT MIT License
* @link https://github.com/ProjectOrangeBox
*/
@ProjectOrangeBox
ProjectOrangeBox / disc.php
Last active July 7, 2022 23:21
PHP File System Wrapper DISC
<?php
declare(strict_types=1);
/**
* File System Functions
*
* File System Abstraction which automatically
* works in a given root path
*