Skip to content

Instantly share code, notes, and snippets.

@cristiroma
cristiroma / gist:406a3fc0f55f99576a4b293def2f4067
Created February 12, 2018 11:41
Connect from docker container to host service (mysqld)
# docker-compose.yml - creates a new network bridge
# listed in `docker network ls`.
# Note the name, i.e: `br-f60327d77bc2`
services:
tomcat:
image: tomcat:7.0
networks:
- dockernet
networks:
@cristiroma
cristiroma / vagrant-issue-8666-1.9.1.patch
Created November 10, 2017 08:19
Fixes issue https://github.com/hashicorp/vagrant/issues/4666 in vagrant 1.9.1 - Duplicate NFS exports
diff --git a/nfs.rb.bak b/nfs.rb
index 731399b..13c3207 100644
--- a/nfs.rb.bak
+++ b/nfs.rb
@@ -29,6 +29,7 @@ module VagrantPlugins
nfs_start_command = env.host.capability(:nfs_start_command)
nfs_opts_setup(folders)
+ folders = folder_dupe_check(folders)
output = Vagrant::Util::TemplateRenderer.render('nfs/exports_linux',
@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
@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 / 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 / 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 / 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 / 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 / csv2skosxl.php
Last active September 3, 2025 15:45
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 <[email protected]>
*/
@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(