Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
▶️ Entering flow state

Savvas Radevic medigeek

💭
▶️ Entering flow state
View GitHub Profile
@medigeek
medigeek / timeperiodwithstepping
Created Sep 25, 2020
getting a time period with stepping in php (I know, I know... CarbonPeriod)
View timeperiodwithstepping
<?php
printf("<pre>\n");
$secStep = 5;
$a = strtotime("2020-09-24 07:04:35 UTC");
$b = strtotime("2020-09-24 07:05:50 UTC");
var_dump($a);
var_dump($b);
@medigeek
medigeek / test-spurious-arguments.php
Created Aug 8, 2020
Why is declare(strict_types=1); important -- test with spurious (extra) arguments passed to methods
View test-spurious-arguments.php
<?php
declare(strict_types=1);
//see results:
//using declare(strict_types=1): https://3v4l.org/XJYlJ
//commented out declare(strict_types=1): https://3v4l.org/1bD85
class Fruit {
// Properties
private string $name;
@medigeek
medigeek / carbon-test-tz-conversion.php
Created Jul 7, 2020
test time zone conversion using carbon
View carbon-test-tz-conversion.php
<?php
// date/time variables using CarbonImmutable: https://carbon.nesbot.com/docs/
//set user time zone
$userTimeZone = 'Europe/London';
//======================= UTC ==============================================
//now in UTC
//CarbonImmutable i.e. don't change the hour value when switching timezones
$nowUTC = CarbonImmutable::now('UTC');
//$nowUTC = CarbonImmutable::parse('2020-05-31 23:12:58 UTC');
@medigeek
medigeek / logrotate_script_platform.sh
Last active Jun 20, 2020
logrotate script for platform.sh -- can be modified for other purposes
View logrotate_script_platform.sh
#!/usr/bin/env bash
set -e
SCRIPTDIR=$(dirname "$0")
SCRIPTREALPATH=$(realpath $(dirname "$0"))
#cd "$SCRIPTDIR"
#echo $SCRIPTREALPATH
@medigeek
medigeek / install-magmi-m2.sh
Created Jun 17, 2020
magmi m2 magento2 semi-automated installation
View install-magmi-m2.sh
#Where to install magmi (symlink to vendor/macopedia/magmi2/magmi folder)
MAGMIFOLDER="yourmagmifolder"
#find the version you want using: composer show --all macopedia/magmi2
MAGMIVERSION="v200.7.26"
composer require macopedia/magmi2 $MAGMIVERSION
ln -s vendor/macopedia/magmi2/magmi $MAGMIFOLDER
ls -l $MAGMIFOLDER
@medigeek
medigeek / ebay_siteid_sitename_globalid_map.php
Created Jul 7, 2018
eBay Site ID to Global ID Mapping PHP array
View ebay_siteid_sitename_globalid_map.php
<?php
// Just a basic concept/array of eBay Site ID, Global ID and Site Name
// https://developer.ebay.com/devzone/merchandising/docs/concepts/siteidtoglobalid.html
$ebay_array = [
"siteid" => [
"0", "2", "3", "15", "16",
"23", "71", "77", "100", "101",
"123", "146", "186", "193", "201",
"203", "205", "207", "210", "211",
@medigeek
medigeek / joomla-reset-two-factor.php
Created Apr 9, 2018
Joomla 3.x - Disable two factor authentication plugin, clear otpKey and otep values for all Super Users
View joomla-reset-two-factor.php
<?php
/* This script disables Joomla!'s two factor authentication
* plugin and clears the otpKey and otep values for Super
* Users. It allows you to login when you aren't able to
* use Google authenticator for any reason.
* Usage:
* Place it in the Joomla! 3.x root dir (where configuration.php
* and index.php are) and run it. Then login and leave the
@medigeek
medigeek / pyurl2file.py
Created Jul 25, 2012
Improve http://stackoverflow.com/a/22776/286994 (using .format() instead of % string formatting)
View pyurl2file.py
#!/usr/bin/python
# Improve http://stackoverflow.com/a/22776/286994
# (using .format() instead of % string formatting)
import sys
import urllib2
file_name = url.split('/')[-1]
u = urllib2.urlopen(url)
f = open(file_name, 'wb')
@medigeek
medigeek / ignore_fiemap_errors.patch
Created Mar 9, 2012
libarchive 3.x - quilt patch: Ignore FIEMAP errors on linux < 2.6.28 - e.g. https://bugs.launchpad.net/bugs/942994
View ignore_fiemap_errors.patch
Origin: https://code.google.com/p/libarchive/issues/detail?id=238
Description: Ignore FIEMAP errors on linux < 2.6.28
(most launchpad build daemon servers use ubuntu hardy)
https://bugs.launchpad.net/bugs/942994
Index: libarchive-3.0.3/libarchive/archive_read_disk_entry_from_file.c
===================================================================
--- libarchive-3.0.3.orig/libarchive/archive_read_disk_entry_from_file.c 2012-03-15 23:48:52.000000000 +0100
+++ libarchive-3.0.3/libarchive/archive_read_disk_entry_from_file.c 2012-03-15 23:49:00.000000000 +0100
@@ -855,16 +855,9 @@
@medigeek
medigeek / 02_fix-infinite-loop.patch
Created Mar 4, 2012
quilt patch: fix infinite loop in libarchive when reading xps file [fixes conversion issue for libgxps-utils (e.g. xpstopdf)]
View 02_fix-infinite-loop.patch
Origin: https://code.google.com/p/libarchive/issues/detail?id=226
Description: Fix issue 226 (infinite loop while using libgxps-utils).
The patch is from this merge (adopted to match 3.0.3 release):
https://github.com/libarchive/libarchive/commit/f7cd53ca1eda0d08fc3b3876ed474321b9f70ac7
Index: libarchive-3.0.3/libarchive/archive_read_support_format_zip.c
===================================================================
--- libarchive-3.0.3.orig/libarchive/archive_read_support_format_zip.c 2012-03-04 16:01:31.000000000 +0100
+++ libarchive-3.0.3/libarchive/archive_read_support_format_zip.c 2012-03-04 16:08:52.000000000 +0100
@@ -1093,7 +1093,7 @@
You can’t perform that action at this time.