Skip to content

Instantly share code, notes, and snippets.

View anykeyist's full-sized avatar
🇺🇦
Never give up!

Andrii B. anykeyist

🇺🇦
Never give up!
View GitHub Profile
<?php
function compressJS($rawjs) {
$replace = [
"/\/\*[\s\S]*?\*\//" => '', //remove nultile line comment
"/\/\/.*$/" => '', //remove single line comment
'#[\r\n]+#' => "\n", // remove blank lines and \r's
'#\n([ \t]*//.*?\n)*#s' => "\n", // strip line comments (whole line only)
'#([^\\])//([^\'"\n]*)\n#s' => "\\1\n",
'#\n\s+#' => "\n", // strip excess whitespace
@anykeyist
anykeyist / mysql-create-db-user.sh
Created February 23, 2022 04:19 — forked from MagePsycho/mysql-create-db-user.sh
Bash Script: Create MySQL Database & User - https://blog.magepsycho.com/
#!/bin/bash
#
# Script to create MySQL db + user
#
# @author Raj KB <magepsycho@gmail.com>
# @website http://www.magepsycho.com
# @version 0.1.0
################################################################################
@anykeyist
anykeyist / product.php
Created November 26, 2021 06:30 — forked from kalinichenko88/product.php
Получение минимальной цены товара в категории OpenCart
/**
* Получение минимальной цены товара в категории
*
* @file catalog/models/product.php
* @param $category_id
* @return int
*/
public function getMinPriceFromCategory($category_id)
{
$sql = 'SELECT MIN(' . DB_PREFIX . 'product.price) FROM ' . DB_PREFIX . 'product LEFT JOIN ' .
@anykeyist
anykeyist / name2alias.php
Created March 10, 2021 19:23 — forked from alextraza/name2alias.php
Создает slug для opencart
<?php
include 'config.php';
$mysqli = new mysqli('DB_HOSTNAME', 'DB_USERNAME', 'DB_PASSWORD', 'DB_DATABASE');
$sqlChar = 'utf8';
if ($mysqli->connect_errno) {
echo "Извините, возникла проблема на сайте";
exit;
}
@anykeyist
anykeyist / GoogleTranslate.html
Created November 26, 2019 12:22 — forked from brablc/GoogleTranslate.html
Google Translate Snippet
<div id="google-tr">
<div id="google_translate_element"></div>
<script>
function googleTranslateElementInit() {
new google.translate.TranslateElement({
pageLanguage: 'cs'
}, 'google_translate_element');
}
</script>
<script src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
@anykeyist
anykeyist / jq_plugin_visible.js
Created October 16, 2019 05:21
jquery plugin to make element visible-invisible
(function($) {
$.fn.invisible = function() {
return this.each(function() {
$(this).css("visibility", "hidden");
});
};
$.fn.visible = function() {
return this.each(function() {
$(this).css("visibility", "visible");
});
@anykeyist
anykeyist / sass_map_reverse
Created March 11, 2019 05:55
SASS map reverse function
@function mapReverse ($map) {
$result: null;
@if type-of($map) == "map" {
$keys: map-keys($map);
$map-reversed: ();
@for $i from length($keys) through 1 {
$map-reversed: map-merge(
$map-reversed,
@anykeyist
anykeyist / hash_string.js
Last active November 14, 2018 05:46
javascript
/**
* Calculate a 32 bit FNV-1a hash
* Found here: https://gist.github.com/vaiorabbit/5657561
* Ref.: http://isthe.com/chongo/tech/comp/fnv/
*
* @param {string} str the input value
* @param {boolean} [asString=false] set to true to return the hash value as
* 8-digit hex string instead of an integer
* @param {integer} [seed] optionally pass the hash of the previous chunk
* @returns {integer | string}
@anykeyist
anykeyist / rnd_gen.sh
Last active October 22, 2018 13:12
Bash generate random alphanumeric string
#!/bin/bash
# bash generate random alphanumeric string
#
# bash generate random 32 character alphanumeric string (upper and lowercase) and
NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
# bash generate random 32 character alphanumeric string (lowercase only)
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1