Skip to content

Instantly share code, notes, and snippets.

View Luxato's full-sized avatar
🎯
Focusing

Lukas S. Luxato

🎯
Focusing
  • Denmark
View GitHub Profile
@Luxato
Luxato / mp4_to_wav.py
Created November 6, 2018 01:28
Convert .mp4 video into .wav voice file. ffmpeg is required
import subprocess
command = "C:/ffmpeg/bin/ffmpeg.exe -i C:/path_to/video.mp4 -ab 160k -ac 2 -ar 44100 -vn audio.wav"
subprocess.call(command, shell=True)
@Luxato
Luxato / git.sh
Created November 14, 2018 22:12
.gitignore does not work.
git rm -r --cached .
git add .
git commit -m ".gitignore is now working"
@Luxato
Luxato / magento.php
Created November 28, 2018 09:43
Magento find product with attribute
<?php
for ($i = 1; $i < 12; $i++) {
$cartProductsCollection = Mage::getModel('catalog/product')->getCollection()
->addStoreFilter($this->getStoreId())
->addAttributeToSelect('*')->setPageSize( 1000 )
->setCurPage( $i );
// FIND PRODUCT WITH COLOR ATTRIBUTE
foreach ( $ProductsCollection as $product) {
$attributes = $product->getAttributes();
@Luxato
Luxato / main.sh
Last active June 1, 2019 16:34
Github utrack without delete
#For single file:
git rm --cached mylogfile.log
#For single directory:
git rm --cached -r mydirectory
# Now you have to put the file/directory into .gitignore
@Luxato
Luxato / array.php
Last active January 14, 2019 12:55
Move array element to different position within the array.
<?php
function moveElement(&$array, $a, $b) {
$out = array_splice($array, $a, 1);
array_splice($array, $b, 0, $out);
}
@Luxato
Luxato / bash.sh
Created February 27, 2019 08:47
Linux Search for a pattern in files
grep -rnw '/etc/path/somewhere/' -e 'pattern'
@Luxato
Luxato / index.html
Last active April 1, 2019 08:13
Deferring CSS assets
<html>
<head>
<!-- This will make the CSS load asynchronously, and also it takes care of users without javascript -->
<link rel="stylesheet" href="styles.css" media="none" onload="if(media!='all')media='all'">
<noscript><link rel="stylesheet" href="styles.css"></noscript>
</head>
</html
@Luxato
Luxato / fix.sql
Created June 18, 2019 08:30
Fix Wordpress DB after moving to new domain
UPDATE wp_posts SET guid = REPLACE(guid, 'olddomain.com', 'newdomain.com') WHERE guid LIKE 'http://olddomain.com/%';
UPDATE wp_posts SET guid = REPLACE(guid, 'olddomain.com', 'newdomain.com') WHERE guid LIKE 'https://olddomain.com/%';
@Luxato
Luxato / bash.sh
Created March 19, 2020 09:58
Git remove orphaned objects
# This will fix errors like this
# error: update_ref failed for ref 'refs/remotes/origin/lukas': cannot lock ref 'refs/remotes/origin/lukas': 'refs/remotes/origin/lukas/css' exists;
# cannot create 'refs/remotes/origin/lukas'
git gc --prune=now
git remote prune origin
git pull
@Luxato
Luxato / getChildrenBundleProducts.php
Last active August 17, 2020 07:57
Magento 1 get Bundle product children qty
<?php
$product = Mage::getModel('catalog/product')
->load(9275);
$collection = $product->getTypeInstance(true)
->getSelectionsCollection($product->getTypeInstance(true)->getOptionsIds($product), $product);
$children_ids = [];