Skip to content

Instantly share code, notes, and snippets.

View erighetto's full-sized avatar

Emanuel Righetto erighetto

View GitHub Profile
@erighetto
erighetto / functions.php
Last active January 3, 2016 16:29
Displaying recent posts in WordPress with WPML plugin
<?php
function icl_get_recent_posts($limit = 10, $language) {
global $wpdb;
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
if (is_plugin_active('sitepress-multilingual-cms/sitepress.php')) {
$querystr = "
SELECT wposts.*
FROM {$wpdb->prefix}posts wposts, {$wpdb->prefix}icl_translations icl_translations
WHERE wposts.ID = icl_translations.element_id
@erighetto
erighetto / services.local.yml
Last active February 5, 2018 05:50
Drupal 8 services for development
# @file
# Local development services.
services:
cache.backend.null:
class: Drupal\Core\Cache\NullBackendFactory
parameters:
twig.config:
debug: true
cache: false
@erighetto
erighetto / print_zpl.php
Last active June 16, 2022 16:06
Send raw ZPL to Zebra printer
<?php
error_reporting(E_ALL);
/* Get the port for the service. */
$port = "9100";
/* Get the IP address for the target host. */
$host = "172.17.144.89";
/* construct the label */
@erighetto
erighetto / settings.local.php
Last active February 5, 2018 05:50
Drupal 8 Local development override configuration feature
<?php
/**
* @file
* Local development override configuration feature.
*/
/**
* Assertions.
*
* The Drupal project primarily uses runtime assertions to enforce the
@erighetto
erighetto / docker-compose.yml
Last active December 19, 2018 22:49
Docker compose file demo suitable for Drupal local development with PHP 7 and MariaDB 10
version: '3'
services:
web-app:
image: erighetto/drupal-dev:latest
ports:
- "80:80"
depends_on:
- dbserver
links:
@erighetto
erighetto / docker-killer.sh
Created October 16, 2016 11:45
stop & remove container + remove volume
docker stop $(docker ps -a -q) && docker rm $(docker ps -a -q) && docker volume rm $(docker volume ls -qf dangling=true)
# Ignore configuration files that may contain sensitive information.
/sites/*/settings*.php
/.htpasswd
# Ignore the boost cache
/cache
/cache/*
# Ignore the files
/sites/*/files
<?php
$entities = array_keys(\Drupal::entityTypeManager()->getDefinitions());
sort($entities);
foreach ($entities as $entity) {
$current_field_storage_definitions = \Drupal::entityManager()->getFieldStorageDefinitions($entity);
\Drupal::service('entity.last_installed_schema.repository')
->setLastInstalledFieldStorageDefinitions($entity, $current_field_storage_definitions);
@erighetto
erighetto / recipe
Created March 27, 2021 16:44 — forked from magdmartin/recipe
OpenRefine recipe to parse Apache log
[
{
"op": "core/column-split",
"description": "Split column Column 1 by separator",
"engineConfig": {
"facets": [],
"mode": "row-based"
},
"columnName": "Column 1",
"guessCellType": true,
@erighetto
erighetto / artworks.py
Last active November 14, 2024 05:37
a Python script that embeds album cover images directly into each MP3 file
# When transferring an iTunes library to a new Mac, one common issue is that album artwork often fails to display correctly.
# This can happen because iTunes stores cover art separately from the actual MP3 files, so artwork may not carry over smoothly during migration.
# To solve this, a Python script can be used to embed album cover images directly into each MP3 file's metadata.
# By embedding the artwork, each song will retain its cover art no matter where it’s moved or which music player is used.
# This approach ensures a more seamless experience, making the iTunes library look complete and visually organized on the new device.
# This script simplifies the embedding process by automating image retrieval and integration for each MP3 file,
# saving users from the hassle of manually adding artwork.
import os