Skip to content

Instantly share code, notes, and snippets.

@arnisjuraga
arnisjuraga / 0_reuse_code.js
Created December 11, 2016 20:02
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@arnisjuraga
arnisjuraga / convert_twig_to_php_opencart.md
Last active April 3, 2020 05:02
A small script with manual steps, how to convert simple TWIG templates back to PHP markup. Used for Opencart, sequence is important. Will be updated as used for any new template.

TODO: automated script

Regex search-replace

Static variables echo


# Strings
@arnisjuraga
arnisjuraga / suffixsearch.php
Last active September 19, 2019 10:32
Search, is array strings matches suffix of another string
<?php
/*
Credits: https://stackoverflow.com/a/10872110/1720476
e.g. I need to search, if given string suffix characters (starts with) "allowed" characters.
$allowed = [ 'LV', 'LT' , 'IBAN' ];
$given = 'LViban8500';
*/
@arnisjuraga
arnisjuraga / HTML_UnEncode.sql
Created February 13, 2020 14:08
Convert HTML entities to HTML code in MySQL
/*
Function converts encoded HTML entities back to HTML tags in pure MySQL
-- Original method: https://stackoverflow.com/a/41460016/1720476
-- @Balmiopour comment added https://stackoverflow.com/questions/3678980/is-there-a-mysql-function-to-decode-html-entities#comment71742861_41460016
Version history:
@arnisjuraga
arnisjuraga / gist:a377c591bdddda17b00108beb0bad1ed
Last active April 15, 2020 10:17
Remove DEFINER from MySQL mysqldump tool backup file
#
# Documented from https://stackoverflow.com/questions/9446783/remove-definer-clause-from-mysql-dumps
#
cat backupfile.sql | sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' | sed -e 's/DEFINER[ ]*=[ ]*[^*]*PROCEDURE/PROCEDURE/' | sed -e 's/DEFINER[ ]*=[ ]*[^*]*FUNCTION/FUNCTION/' > result.sql
#
#
#
@arnisjuraga
arnisjuraga / Readme.md
Last active April 26, 2020 11:36
Codeigniter 4 install, boilerplate, configuration
apt update
apt install php-intl #needed by default
php-sqlite3 #needed by default configuration for tests - uses sqlite 

composer create-project codeigniter4/appstarter myfirstproject
cd myfirstproject
composer require myth/auth:1.*@dev