Skip to content

Instantly share code, notes, and snippets.

@gwillem
gwillem / ansible-bootstrap-ubuntu-16.04.yml
Created June 16, 2016 21:59
Get Ansible to work on bare Ubuntu 16.04 without python 2.7
# Add this snippet to the top of your playbook.
# It will install python2 if missing (but checks first so no expensive repeated apt updates)
# gwillem@gmail.com
- hosts: all
gather_facts: False
tasks:
- name: install python 2
raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal)
@Morasta
Morasta / d7_display_suite_hide_labels_function.php
Last active September 2, 2016 02:10
Drupal 7 - Hide labels for empty display suite fields
/**
* Implements hook_field_attach_view_alter().
*
* Hide label of display suite fields if field content is empty.
*/
function cof_directory_field_attach_view_alter(&$output, $context) {
$displaySuiteFields = array("graduate_students","office_location");
foreach ($output as $field_name => $field) {
if (!empty($field['#label_display'])) {
@marekkalnik
marekkalnik / SpinningContext.php
Created July 9, 2014 14:47
Using spinners in BehatContext
<?php
use Behat\MinkExtension\Context\MinkContext;
class BaseFeatureContext extends MinkContext
{
/**
* This function prevents Behat form failing a tests if the HTML is not loaded yet.
* Behat with Selenium often executes tests faster thant Selenium is able to retreive
* the HTML causing false negatives.
@cridenour
cridenour / gist:74e7635275331d5afa6b
Last active August 7, 2023 13:52
Setting up Vim as your Go IDE

Setting up Vim as your Go IDE

The final IDE

Intro

I've been wanting to do a serious project in Go. One thing holding me back has been a my working environment. As a huge PyCharm user, I was hoping the Go IDE plugin for IntelliJ IDEA would fit my needs. However, it never felt quite right. After a previous experiment a few years ago using Vim, I knew how powerful it could be if I put in the time to make it so. Luckily there are plugins for almost anything you need to do with Go or what you would expect form and IDE. While this is no where near comprehensive, it will get you writing code, building and testing with the power you would expect from Vim.

Getting Started

I'm assuming you're coming with a clean slate. For me this was OSX so I used MacVim. There is nothing in my config files that assumes this is the case.

@BBGuy
BBGuy / drupal_commerce_order_total_components_1.php
Last active August 29, 2015 14:00
Drupal Commerce Order Total components
<?php
// Get a nicely formatted amount for Ex VAT & Vat order totals.
// Get the order wrapper
$order_wrapper = entity_metadata_wrapper('commerce_order', $order);
// Order total.
$order_total = $order_wrapper->commerce_order_total->value();
// Get ex vat amount.
@shawnrice
shawnrice / skeleton-daemon.sh
Created April 19, 2014 07:22
A template to write a quick daemon as a bash script
#!/bin/sh
# This is a skeleton of a bash daemon. To use for yourself, just set the
# daemonName variable and then enter in the commands to run in the doCommands
# function. Modify the variables just below to fit your preference.
daemonName="DAEMON-NAME"
pidDir="."
pidFile="$pidDir/$daemonName.pid"
@juampynr
juampynr / mymodule.info
Last active June 9, 2023 21:53
Drupal 7 Views 3 custom field handler
dependencies[] = ctools
; Views Handlers
files[] = views/mymodule_handler_handlername.inc
@carlwiedemann
carlwiedemann / gist:4061841
Created November 12, 2012 20:57
The Future of Renderables, in Theory
<?php
/**
* DISCLAIMER: This is a purely theoretical example.
*
* Let's render a paged list of nodes, using a component. Components
* are common layout recipes, and we wish to provide a Theme
* Component Library that developers can use. These are similar in
* concept to the traditional theme functions, but should be more
* flexible and reusable by core and contrib. We're hoping that
@lg0
lg0 / markdown.xml
Created April 10, 2012 19:58
Markdown Syntax Highlighting for Sublime text 2
<!-- copy this to YOUR_THEME.tmTheme-->
<dict>
<key>name</key>
<string>diff: deleted</string>
<key>scope</key>
<string>markup.deleted</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#EAE3CA</string>
@ScottPhillips
ScottPhillips / .htaccess
Created February 2, 2012 04:30
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/