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 / index.php
Last active January 11, 2021 14:51
Magento 1 join collection with table created by subquery
<?php
$productCollection->getSelect()->join(
new Zend_Db_Expr("(SELECT product_id, SUM(impressions) as impressions, SUM(clicks) as clicks, SUM(cart) as cart, SUM(conversions) as conversions, round(SUM(profit), 2) as profit, round(SUM(profit)/SUM(impressions), 3) as rpi
FROM evermart_crosssells_statistics_daily" .
($dateFilter ? " WHERE $dateFilter" : "")
. " GROUP BY product_id)"),
't.product_id = e.entity_id',
array('t.impressions','t.clicks', 't.cart', 't.conversions', 't.profit', 't.rpi')
);
@Luxato
Luxato / sql.sql
Last active January 20, 2022 08:37
Add datetime that updates on update
ALTER TABLE `table_name`
ADD `updated_at` datetime NULL DEFAULT now() on update now();
@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 / notebook.py
Created April 19, 2018 08:43
Install pip package in Jupyter notebook
# Install a pip package in the current Jupyter kernel
import sys
!{sys.executable} -m pip install numpy