Skip to content

Instantly share code, notes, and snippets.

View adrian-green's full-sized avatar

Adrian Green adrian-green

  • Australia
  • 21:17 (UTC +10:00)
View GitHub Profile
@adrian-green
adrian-green / reset-trial-navicat.sh
Created August 20, 2024 04:46 — forked from nakamuraos/reset-trial-navicat.sh
Reset trial Navicat 15, Navicat 16, Navicat 17 on Linux
#!/bin/bash
# Author: NakamuraOS <https://github.com/nakamuraos>
# Latest update: 06/24/2024
# Tested on Navicat 15.x, 16.x, 17.x on Debian, Ubuntu.
BGRED="\e[1;97;41m"
ENDCOLOR="\e[0m"
echo -e "${BGRED} ${ENDCOLOR}"
@adrian-green
adrian-green / ArrayPathHelper.php
Created August 12, 2024 00:16 — forked from Neunerlei/ArrayPathHelper.php
A rather simple helper to access php array's using paths. Supporting wildcards and branching.
<?php
/**
* User: Martin Neundorfer and Arnfired Weber
* Date: 01.02.2018
* Time: 10:54
* Vendor: LABOR.digital
*/
namespace Labor\X\Utilities\Arrays\Helpers;
@adrian-green
adrian-green / auto-increment-version.sh
Created April 18, 2024 04:01 — forked from CSTDev/auto-increment-version.sh
Script that will find the last Git Tag and increment it. It will only increment when the latest commit does not already have a tag. By default it increments the patch number, you can tell it to change the major or minor versions by adding #major or #minor to the commit message.
#!/bin/bash
#get highest tag number
VERSION=`git describe --abbrev=0 --tags`
#replace . with space so can split into an array
VERSION_BITS=(${VERSION//./ })
#get number parts and increase last one by 1
VNUM1=${VERSION_BITS[0]}
@adrian-green
adrian-green / MidpointRounding.AwayFromZero.js
Last active August 23, 2023 07:47 — forked from petrosmm/MidpointRounding.AwayFromZero.js
A function to assist in MidpointRounding.AwayFromZero in Javascript
Math.RoundAwayFromZero = function round(num, decimalPlaces) {
const d = decimalPlaces || 2;
const m = Math.pow(10, d);
const n = +(d ? num * m : num).toFixed(8);
const i = Math.ceil(n), f = n - i;
const e = 1e-8;
const r = (f > 0.5 - e && f < 0.5 + e) ?
((i % 2 === 0) ? i : i + 1) : Math.round(n);
return d ? r / m : r;
}
@adrian-green
adrian-green / php-event-extensions.sh
Created March 15, 2022 03:38 — forked from palpalani/php-event-extensions.sh
Installing ev, event and libevent for PHP 7.4 on Ubuntu 20.04
cd /usr/src/
git clone https://github.com/expressif/pecl-event-libevent.git
cd pecl-event-libevent
phpize
./configure
make && sudo make install
sudo apt update
sudo apt install php7.4-dev libevent-dev
#!/bin/bash
# adjust to suit
MODE=live
SITE=https://full.site.domain/
WEBDIR=/srv/magento/${MODE}/www/pub/
# generate a 20 char random file name (will be removed)
RANDOM_SCRIPT_NAME=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 20)
# write temp file
echo "<?php opcache_reset(); ?>" > ${WEBDIR}${RANDOM_SCRIPT_NAME}.php
# issue curl request to flush the opcache under web server context

Redis Desktop Manager for Windows

Yes, it's been done already. No, it's still not particularly easy. You do not need to use either Qt Creator or VS2015.

I am building on information found here, here, and here. Thanks to these folks and the contributors to RDM.

With this document, I sought to "trim the fat" from these other guides and prove that VS2015 itself was not in fact necessary - just its tooling.

Prerequisites

The entire set of inputs is wrapped in a form
<form id="qrgenerate">
Javascript is added that allows the user to load, save, update and remove 'presets'. It uses local storage for the preset data.

ServiceWorker for github pages

This is a ServiceWorker template to turn small github pages into offline ready app.

Why ?

Whenever I make small tools & toys, I create github repo and make a demo page using github pages (like this one).
Often these "apps" are just an index.html file with all the nessesary CSS and JavaScript in it (or maybe 2-3 html/css/js files). I wanted to cache these files so that I can access my tools offline as well.

Notes

Make sure your github pages have HTTPS enforced, you can check Settings > GitHub Pages > Enforce HTTPS of your repository.

#!/bin/bash
#Repo directory name
FNAME=${PWD##*/}
#Latest tag (release)
TAG=`git describe --abbrev=0 --tags`
#Create zip archive named after repo and tag, containing repo contents @HEAD
git archive -9 --prefix $FNAME/ HEAD -o ../$FNAME-$TAG.zip