Skip to content

Instantly share code, notes, and snippets.


Jamie Hamel‑Smith jamiehs

View GitHub Profile
jamiehs / functions.php
Created Jul 7, 2015
Snippet to add a smarter option to Mandrill for WordPress.
View functions.php
* Add paragraph breaks to plain text notifications sent by Mandrill
* Mandrill's default option for handling this is a bit too
* agressive. This method checks the type of email, and attempts
* to detect whether or not it is HTML or not.
* @param array $message
jamiehs / markup.html
Created Apr 14, 2015
Equal height strategy for Bootstrap columns
View markup.html
<div class="row equal-height">
<div class="hidden-xs equal-height-trigger"></div>
<div class="col-sm-6 col-md-3">
<div class="card">
<div class="inner">
<p>Lorem ipsum Veniam eiusmod sunt velit deserunt ullamco cillum Duis dolore anim nulla Ut pariatur pariatur labore non esse qui proident ad.</p>
jamiehs / scrollto-pushstate.js
Created Sep 23, 2014
jQuery Scroll To with history.pushState support for using the back button and the location bar:
View scrollto-pushstate.js
$(document).on('click', 'a[href*=#]', function(event){
var targetId = this.hash;
var theTarget = $(targetId);
var customOffset = 0;
switch( targetId ){
case '#target1':
case '#target2':
customOffset = -80;
jamiehs /
Created Apr 24, 2014
Recursively loop over all files, then use simple string replacements.
find . -type f -name "file-pattern*" -exec sh -c 'echo mv "$0" "${0/find/replace}"' '{}' \;
#Remove the echo when you're sure this does what you want.
View popup_function.js
function openPopup(href, title, width, height){
var left = screen.availLeft + screen.width/2 - width/2,
top = screen.height/2 - height/2;, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=' + width + ', height=' + height + ', top=' + top + ', left=' + left);
jamiehs / gist:9824788
Created Mar 28, 2014
ISO 8601 Parser for PHP
View gist:9824788
* Parse an ISO 8601 duration string
* @return array
* @param string $str
function parseDuration($str)
$result = array();
preg_match('/^(?:P)([^T]*)(?:T)?(.*)?$/', trim($str), $sections);
jamiehs / sass-mixins.scss
Last active Aug 29, 2015
Magical mixins with trees
View sass-mixins.scss
@mixin gallery-items($size) {
.item {
float: left;
.thumbnail {
margin-bottom: $size/4;
text-align: center;
width: $size;
height: $size;
jamiehs / update-domain-name-2.sql
Created Mar 19, 2014
Simple version of MySQL find and replace for WOrdPress database migration.
View update-domain-name-2.sql
# Update wp_options table
UPDATE wp_options SET option_value = REPLACE(option_value,'','');
# Update wp_posts table
UPDATE wp_posts SET guid = REPLACE(guid,'','');
jamiehs / 01-update-domain-name.sql
Last active Sep 24, 2015
MySQL Find and replace for WordPress domain changing
View 01-update-domain-name.sql
# Table Prefix
SET @prefix = 'wp';
# Find and replace strings
SET @find = "";
SET @replace = "";
# Build and execute the statements
SET @sql1 = CONCAT('UPDATE ', @prefix, '_options SET option_value = REPLACE(option_value,?,?)');
SET @sql2 = CONCAT('UPDATE ', @prefix, '_posts SET guid = REPLACE(guid,?,?)');
jamiehs / Pi setup
Last active Aug 29, 2015
Setup a new Raspberry Pi Dashing board based on cloned image of "raspberrypi2"
View Pi setup
# Find listening port 22 on the network
nmap -T5 -n -p 22 --open --min-parallelism 100
# edit hostname and hosts to change the hostname.
sudo nano /etc/hostname
sudo nano /etc/hosts
# edit the static IP address in the interfaces file.
sudo nano /etc/network/interfaces
You can’t perform that action at this time.