Skip to content

Instantly share code, notes, and snippets.

View lmeyer's full-sized avatar
🍷
Working full-time for @winesitting

Ludovic Meyer lmeyer

🍷
Working full-time for @winesitting
View GitHub Profile
@lmeyer
lmeyer / gist:8186263
Created December 30, 2013 18:54
See what ports are used windows
C:\> netstat -a -b
@lmeyer
lmeyer / gist:f12170b46e254caa0c4320c9ae455880
Last active April 24, 2016 12:53
Display SQL queries that need to be run to convert myISAM to InnoDB
SELECT CONCAT('ALTER TABLE ',TABLE_NAME,' ENGINE=InnoDB;')
FROM INFORMATION_SCHEMA.TABLES
WHERE ENGINE='MyISAM'
AND table_schema = 'mydatabase';
@lmeyer
lmeyer / file.sh
Last active April 24, 2016 12:59
View and enable mySQL logs
mysql> SHOW VARIABLES LIKE "general_log%";
+------------------+----------------------------+
| Variable_name | Value |
+------------------+----------------------------+
| general_log | OFF |
| general_log_file | /var/run/mysqld/mysqld.log |
+------------------+----------------------------+
mysql> SET GLOBAL general_log = 'ON';
@lmeyer
lmeyer / gist:fddd7333aba1b076f17cce8d5e4ddbf4
Created August 1, 2016 11:14
Sync local folder with FTP
ncftpput -R -u user -p pass ftp.domain.com remote_dir local_dir
-z to incremental
@lmeyer
lmeyer / gist:b98bdda9237e43179019c84c9de20771
Created October 10, 2016 09:55
Javascript page redirection difference
// similar behavior as an HTTP redirect
window.location.replace("http://stackoverflow.com");
// similar behavior as clicking on a link
window.location.href = "http://stackoverflow.com";
@lmeyer
lmeyer / hdco_set_post_metabox_field.php
Last active October 14, 2016 15:21
Connect Gravity Forms upload field to a Metabox image field
<?php
$gravity_form_id = 1; // gravity form id, or replace {$gravity_form_id} below with this number
add_filter( "gform_after_submission_{$gravity_form_id}", 'hdco_set_post_metabox_field', 10, 2 );
function hdco_set_post_metabox_field( $entry, $form ) {
$gf_images_field_id = 18; // the upload field id
$metabox_field_id = 'images_gallery'; // the metabox field id
if( isset( $entry['post_id'] ) ) {
$post = get_post( $entry['post_id'] );
msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: 2015-10-12 19:24+0200\n"
"PO-Revision-Date: 2015-10-12 19:35+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: fr_FR\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@lmeyer
lmeyer / functions.php
Created January 28, 2017 12:07
Usage of woocommerce_appointments_time_slots_html filter (display left spaces when no booking)
<?php
add_filter('woocommerce_appointments_time_slots_html', 'idl_woocommerce_appointments_time_slots_html', 10, 8);
function idl_woocommerce_appointments_time_slots_html($slot_html, $slots, $intervals, $time_to_check, $staff_id, $from, $timezone, $appointment) {
if ( empty( $intervals ) ) {
$default_interval = 'hour' === $appointment->get_duration_unit() ? $appointment->get_duration() * 60 : $appointment->get_duration();
$custom_interval = 'hour' === $appointment->get_duration_unit() ? $appointment->get_duration() * 60 : $appointment->get_duration();
if ( $appointment->get_interval_unit() && $appointment->get_interval() ) {
$custom_interval = 'hour' === $appointment->get_interval_unit() ? $appointment->get_interval() * 60 : $appointment->get_interval();
}
@lmeyer
lmeyer / main.sh
Last active July 22, 2017 10:40
Magento 2 commands
php bin/magento module:status
php bin/magento module:enable Hdco_CatalogSearch
php bin/magento setup:upgrade
php bin/magento setup:di:compile
find pub/static -name js-translation.json -exec rm -rf {} \;
php bin/magento setup:static-content:deploy en_US fr_FR
php bin/magento cache:clean
php bin/magento indexer:reindex
@lmeyer
lmeyer / gist:bdae4a8a8242349afb5aa23f418082a0
Created December 28, 2017 00:22
Protect gravityforms uploads
RewriteCond %{HTTP_COOKIE} !^.*wordpress_logged_in.*$
RewriteRule ^app/uploads/gravity_forms/(.*)$ /index.php [NC,R=401,L]