Skip to content

Instantly share code, notes, and snippets.

@szeidler
szeidler / nginx-drupal7-xml.conf
Created December 2, 2016 10:29 — forked from pprishchepa/nginx-drupal7-xml.conf
Docker4Drupal Nginx + XML
server {
server_name SERVER_NAME;
listen 80;
root /var/www/html/;
index index.php;
fastcgi_keep_conn on;
fastcgi_index index.php;
fastcgi_param QUERY_STRING $query_string;
@szeidler
szeidler / drush-config-export-skip-development.sh
Created December 30, 2016 22:56
Drupal 8 CMI exclude development modules
drush config-export --skip-modules=devel,kint,stage_file_proxy
@szeidler
szeidler / boost-recent-content-with-searchapi-solr.php
Created January 26, 2017 09:02
Add a boost function, to prioritize recent content in Search API Solr queries. More recent articles will get boosted heavily, older ones less and less.
<?php
/**
* Boost published_at field to prioritize newer content.
*
* @see https://wiki.apache.org/solr/SolrRelevancyFAQ#How_can_I_boost_the_score_of_newer_documents
* Implements hook_search_api_solr_query_alter().
*/
function my_module_search_api_solr_query_alter(array &$call_args, SearchApiQueryInterface $query) {
// Boost more recently created articles. Boost the field with score +8 shrinking during 365 days.
<?php
/**
* Implements hook_views_query_alter().
*/
function ramsalt_shy_replacement_views_query_alter(&$view, &$query) {
if ($view->name === 'frontpage_admin') {
foreach ($query->where[1]['conditions'] as $delta => $condition) {
if ($condition['field'] === 'node.title') {
$query->add_where_expression(1, "REPLACE(node.title, '=', '') " . $condition['operator'] . " '" . $condition['value'] . "'");
@szeidler
szeidler / gulpfile.js
Created February 23, 2017 10:16
Gulp files for Drupal theming (including clever drush cache clearing)
/**
* Gulp file for Drupal theming, including clever drush cache clearing.
*
* Usage in docker4drupal environment: `gulp --docker`
* It ensures, that drush is executed from the php container.
*/
var gulp = require('gulp');
var argv = require('yargs').argv;
var plumber = require('gulp-plumber');
@szeidler
szeidler / drush-sql-dump.sh
Created March 3, 2017 12:02
drush sql-dump
drush sql-dump --structure-tables-list=ctools_object_cache,ctools_css_cache,cache,cache_field,cache_form,cache_filter,cache_menu,cache_page,cache_views,cache_views_data,history,sessions,watchdog > ~/backup/database/backup-20170303.sql
@szeidler
szeidler / Mysql Commands
Created March 6, 2017 16:31
MySQL: Create User and grant priv to wildcard DB
.
@szeidler
szeidler / manualcrop-make_selection_path_alterable.patch
Created March 14, 2017 17:56
Fotoweb: Alter the file path for manualcrop selection. That is needed, because manualcrop settings are stored for $file->uri not image style path.
diff --git a/manualcrop.helpers.inc b/manualcrop.helpers.inc
index 1375f99..090cca0 100644
--- a/manualcrop.helpers.inc
+++ b/manualcrop.helpers.inc
@@ -636,6 +636,8 @@ function manualcrop_save_crop_data($file, $data) {
* - "height": An integer representing the height in pixels.
*/
function manualcrop_load_crop_selection($file, $style_name = NULL) {
+ drupal_alter('manualcrop_load_crop_selection', $file);
+
@szeidler
szeidler / drupal7-nginx-with-fotoweb.conf
Last active July 11, 2017 18:08
Nginx configuration for Fotoweb image style processing
server {
server_name SERVER_NAME;
listen 80;
root /var/www/html/;
index index.php;
fastcgi_keep_conn on;
fastcgi_index index.php;
fastcgi_param QUERY_STRING $query_string;
#!/bin/sh
# Usage: sudo curl https://gist.githubusercontent.com/szeidler/0b0e166b0e34dbb01248680627470af1/raw/setup-docker4drupal-mac-environment.sh | sh
# Check if docker is setup.
if ! [ -x "$(command -v docker-compose)" ]; then
echo 'Make sure, that you have installed Docker4Mac: https://download.docker.com/mac/stable/Docker.dmg'
exit 1
fi
# Install unison for Mac