<script>
if ((navigator.userAgent.match(/(iphone)|(ipod)|(android)|(blackberry)|(windows phone)|(symbian)/i))){
window.location = "allodomain" + window.location.pathname;
}
</script>
Ανίχνευση κινητού τηλεφώνου
Εξαίρεση Φακέλων ή Αρχείων σε Backup
Αρχείο /etc/cpbackup-exclude.conf
Add
logs
mail
tmp
Φορμάτ ποσών σε SQL
SELECT PRODUCT_SECTOR, FORMAT(SUM(CURRENT_BALANCE_EUR),'C','el-GR') AS '29-OCT' FROM theTabel WHERE REF_DATE = '2021-10-29'
GROUP BY PRODUCT_SECTOR
ORDER BY SUM(CURRENT_BALANCE_EUR) DESC
Μαζική αλλαγή φόρου σε όλα τα προϊόντα
UPDATE mm_product_shop SET id_tax_rules_group = 25 WHERE id_tax_rules_group = 22;
UPDATE mm_product SET id_tax_rules_group = 25 WHERE id_tax_rules_group = 22;
Δημοσιεύθηκε στη Prestashop
Σχολιάστε
Εξαγωγή όλων των προϊόντων με χαρακτηριστικά σε Prestashop
SELECT p.id_product, pl.name as product_name, pa.reference as product_reference, p.ean13 AS product_barcode, GROUP_CONCAT(DISTINCT(pal.name) SEPARATOR ",") as attribute, pa.ean13 AS attribute_barcode, pa.reference AS attribute_reference, ROUND(((p.price * 1.24) - coalesce(rd.reduction,0)),2) AS product_price, ROUND(p.wholesale_price,2) as product_wholesale, manu.name as product_manufacturer, cl.name
FROM mm_product p
LEFT JOIN mm_product_lang pl ON (p.id_product = pl.id_product)
LEFT JOIN mm_category_product cp ON (p.id_product = cp.id_product)
LEFT JOIN mm_category_lang cl ON (cp.id_category = cl.id_category)
LEFT JOIN mm_category c ON (cp.id_category = c.id_category)
LEFT JOIN mm_product_tag pt ON (p.id_product = pt.id_product)
LEFT JOIN mm_product_attribute pa ON (p.id_product = pa.id_product)
LEFT JOIN mm_product_attribute_combination pac ON (pac.id_product_attribute = pa.id_product_attribute)
LEFT JOIN mm_attribute_lang al ON (al.id_attribute = pac.id_attribute)
LEFT JOIN mm_attribute_lang pal ON (pac.id_attribute = pal.id_attribute)
LEFT JOIN mm_manufacturer manu ON (p.id_manufacturer = manu.id_manufacturer)
LEFT JOIN mm_specific_price rd ON (p.id_product = rd.id_product)
WHERE pl.id_lang = 2
AND cl.id_lang = 2
AND p.id_shop_default = 1
AND c.id_shop_default = 1
GROUP BY pac.id_product_attribute
Δημοσιεύθηκε στη Prestashop
Σχολιάστε
Διόρθωση του ps_stock_available
UPDATE mm_stock_available a LEFT JOIN (SELECT id_product, id_product_attribute, SUM(physical_quantity) AS physical_quantityA FROM mm_stock GROUP BY id_product, id_product_attribute) b ON a.id_product = b.id_product AND a.id_product_attribute = b.id_product_attribute SET a.quantity = b.physical_quantityA
Δημοσιεύθηκε στη Prestashop
Σχολιάστε
Ένωση πινάκων με μοναδικές Τιμές
Δημιουργία νέου πίνακα:
ALL ATMS = DISTINCT(UNION(
SELECTCOLUMNS( ATMS; "ATM";'ATMS'[Place]; "OWNED"; "Some Bank" );
SELECTCOLUMNS( 'Euronet ATMS'; "ATM";'Euronet Atms'[Place Fixed];"OWNED"; "Euronet")
))
Custom Query σε Custom Table WordPress
$datotal = $wpdb->get_results( $wpdb->prepare("SELECT SUM(amount) as 'Total_Payments' FROM `aKBTF61_pms_payments` WHERE status = 'completed'"));
echo $datotal[0]->Total_Payments;
Total User Count WordPress using Shortcode
To function παρακάτω δημιουργεί shortcode
// Function to return user count
function tcp_user_count() {
$usercount = count_users();
$result = $usercount['total_users'];
return $result;
}
// Creating a shortcode to display user count
add_shortcode('tuser_count', 'tcp_user_count');
Για page/post χρησιμοποιούμε το shortcode [tuser_count]. Για να το βάλουμε στην php echo do_shortcode(‘[tuser_count]’);
Εξαγωγή των άρθρων με βάση την κατηγορία
SELECT DISTINCT
post_title
, concat('https://www.thewebsite.gr/',post_name)
,(SELECT group_concat(wp_terms.name separator ', ')
FROM wp_terms
INNER JOIN wp_term_taxonomy on wp_terms.term_id = wp_term_taxonomy.term_id
INNER JOIN wp_term_relationships wpr on wpr.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id
WHERE taxonomy= 'category' and wp_posts.ID = wpr.object_id
) AS "Categories"
FROM wp_posts
WHERE post_type = 'post'
AND post_status = 'publish'
ORDER BY
id DESC
Μετατροπή όλων των πινάκων σε InnoDB από MyISAM
Το InnoDB είναι πιο γρήγορο για το wordpress. Εκτός αυτού είναι λιγότερο πιθανό να κρασάρουν πίνακες.
SET @DATABASE_NAME = 'name_of_your_db';
SELECT CONCAT('ALTER TABLE `', table_name, '` ENGINE=InnoDB;') AS sql_statements
FROM information_schema.tables AS tb
WHERE table_schema = @DATABASE_NAME
AND `ENGINE` = 'MyISAM'
AND `TABLE_TYPE` = 'BASE TABLE'
ORDER BY table_name DESC;
Για stored procedure:
DROP PROCEDURE IF EXISTS convertToInnodb;
DELIMITER //
CREATE PROCEDURE convertToInnodb()
BEGIN
mainloop: LOOP
SELECT TABLE_NAME INTO @convertTable FROM information_schema.TABLES
WHERE `TABLE_SCHEMA` LIKE DATABASE()
AND `ENGINE` LIKE 'MyISAM' ORDER BY TABLE_NAME LIMIT 1;
IF @convertTable IS NULL THEN
LEAVE mainloop;
END IF;
SET @sqltext := CONCAT('ALTER TABLE `', DATABASE(), '`.`', @convertTable, '` ENGINE = INNODB');
PREPARE convertTables FROM @sqltext;
EXECUTE convertTables;
DEALLOCATE PREPARE convertTables;
SET @convertTable = NULL;
END LOOP mainloop;
END//
DELIMITER ;
CALL convertToInnodb();
DROP PROCEDURE IF EXISTS convertToInnodb;
Ημερομηνία και ώρα ανανέωσης Δεδομένων
1. New Blank Query.
2. Advanced Editor
let
Source = #table(type table[Date Last Refreshed=datetime], {{DateTime.LocalNow()}})
in
Source
Αποθήκευση των tabs σε διαφορετικό path με Macro
Οι καρτέλες αποθηκεύονται ως αυτοτελή excel. Οι τιμές των κελιών τους αποθηκεύονται ως values.
Option Explicit
Public Sub MISCSV()
Dim wbkExport As Workbook
Dim shtToExport As Worksheet
Set shtToExport = ThisWorkbook.Worksheets("mis")
Set wbkExport = Application.Workbooks.Add
shtToExport.Copy Before:=wbkExport.Worksheets(wbkExport.Worksheets.Count)
Application.DisplayAlerts = False
Worksheets("mis").Cells.Copy
Worksheets("mis").Cells.PasteSpecial xlPasteValues
wbkExport.SaveAs Filename:="C:\MIS\mis.xlsx"
Application.DisplayAlerts = True
wbkExport.Close SaveChanges:=False
Set shtToExport = ThisWorkbook.Worksheets("PORTFOLIO STATISTICS")
Set wbkExport = Application.Workbooks.Add
shtToExport.Copy Before:=wbkExport.Worksheets(wbkExport.Worksheets.Count)
Application.DisplayAlerts = False
Worksheets("Portfolio Statistics").Cells.Copy
Worksheets("Portfolio Statistics").Cells.PasteSpecial xlPasteValues
wbkExport.SaveAs Filename:="C:\mis\PORTFOLIO STATISTICS.xlsx"
Application.DisplayAlerts = True
wbkExport.Close SaveChanges:=False
Set shtToExport = ThisWorkbook.Worksheets("DAILY REVAL")
Set wbkExport = Application.Workbooks.Add
shtToExport.Copy Before:=wbkExport.Worksheets(wbkExport.Worksheets.Count)
Application.DisplayAlerts = False
Worksheets("daily reval").Cells.Copy
Worksheets("daily reval").Cells.PasteSpecial xlPasteValues
wbkExport.SaveAs Filename:="C:\mis\DAILY REVAL.xlsx"
Application.DisplayAlerts = True
wbkExport.Close SaveChanges:=False
Set shtToExport = ThisWorkbook.Worksheets("PORTFOLIO BENCHMARK")
Set wbkExport = Application.Workbooks.Add
shtToExport.Copy Before:=wbkExport.Worksheets(wbkExport.Worksheets.Count)
Application.DisplayAlerts = False
Worksheets("PORTFOLIO BENCHMARK").Cells.Copy
Worksheets("PORTFOLIO BENCHMARK").Cells.PasteSpecial xlPasteValues
wbkExport.SaveAs Filename:="C:\mis\PORTFOLIO BENCHMARK.xlsx"
Application.DisplayAlerts = True
wbkExport.Close SaveChanges:=False
Set shtToExport = ThisWorkbook.Worksheets("SYNOLA")
Set wbkExport = Application.Workbooks.Add
shtToExport.Copy Before:=wbkExport.Worksheets(wbkExport.Worksheets.Count)
Application.DisplayAlerts = False
Worksheets("SYNOLA").Cells.Copy
Worksheets("SYNOLA").Cells.PasteSpecial xlPasteValues
wbkExport.SaveAs Filename:="C:\mis\SYNOLA.xlsx"
Application.DisplayAlerts = True
wbkExport.Close SaveChanges:=False
MsgBox "ALL DONE"
End Sub
Δημοσιεύθηκε στη Microsoft Excel
Σχολιάστε
Αποθήκευση σε διαφορετικό path με Macro
Sub SaveReportMIS()
ActiveWorkbook.SaveCopyAs "Z:\BondsTest\BondsReport.xls"
ActiveWorkbook.Save
MsgBox "Saved"
End Sub
Δημοσιεύθηκε στη Microsoft Excel
Σχολιάστε
Date Dimension Power bi
Dates =
VAR CurrentDate = TODAY()
RETURN
ADDCOLUMNS (
CALENDAR( DATE( 1900; 1; 1); DATE( 2022; 12; 31 ) );
"Year"; YEAR([Date]);
"Month in Year"; MONTH([Date]);
"Month"; FORMAT([Date];"mmm");
"Quarter in Year"; QUARTER([Date]);
"Quarter"; CONCATENATE("Q"; QUARTER([Date]) );
"Month & Year Sort"; FORMAT( [Date]; "yyyymm" );
"Month & Year"; FORMAT([Date];"MMM yyyy");
"Month Offset"; DATEDIFF( CurrentDate; [Date]; MONTH );
"Date Offset"; DATEDIFF( CurrentDate; [Date]; DAY )
)
Max Selected Date (in context) =
MAXX(
KEEPFILTERS(
VALUES( Dates[Date] )
);
CALCULATE(
MIN( Dates[Date] )
)
)
Min Selected Date (in context) =
MINX(
KEEPFILTERS(
VALUES( Dates[Date] )
);
CALCULATE(
MIN( Dates[Date] )
)
)
BankCountNewCustomers =
//COUNTROWS(FILTER(Customers, Customers[DateRegistered].[Year] >= [NewRegisteredMeasure])) + 0
var MINDATE = [Min Selected Date (in context)]
VAR MAXDATE = [Max Selected Date (in context)]
var datasetd = CALCULATETABLE(
values(Customers[gid]); Customers[DateRegistered] >= MINDATE && Customers[DateRegistered] <= MAXDATE)
return
CALCULATE([BankCountAllCustomers]; datasetd)
Selected από φίλτρο Power BI
CALCULATE(
MIN(TransactionsEBanking[Ημερομηνία]);
ALLSELECTED(TransactionsEBanking[Ημερομηνία])
)
Change Date End =
Var _endDate= Maxx(ALLSELECTED('Date'[Date Filer]),ENDOFMONTH('Date'[Date Filer]))
Var _start_date= minx(ALLSELECTED('Date'[Date Filer]),'Date'[Date Filer]))
return
_endDate & " " & _start_date
Δημιουργία πίνακα on the fly για πιο εύκολο φιλτράρισμα αποτελεσμάτων.
Δημιουργία πίνακα on the fly για πιο εύκολο φιλτράρισμα αποτελεσμάτων.
AllPresence = SELECTCOLUMNS(Presence; "name";Presence[member_name];"presabs";Presence[presence])
Υπολογισμός χρόνου σε DAX
-- DATEDIFF computes the delta between two dates, using different units of measure
-- YEAFRAC returns the delta as a fraction (in years)
EVALUATE
VAR StartDate = DATE ( 2011, 01, 01 )
VAR EndDate = DATE ( 2012, 12, 15 )
RETURN
{
( "DATEDIFF Year", DATEDIFF ( StartDate, EndDate, YEAR ) ),
( "DATEDIFF Quarter", DATEDIFF ( StartDate, EndDate, QUARTER ) ),
( "DATEDIFF Month", DATEDIFF ( StartDate, EndDate, MONTH ) ),
( "DATEDIFF Day", DATEDIFF ( StartDate, EndDate, DAY ) ),
( "Subtraction", INT ( EndDate - StartDate ) ),
( "YEARFRAC", YEARFRAC ( StartDate, EndDate ) )
}
MeetingTimeMinsHours =
VAR _all = SUMX( Committees_Meetings; Committees_Meetings[time_end] - Committees_Meetings[time_start] ) * 1
VAR _days = INT( _all )
VAR _time = _all - _days
RETURN FORMAT( _time; "hh:mm")
Διόρθωση Flickering se Windows Forms με διάφανες εικόνες και background
Protected Overloads Overrides ReadOnly Property CreateParams() As CreateParams
Get
Dim cp As CreateParams = MyBase.CreateParams
cp.ExStyle = cp.ExStyle Or 33554432
Return cp
End Get
End Property
Private Sub PreVentFlicker()
With Me
.SetStyle(ControlStyles.OptimizedDoubleBuffer, True)
.SetStyle(ControlStyles.UserPaint, True)
.SetStyle(ControlStyles.AllPaintingInWmPaint, True)
.UpdateStyles()
End With
End Sub
Μικρά χρήσιμα script
//Αλλάζει κείμενο σε div
$('.cart-items').text(response);
//Επιστρέφει κείμενο στο success
toastr.success('<?php echo site_phrase('added_to_the_cart'); ?>');
//Κλείνει το modal
jQuery('#large-modal').modal("toggle");
//Κάνει update συγκεκριμένο div
$('#cartinstoreright').load(location.href+" #cartinstoreright>*","");;
If statement php σε μια γραμμή
<?php echo $row['status'] == 1 ? "checked" : ""; ?>
Repair XFS Filesystem error
xfs_repair /dev/md0
fsck /dev/md1
Check the file system and the re-install the bootloader
Request the rescue-system and then a hardware-reset. Connect to the rescue system.
Possible to mount the RAID?
# mount /dev/md1 /mnt
Yes. Do a file system check (first umount the file system):
# ummount /mnt
# fsck /dev/md1;
Shows some (many) errors. Fixed them by staying on the "y" key. Could use the auto repair option of fsck (-y).
Re-Install the bootloader
This is a Hetzner installimage-setup, so there should be a grub bootloader. Check for the /boot/grub/ folder. Again mount the RAID.
# mount /dev/md1 /mnt
# ls /mnt/boot/grub
It is there, so there is a good chance, that the bootloader is grub, not lilo. Now re-install grub on the disk. Actually on both disks, just in case one is missing.
Make a chroot environment:
# mount /dev/md1 /mnt
# mount -t none -o bind /dev /mnt/dev
# mount -t proc -o bind /proc /mnt/proc
# mount -t sysfs -o bind /sys /mnt/sys
# chroot /mnt
Grub:
# grub
Look for the file stage1 to find the boot partitions
grub> find /grub/stage1
(hd0,1)
(hd1,1)
Install the bootloader on both partitions. Both are regarded as hd0 from the point of view of the bootloader at boot time.
grub> device (hd0) /dev/sda
device (hd0) /dev/sda
grub> root (hd0,1)
root (hd0,1)
Filesystem type is ext2fs, partition type 0xfd
grub> setup (hd0)
setup (hd0)
Checking if "/boot/grub/stage1" exists... yes
Checking if "/boot/grub/stage2" exists... yes
Checking if "/boot/grub/e2fs_stage1_5" exists... yes
Running "embed /boot/grub/e2fs_stage1_5 (hd0)"... 17 sectors are embedded.
succeeded
Running "install /boot/grub/stage1 (hd0) (hd0)1+17 p (hd0,1)...
succeeded
Done.
The same for the other disk
grub> device (hd0) /dev/sdb
grub> root (hd1,1)
grub> setup (hd0)
grub> quit
And reboot - works.
Regular expression για e-mail validation
^ Για να δηλώσουμε την αρχή του string
([a-zA-Z0-9_\-\.]) – Το πρώτο block επιτρέπει όλα τα γράμματα, όλα τα νούμερα, την κάτω παύλα, την παύλα και την τελεία.
@ – Για να κάνει validate το @
([a-zA-Z0-9_\-\.]) – Το πρώτο block επιτρέπει όλα τα γράμματα, όλα τα νούμερα, την κάτω παύλα, την παύλα και την τελεία.
([a-zA-Z) – Το πρώτο block επιτρέπει όλα τα γράμματα.
$ – Για να δηλώσουμε το τέλος του string.
^([a-zA-Z0-9_\-\.])+@+([a-zA-Z0-9_\-\.])+([a-zA-Z])$
Γίνονται validate e-mail της μορφής:
mail@domain.com
mail_d@domain.com
mail.dd@domain.com
mail@sub.domain.com
mail@domain-dot.com
και όλοι οι συνδυασμοί αυτών
Πως προσθέτουμε τα μεταφορικά στο product.tpl στο Prestashop
Controllers/font/ProductController.php
Προσθέτουμε αυτό. Όπου 172 το id του carrier. Το id αλλάζει κάθε φορά που γίνεται επεξεργασία κάποιο στοιχείο του.
//tcp
$default_carrier = new Carrier(172);
$carrier_zones = $default_carrier->getZones();
if (isset($carrier_zones) && !empty($carrier_zones)) {
$first_carrier_zone = $carrier_zones[0][1];
$delivery_price = $default_carrier->getDeliveryPriceByWeight($this->product->weight, 1);
$delivery_priceog = $default_carrier->getDeliveryPriceByWeight($this->product->depth, 1);
if ($delivery_priceog > $delivery_price) {$delivery_price = $delivery_priceog;}
}
else
{
$delivery_price = 'not found';
}
//tcp
Στο product.tpl προσθέτουμε το παρακάτω για να πάρουμε τα μεταφορικά
{$delivery_price}
Δημοσιεύθηκε στη Prestashop
Σχολιάστε
Δημιουργία συντόμευσης εικονιδίου για την Επιφάνεια Εργασίας στα Windows 10
Βάζουμε προορισμό:
%windir%\explorer.exe shell:::{3080F90D-D7AD-11D9-BD98-0000947B0257}
Εικονίδιο:
%SystemRoot%\System32\imageres.dll
Πως κρατάμε αρχείο Mysql bin για όχι περισσότερο από 3 μέρες
Τα αρχεία logs (bins) της mysql πιάνουν πολύ χώρο. Είναι σχεδόν ολόκληρο το μέγεθος της βάσης για κάθε μέρα που κρατιούνται. Καλό είναι να υπάρχει ένα όριο ημερών για να μην γίνεται waste of resources.
[mysqld]
expire_logs_days=3
Πως αλλάζω background σε κλειδωμένο υπολογιστή εταιρείας
Σε command promt πατάμαε το παρακάτω path.
%AppData%\Microsoft\Windows\Themes\
Αντικαθιστούμε τα αρχεία με την εικόνα που θέλουμε. Κάνουμε log off.
SELECT αυτά που δεν υπάρχουν σε συσχετισμένο table
Βρίσκουμε αυτά που δεν κάνουν match
SELECT DISTINCT tags_to_news.tag_id, tags.name FROM `tags_to_news` LEFT OUTER JOIN tags ON tags.id = tags_to_news.tag_id WHERE tags.name IS NULL