Skip to content

Instantly share code, notes, and snippets.

View kevinquillen's full-sized avatar

Kevin kevinquillen

View GitHub Profile
@ethanhinson
ethanhinson / gluecode.php
Last active August 29, 2015 14:02
SOLR Views Code
<?php
/**
* Implements hook_views_query_alter().
*
* Integrates solr index search facets with select displays of the vr search
* views in order to allow views built on normal views base tables (not search API)
* to interact with SOLR for facet generation. This is perhaps not the most
* efficient approach, but provides a solution allowing the full extent of
* normal views base table fields, filters and sorts to be used in conjunction
* with SOLR facets.
'field_address/country_code':
plugin: default_value
default_value: US
'field_address/langcode':
plugin: default_value
default_value: en
'field_address/address_line1': streetAddress
'field_address/locality': city
# This has the form US-IN.
'field_address/administrative_area':
@kevinquillen
kevinquillen / module.php
Last active July 10, 2017 20:39
Importing to a SQL table from a CSV file in Drupal, so you don't have to parse exceptionally large CSVs line by line and instead can do so with MySQL querying. This snippet assumes you have read the column headers already from the CSV and passed them as parameters, as well as the temp table name you want to use.
<?php
/**
* Creates a temporary table to hold values from an uploaded CSV.
* @param $table_name
* @param $columns
* @param $message
* @param $context
*/
function csv_import_create_temp_table($table_name, $columns) {
@rgoodie
rgoodie / new-drupal-dev-vm.sh
Last active March 22, 2018 23:47
A function, when added to bash profile, clones the Vagrant Drupal-Dev-VM (https://github.com/geerlingguy/drupal-dev-vm), augments configuration (based on d7 or d8), renames the VM to something other than drupaltest.dev and starts vagrant up. Uses include <newd 7 my-drupal-site> and <newd 8 my-other-drupal-site>.
# new drupal vagrant install
# A function, when added to bash profile, clones the Vagrant Drupal-Dev-VM (https://github.com/geerlingguy/drupal-dev-vm),
# augments config (based on d7 or d8), renames the VM to something other than drupaltest.dev and starts vagrant up. Uses
# include <newd 7 my-drupal-site> and <newd 8 my-other-drupal-site>.
function newd {
if [ $2 == ]; then
echo 'USAGE: newd8 <version> <sitename>'
@chriscalip
chriscalip / xxx.drush.inc
Last active March 6, 2019 20:10
Demo of `drush-update-assets-via-csv`
<?php
/**
* Command callback. drush update-assets-via-csv
*/
function drush_capacitype_deploy_update_assets_via_csv() {
$source_csv = (!is_null(drush_get_option('csv'))) ? drush_get_option('csv') : '';
if (empty($source_csv)) {
drush_print_r('Expected parameter, csv not found.');
return;
@kevinquillen
kevinquillen / README.md
Created June 2, 2013 21:25
Reddit Widget for Dashing

Preview

Description

Took a little inspiration from the News widget to construct this Reddit widget. Simply add the subreddit .json feed URLs that you want to the top of the reddit.rb job script, and the widget will cycle through each one, showing top posts, their score, and comment count. You can also set the maxcount higher or lower, the default is 5 posts.

##Usage

@svetlio
svetlio / SerializerCount.php
Last active February 12, 2020 22:13
Drupal 8 views rest with pager data
<?php
// thanks Dan - http://www.mediacurrent.com/blog/eight-insights-and-useful-snippets-d8-rest-module
/** @file
* Contains \Drupal\views_ext\Plugin\views\style\SerializerCount.
*/
namespace Drupal\views_ext\Plugin\views\style;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheableDependencyInterface;
@petervanderdoes
petervanderdoes / filter-flow-hotfix-start-version
Created June 5, 2012 22:20
gitflow hooks and filter for gitflow development
#!/bin/sh
#
# Runs during git flow release start
#
# Positional arguments:
# $1 Version
#
# Return VERSION - When VERSION is returned empty gitflow
# will stop as the version is necessary
#
@crittermike
crittermike / get_node_by_path.php
Created September 16, 2016 15:15 — forked from thagler/get_node_by_path.php
Drupal 8 Get node ID by path alias
<?php
$path = \Drupal::service('path.alias_manager')->getPathByAlias('/this-is-the-alias');
if(preg_match('/node\/(\d+)/', $path, $matches)) {
$node = \Drupal\node\Entity\Node::load($matches[1]);
}
@hans2103
hans2103 / .htaccess-mod_headers
Created April 13, 2015 08:33
.htaccess rules to set cache control.
<IfModule mod_headers.c>
Header set Connection keep-alive
# Cache-control headers
# 2 HOURS
#<filesMatch "*">
Header set Cache-Control "max-age=7200, must-revalidate"
#</filesMatch>
# 480 weeks - 290304000