Skip to content

Instantly share code, notes, and snippets.

@hedleysmith
hedleysmith / slick.zsh-theme
Created July 14, 2013 21:13
My zsh theme, based on ys
# Clean, simple and slick. All on one line.
# It is recommended to use with a dark background and the font Inconsolata.
# Colors: black, red, green, yellow, *blue, magenta, cyan, and white.
# Based on YS theme
# Machine name.
function box_name {
[ -f ~/.box-name ] && cat ~/.box-name || hostname -s
}
@hedleysmith
hedleysmith / gist:6029421
Created July 18, 2013 13:45
Install Apache Solr (v3.6.0) and Jetty (v6.1) on Ubuntu
#!/bin/bash
# ################################################################################ Apache SolR
# README:
#
# This script will install Apache Solr and run using Jetty
#
HELP="
@hedleysmith
hedleysmith / gist:6542309
Last active December 22, 2015 22:49
Drupal debugging
Useful for anonymous users & debugging Drupal hook_mail and hook_mail_alter. Pretty-prints an object
drupal_set_message('<pre>' . print_r($account, TRUE) . '</pre>');
@hedleysmith
hedleysmith / gist:6549790
Created September 13, 2013 12:03
Drupal 7 Spaces module: Add current space to body as a class
/*
* Implements template_preprocess_html()
*/
function YOURTHEME_preprocess_html(&$variables, $hook) {
// Get the current space and output as a class in the body for use elsewhere
$space = spaces_get_space();
// Works for Taxonomy spaces
if(!empty($space->term->name)) {
// Format nicely
@hedleysmith
hedleysmith / gist:6864687
Created October 7, 2013 08:52
Changing your cron key in Drupal 7, or regenerating a lost cron key
drush vset cron_key $(date | md5sum | head -c 32)
@hedleysmith
hedleysmith / gist:6921874
Created October 10, 2013 17:01
Reset admin password in Drupal 7
cd /path/to/drupal
scripts/password-hash.sh 'mynewpassword'
-> Add hash to user 1 in the DB
@hedleysmith
hedleysmith / gist:7695973
Last active December 29, 2015 16:09
SASS Style Guide / Coding Standards
/**
* Code block comment
*/
$variable: 1;
$variable: 2;
.selector {
@extend %placehold-extender;
@include functionname();
@hedleysmith
hedleysmith / Override Drupal Ajax progress throbber.js
Last active June 30, 2021 17:15
Ever wondered how to override the default Ajax progress throbber? We can change the GIF easily with CSS but if you want to do things like change the position of the actualy HTML this is probably the cleanest way to do so.
/**
* @file
*
* Overrides the default Ajax progress indicator to do things like change the
* styling and positioning.
*/
(function ($) {
// Drupal's core beforeSend function
var beforeSend = Drupal.ajax.prototype.beforeSend;
@hedleysmith
hedleysmith / jQuery radio input selected & not-selected classes.js
Last active August 29, 2015 14:15
Add selected and not-selected classes to radio inputs parent elements for checked and not-checked radio inputs in jQuery
// Load selected & not-selected classes when page loads
$('input[type=radio]').filter(':checked').parent().addClass('selected');
$('input[type=radio]').filter(':not(":checked")').parent().addClass('not-selected');
// When radio buttons are changed add classes
$('form').once('selected-radio-listen').on(
"change",
"input[type=radio]",
function () {
// Get all related inputs.
@hedleysmith
hedleysmith / Vagrant guest to guest access
Last active August 29, 2015 14:17
Accessing a vagrant vm from another guest (guest to guest vm access)
1. Configure your Vagrant box to use a private network and assign an IP:
config.vm.network 'private_network', ip: 192.168.56.101
2. Open the guest VM and add an entry to the hosts file (/system32/drivers/etc/hosts on Windows)
192.168.156.101 mysite.local
3. You may need to add a hosts-only network adapter to the second guest VM (this can be done in the VirtualBox config for that VM)
This can be very useful for testing a website served by a vagrant box on a Windows VM with Internet Explorer.