Skip to content

Instantly share code, notes, and snippets.

View andydempster's full-sized avatar
💬

Andy Dempster andydempster

💬
View GitHub Profile
@andydempster
andydempster / gist:61b120546797f099b360
Created October 15, 2015 16:26
Some menu_alter code
/**
* Implements hook_menu_alter(&$item)
*
* Giant hack around a non-functioning permissions system - gets the users roles and checks to see if they
* can create content types - if so allow the menu link else disable it.
*/
//function olc_access_menu_alter(&$items) {
// // get the current user entity
// global $user;
// $account = $user;
@andydempster
andydempster / fix-permissions.sh
Created August 15, 2016 10:50
Drupal 7 fixer upper - run using sudo
#!/bin/bash
# Help menu
print_help() {
cat <<-HELP
This script is used to fix permissions of a Drupal installation
you need to provide the following arguments:
1) Path to your Drupal installation.
2) Username of the user that you want to give files/directories ownership.
3) HTTPD group name (defaults to www-data for Apache).
Usage: (sudo) bash ${0##*/} --drupal_path=PATH --drupal_user=USER --httpd_group=GROUP
@andydempster
andydempster / README.MD
Last active May 9, 2017 11:01
Alter the node label pre-theme - uses callback_entity_info_label

This code came as a result of using the following modules in Drupal 7:

node_display_title

entity_reference_multiple

The output returned from entity ref mult was unalterable and used the default entity label in the markup. I was unable to theme the field and didn't want to alter the markup so implemented these hooks to change the label itself. Rather dangerous but it does fall back gracefully to the default node title.

@andydempster
andydempster / my_module.install
Created May 26, 2017 14:59
How to create a taxonomy
/**
* Insert terms for School Level vocabulary.
*/
function bracknell_deploy_update_7018() {
// Create the new school level vocab.
$vocabulary = new stdClass();
$vocabulary->name = 'School Level';
$vocabulary->machine_name = "school_level";
$vocabulary->description = t('List of school levels weighted by order preference.');
$vocabulary->module = 'taxonomy';
@andydempster
andydempster / README.md
Last active December 2, 2020 21:10
pre-commit for Powershell and PHP

This setup is for Windows 10 using powershell. You should already have Git for Windows installed, PHP in the path specified (c:\php) and composer with phpcs and the Drupal coding standards installed.

@andydempster
andydempster / github_issues_to_csv.py
Created March 15, 2019 15:43 — forked from patrickfuller/github_issues_to_csv.py
Export Issues from Github repo to CSV (API v3)
"""
Exports issues from a list of repositories to individual csv files.
Uses basic authentication (Github username + password) to retrieve issues
from a repository that username has access to. Supports Github API v3.
Forked from: unbracketed/export_repo_issues_to_csv.py
"""
import argparse
import csv
from getpass import getpass
import requests
@andydempster
andydempster / add_giphy.md
Last active October 14, 2019 15:54
How to add images to PRs, READMEs etc

![](name-of-giphy.gif)

@andydempster
andydempster / parseCSV.php
Created November 22, 2019 18:42
Find and Replace in a CSV
<?php
require_once('countries.php');
$row = 0;
$fp = fopen('hubspot10daysnew.csv', 'w');
$countries = get_countries();
if (($handle = fopen("hubspot10days.csv", "r")) !== FALSE) {
while ($data = fgetcsv($handle)) {