Skip to content

Instantly share code, notes, and snippets.

View gukandrew's full-sized avatar
🇺🇦

gukandrew

🇺🇦
View GitHub Profile
@gukandrew
gukandrew / git-wheh.sh
Created August 25, 2020 12:21
Script that shows list of files and last change in git for them, files could be passed as params
#!/bin/sh
# Shows list of files and last change in git for them
# USAGE:
# ~/gw.sh [optional: <file1> <file2> ... otherwise current dir will be used]
# complex example
# bash -c "~/gw.sh $(git ls-tree -r --name-only HEAD app/*/web/main.js | tr '\n' ' ')"
#
# based on: https://stackoverflow.com/a/17361406
@gukandrew
gukandrew / docker-compose.yml
Created June 2, 2020 12:07
MariaDB & phpMyAdmin on Alpine Linux using docker-compose.yml
################################################################################
# docker-compose file to run yobasystems/alpine-mariadb & phpmyadmin/phpmyadmin
#
# run with `docker-compose up -d`
# and connect on host using mysql command: `mysql -h127.0.0.1 -uroot -ppassword`
# or over phpMyAdmin http://localhost:8080/
#
# Author Andrew Guk
################################################################################
@gukandrew
gukandrew / magento_quote_selected_custom_option_value.php
Created March 3, 2020 16:20
Get selected values of custom options from Magento2 Quote
<?php
$quoteId = 1;
$ObjectManager = \Magento\Framework\App\ObjectManager::getInstance();
$quoteCollectionFactory = $ObjectManager->create('\Magento\Quote\Model\ResourceModel\Quote\CollectionFactory');
$QuoteRepository = $ObjectManager->create('\Magento\Quote\Model\ResourceModel\Quote\CollectionFactory');
$quote = $quoteCollectionFactory->create()
->addFieldToFilter('quote_id', $quoteId)
->getFirstItem();
@gukandrew
gukandrew / magento2_resave_all_products_with_custom_options.php
Created November 12, 2019 16:04
Force resave all products with custom options for store Magento 2 php script
<?php
use Magento\Framework\App\Bootstrap;
include 'app/bootstrap.php';
// config
$pageSize = 100;
// config end
@gukandrew
gukandrew / magento2_resave_all_products.php
Last active November 12, 2019 16:03
Force resave all products for store Magento 2 php script
<?php
use Magento\Framework\App\Bootstrap;
include 'app/bootstrap.php';
// config
$pageSize = 100;
// config end
// create a bookmark and use this code as the URL, you can now toggle the css on/off
// thanks+credit: https://dev.to/gajus/my-favorite-css-hack-32g3
javascript: (function() {
var styleEl = document.getElementById('css-layout-hack');
if (styleEl) {
styleEl.remove();
return;
}
styleEl = document.createElement('style');
styleEl.id = 'css-layout-hack';
@gukandrew
gukandrew / pure_es6_parse_search_to_object.js
Created July 22, 2019 09:46
Parse url search query to js object (es6)
const parseSearchToObject = (urlSearch) => {
const fromPairs = (pairs) => pairs.reduce((cache, pair) => {
cache[pair[0]] = pair[1];
return cache;
}, {});
return fromPairs(urlSearch.replace('?', '').split('&').map((v) => v.split('=')));
};
@gukandrew
gukandrew / smoothScrollAfterRender.js
Last active July 17, 2019 13:37
Smooth scrollToElement after browser render
# when pass id, mean click action on some link, scroll and replace hash in url
# when no id, gets element id to scroll from url hash
export const scrollToElementAfterBrowserRender = (id) => {
if (!window.requestAnimationFrame) {
return;
}
window.requestAnimationFrame(() => {
const url = new URL(document.location.href);
@gukandrew
gukandrew / pure_es6_reject.js
Last active June 22, 2019 09:34
Pure JS ES6 realization of lodash reject() method. Filter iterable object by condition object (like sql where)
function filterWhere(inputObject, conditions = {}) {
return Object.values(inputObject).filter((r) => {
return !(Object.keys(conditions).every((v) => {
return String(r[v]) === String(conditions[v])
}))
})
}
const data = {
@gukandrew
gukandrew / batch-rename-replace-string.sh
Created June 14, 2019 12:49
Shell Batch rename files using string replacement
for file in *string-to-replace*; do
newname=$(echo $file | sed "s/string-to-replace//");
mv $file $newname;
done;