Skip to content

Instantly share code, notes, and snippets.

View kevinquillen's full-sized avatar

Kevin kevinquillen

View GitHub Profile
@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;
@florentdestremau
florentdestremau / NewPasswordType.php
Last active March 10, 2023 13:17
A simple User authentication setup to copy & paste into your Symfony 3.4 install
<?php
namespace AppBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormBuilderInterface;
@taufek
taufek / pre-push
Last active January 10, 2023 17:40
PrePush Git Hook with PhpCs and PhpStan
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".
exec < /dev/tty
@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;
@lxhunter
lxhunter / semver.sh
Last active July 8, 2022 19:12
Automated semantic versioning for travis-ci or any other ci
#!/bin/bash
export SEMVER_LAST_TAG=$(git describe --abbrev=0 --tags 2>/dev/null)
export SEMVER_RELEASE_LEVEL=$(git log --oneline -1 --pretty=%B | cat | tr -d '\n' | cut -d "[" -f2 | cut -d "]" -f1)
#curl -o /tmp/hub.tgz https://github.com/github/hub/releases/download/v2.2.9/hub-linux-arm64-2.2.9.tgz
#tar -xvzf /tmp/hub.tgz -C /tmp
if [ -z $SEMVER_LAST_TAG ]; then
>&2 echo "No tags defined"
@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]);
}
'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':
@subfuzion
subfuzion / curl.md
Last active April 23, 2024 14:44
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@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) {