Skip to content

Instantly share code, notes, and snippets.

View delphian's full-sized avatar

Bryan Hazelbaker delphian

  • Hesperia, CA
View GitHub Profile
@delphian
delphian / observer-design-pattern.js
Created June 30, 2013 03:27
Javascript observer design pattern.
/**
* @file
* Observer design pattern.
*
* This object will provide an observer design pattern. Observers may
* subscribe to specific message types. Observables may broadcast
* messages specific to a type.
*
* @author Bryan Hazelbaker <bryan.hazelbaker@gmail.com>
* @version 1.0
@delphian
delphian / uniform-ppcl-program-template-2.0.ppcl
Last active December 19, 2015 05:48
Uniform PPCL Program Template. Using the below template voids the need for goto statements. Also, a software programmer that is unfamiliar with control work will have an easier time examining this style of code. A modular approach to coding is more standard in the software community; though unfortunately virtually unheard of to a controls progra…
00001 C Uniform PPCL Program Template 2.0.
00002 C Using the below template voids the need for goto statements.
00003 C Also, a software programmer that is unfamiliar with control work
00004 C will have an easier time examining this style of code. A modular
00005 C approach to coding is more standard in the software community;
00006 C though unfortunately virtually unheard of to a controls
00007 C programmer. The template begins at line 50.
00008 C
00008 C @see https://gist.github.com/delphian/5906264
00009 C @see https://github.com/delphian/ppcl-library
@delphian
delphian / git-bash-syntax.bash_profile
Created July 7, 2013 04:35
Git bash completion. Copy and paste this into the .bash_profile located in your user directory (~/.bash_profile)
# Git-Completion
#!bash
#
# bash/zsh completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.
#
# The contained completion routines provide support for completing:
@delphian
delphian / drush-example-site.make
Last active September 27, 2019 18:16
Example drupal drush site.make file for automatically downloading modules, themes, profiles, and libraries
; @file drush-example-site.make
; @author Bryan Hazelbaker <bryan.hazelbaker@gmail.com>
;
; @brief Drush make file to be processed by the `drush make` command
;
; @details Running drush make on this configuration file will download
; all specified modules, themes, and libraries into their respective
; directories. the `drush` command must first be installed to process
; this make file.
;
@delphian
delphian / drush-rebuild-site-make.sh
Created July 18, 2013 10:58
Rebuild the drush site make file.
# Remove the directories we are rebuilding
tar -czf /tmp/drush-backup-`date +%Y%m%d%H%M%S`.tar.gz modules libraries
rm -rf ./modules/contrib ./libraries
# Pull down the new code
drush make --yes --no-core --working-copy --contrib-destination=. ./site.make
@delphian
delphian / install-drupal-db-and-core.sh
Last active September 16, 2019 13:35
Drupal site install script to install Drupal database and core. Enable and disable favorable contrib modules.
#!/bin/bash
# Site install script that will download the latest version of drupal, create
# a database in mysql, use drush to perform a site install, download
# and enable some handy contrib modules, and disable a few annoying
# core module.
#
# Copy and paste this into a shell to execute:
# curl -s https://gist.github.com/delphian/6043424/raw/ | bash
#
@delphian
delphian / gist:6177336
Created August 7, 2013 19:00
Overwrite regex matched files from one branch to another using git diff.
git diff master --name-only | grep -E '(css|sass)' | xargs -I{} git checkout master {}
@delphian
delphian / drupal-7-example-local-settings.php
Created August 15, 2013 17:12
Example of drupal 7 local settings.php file.
<?php
// To set up a local environment, make a duplicate of this file and name it
// local-settings.inc in the site directory that contains the settings.php file.
// Ignore sites/*/local-settings.php in the .gitignore file. Change the settings.php
// file to include local-settings.php if the file exists.
// Point database to local service.
$databases['default']['default'] = array(
'database' => 'local_db_name',
@delphian
delphian / mink-nodeelement-mouseover-replacement.php
Created August 17, 2013 04:15
A replacement for mink's NodeElement mouseOver method. Occationally the mouseOver method will not cause the desired effect (such as when custom javascript is watching for a change of rate in the mouse location before popping up a menu item).
/**
* More reliable way to hover over an element. Talk to selenium directly.
*
* @param string $selector
* CSS selector.
* @param int $sleep
* Number of seconds to sleep after hover is initiated. Allows some
* slower third party javascript to do its thing before moving on
* with more test steps.
*
@delphian
delphian / mink-step-helper-elementselectfirst.php
Created August 17, 2013 04:55
Returns the first element found from Mink's NodeElement::findAll() request.
/**
* Select the first CSS element returned by findAll query.
*
* @param string $selector.
* CSS selector.
*
* @return NodeElement
* Or throws error if unable to locate.
*/
protected function elementSelectFirst($selector)