Skip to content

Instantly share code, notes, and snippets.

@cristiroma
cristiroma / distro.make
Last active December 27, 2015 06:09
Base make file for the Drupal core
api = 2
core = 7.x
projects[drupal][type] = core
@cristiroma
cristiroma / update.git
Created March 12, 2014 09:13
Bash shell script to handle multiple repositories in the same directory
#!/bin/bash
COMMAND=$1
if [ -z $1 ]; then
COMMAND="status"
else
COMMAND="$@"
fi
for repo in `find . -maxdepth 1 -mindepth 1 -type d`
@cristiroma
cristiroma / db_clean.php
Created November 7, 2014 15:24
PHP script to clean database tables. Add to $preserve the ones you want to keep. Also drop views
<?php
$conn = new mysqli('localhost', 'root', 'root', 'database');
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$conn->autocommit(FALSE);
$preserve = array(
@cristiroma
cristiroma / csv2skosxl.php
Last active February 21, 2019 11:55
Sample script to convert an CSV / Excel into RDF SKOS-XL format
<?php
/**
* Sample script to convert an CSV (ie. exported form MS Excel file) into
* RDF SKOSXL format.
*
* @file csv2skosxl.php
* @license Licensed under WTFPL (http://www.wtfpl.net/txt/copying/)
* @author Cristian Romanescu <cristian.romanescu@eaudeweb.ro>
*/
@cristiroma
cristiroma / docker.database.service
Last active March 22, 2018 21:08
CentOS 7 systemd script to start/stop docker containers at boot
# https://goldmann.pl/blog/2014/07/30/running-docker-containers-as-systemd-services/
[Unit]
Description=MariaDB container
Requires=docker.service
After=docker.service
[Service]
User=php
Restart=always
@cristiroma
cristiroma / my.cnf
Created August 2, 2016 16:29
MySQL cnf configuration script for the power user's dev developer machine
[client]
user=root
password=root
socket=/var/mysql/mysql.sock
[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
@cristiroma
cristiroma / htaccess
Created March 27, 2017 08:10
.htaccess file for production
FileETag MTime Size
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access 1 month"
ExpiresByType text/html "access 1 month"
# CSS
ExpiresByType text/css "access 1 year"
ExpiresByType application/javascript "access 1 year"
@cristiroma
cristiroma / d8.testing.txt
Last active September 5, 2017 14:44
Running Drupal 8 functional tests
List tests classes by group
php core/scripts/run-tests.sh --list
Normal run of a single class
php core/scripts/run-tests.sh --non-html --color --verbose --url http://site.local --class "Drupal\Tests\my_module\Functional\ClassTest"
Debug a single class (leave results)
php core/scripts/run-tests.sh --die-on-fail --keep-results-table --keep-results --non-html --color --verbose --url http://site.local --class "Drupal\Tests\my_module\Functional\ClassTest"
@cristiroma
cristiroma / labels-query.rq
Created October 26, 2017 17:24
SPARQL query to extract English term name of SKOS-XL reified labels
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX nm: <http://nomisma.org/id/>
PREFIX nmo: <http://nomisma.org/ontology#>
PREFIX org: <http://www.w3.org/ns/org#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX skosxl: <http://www.w3.org/2008/05/skos-xl#>
SELECT ?s ?y
@cristiroma
cristiroma / drupal-8-generate-site-urls.sql
Created November 3, 2017 18:19
An SQL query to URL to all published web pages (nodes) in a Drupal installation from url_alias
select concat('http://your.website.url/', c.langcode, c.alias) url from node a
inner join node_field_data b on a.nid = b.nid
inner join url_alias c on CONCAT('/node/', a.nid) = c.source AND c.langcode = 'en'
where b.status = 1 group by a.nid
UNION
select concat('http://your.website.url/', c.langcode, c.alias) url from node a
inner join node_field_data b on a.nid = b.nid
inner join url_alias c on CONCAT('/node/', a.nid) = c.source AND c.langcode = 'fr'
where b.status = 1 group by a.nid