Skip to content

Instantly share code, notes, and snippets.

View ajardin's full-sized avatar
🏠
Working from home

Alexandre Jardin ajardin

🏠
Working from home
View GitHub Profile
@ajardin
ajardin / categories.sql
Last active April 6, 2018 20:47
How to clean up a Magento database
DELETE cce , cceda , ccede , ccei , ccet , ccev FROM catalog_category_entity cce
LEFT JOIN
catalog_category_entity_datetime AS cceda ON cce.entity_id = cceda.entity_id
LEFT JOIN
catalog_category_entity_decimal AS ccede ON cce.entity_id = ccede.entity_id
LEFT JOIN
catalog_category_entity_int AS ccei ON cce.entity_id = ccei.entity_id
LEFT JOIN
catalog_category_entity_text AS ccet ON cce.entity_id = ccet.entity_id
LEFT JOIN
@ajardin
ajardin / git-contributions.bash
Last active November 9, 2021 16:10
A bash script that generates a report about contributions to a Git repository.
#!/bin/bash
# ====================================================================================================
# The script below allows to have a quick overview of contributions on a Git repository. Bash 4+ is required.
# Especially useful when we do not have access to graphs like those that we can find on Github.
#
# This script handles three non-mandatory parameters:
# - START is used to keep commits only since the given date (default = 01 Jan 2000).
# - END is used to keep commits only until the given date (default = 01 Jan 2050).
# - MINIMUM is used to define the minimum number of commits in order to appear in the report (default = 10).
@ajardin
ajardin / capture.html
Created February 8, 2016 08:51
Capture a thumbnail from a video with JavaScript.
<!DOCTYPE html>
<head>
<script type='text/javascript'>
window.onload = function () {
var video = document.getElementById('videoId');
var canvas = document.getElementById('canvasId');
var img = document.getElementById('imgId');
video.addEventListener('play', function () {
canvas.style.display = 'none';
@ajardin
ajardin / project.local.json
Last active February 25, 2018 22:28
My Proximis configuration file.
{
"Change": {
"Application": {
"development-mode": true
},
"Cache": {
"block": false,
"page": false
},
"Db": {
@ajardin
ajardin / proximis.sh
Created June 28, 2016 12:23
A bash script that initializes/updates a Proximis project.
#!/bin/bash
BEHAVIOR="${1}"
if [[ "${BEHAVIOR}" != "bootstrap" && "${BEHAVIOR}" != "update" && "${BEHAVIOR}" != "reindex" ]]; then
echo "$(tput setaf 1)Please specify a valid behavior: $(tput bold && tput setaf 1)bootstrap$(tput sgr0 && tput setaf 1) or $(tput bold && tput setaf 1)update$(tput sgr0 && tput setaf 1) or $(tput bold && tput setaf 1)reindex$(tput sgr0 && tput setaf 1).$(tput sgr0)"
exit 1
fi
if [[ "${2}" =~ "/" ]]; then
GROUP_NAME=$(echo "${2}" | cut -f1 -d/)
@ajardin
ajardin / main.js
Created September 20, 2016 16:18
Update a JavaScript function body without overwriting the whole code.
/*
In the code below, "form_validation" is a JavaScript function provided by a third-party component. This function validates
and then sends the form values. Since these two behaviors are linked, it's impossible to only validate the form in this state.
But we can update the function without overwriting the whole code.
*/
if (typeof form_validation === 'function') {
var definition = form_validation.toString()
.replace(/myForm\.submit\(\);?/, 'return true;');
@ajardin
ajardin / magento1.conf
Created January 11, 2017 17:06
Nginx/PHP-FM configuration for a Magento1 application
server {
listen 80;
server_name magento1.dev;
root /var/www/html/magento1;
location / {
index index.php;
try_files $uri @rewriteapp;
}
@ajardin
ajardin / .blackfire.yml
Created December 30, 2017 22:54
Blackfire sample for Magento
tests:
Pages should be fast enough:
path: "/.*"
assertions:
- "main.wall_time < 3s"
- "main.io < 1s"
- "main.cpu_time < 2s"
Pages should not consume too much memory:
path: "/.*"
@ajardin
ajardin / mysql-volume.txt
Last active April 17, 2018 15:50
Use MySQL data directly from a Docker volume.
# Extract MySQL data
docker run --rm --volumes-from XXXXX -v $(pwd):/backup busybox sh -c "tar cvf /backup/backup.tar /var/lib/mysql"
# Restore MySQL data
docker run --rm --volumes-from XXXXX -v $(pwd):/backup busybox sh -c "tar xvf /backup/backup.tar var/lib/mysql/"
@ajardin
ajardin / docker-gc.sh
Last active November 9, 2021 16:10
Garbage collector for Docker with Docker.
#!/usr/bin/env bash
set -euo pipefail
# ======================================================================================================================
# Custom implementation of a garbage collector for Docker images, containers and volumes.
#
# Usage:
# bash docker-gc.sh
#
# In order to clean Docker volumes, the argument "-v" must be provided to the script.