Skip to content

Instantly share code, notes, and snippets.

@jtwalters
jtwalters / git-grepwords
Last active July 19, 2016 09:11
Grep multiple words in your git commit message history
# Example use: find commit messages that contain pattern1 and pattern2
# $ git grepwords pattern1 pattern2
# Ensure we have at least one param (a pattern)
[ -n "$1" ] || { echo "usage: $0 PATTERN..." >&2; exit 1; }
pattern=""
# Append all remaining patterns
while [ -n "$1" ]; do
@jtwalters
jtwalters / install.sh
Last active August 29, 2015 14:02
Download and install Drupal 7 (MAMP on OS X)
drush dl drupal \
--destination=/Applications/MAMP/htdocs \
--drupal-project-rename=d7
cd /Applications/MAMP/htdocs/d7
drush site-install standard \
--db-url="mysql://root:root@localhost/d7"\
--site-name="d7"
@jtwalters
jtwalters / JOKES.md
Last active August 29, 2015 14:02
Programming Jokes

Comment your jokes below in the following format:

Question?

Answer

@jtwalters
jtwalters / omghosts
Last active August 29, 2015 14:02 — forked from angrytoast/omghosts
#! /usr/bin/env bash
PROBLEM="$(cat /etc/hosts | grep tableausoftware.com | grep -v '^#' | wc -w)"
SAY=${1:-"omg fix yer hosts"}
if [ "$PROBLEM" -gt 0 ]; then
say $SAY
fi
alias nginx.start='sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.nginx.plist'
alias nginx.stop='sudo launchctl unload /Library/LaunchDaemons/homebrew.mxcl.nginx.plist'
alias nginx.restart='nginx.stop && nginx.start'
alias php-fpm.start="launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php53.plist"
alias php-fpm.stop="launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.php53.plist"
alias php-fpm.restart='php-fpm.stop && php-fpm.start'
alias mysql.start="launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mariadb.plist"
alias mysql.stop="launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mariadb.plist"
@jtwalters
jtwalters / settings.php
Created July 21, 2014 20:00
Suggested by mikeytown2 for faster Drupal DB
<?php
/**
* Suggested by mikeytown2 for faster DB
* @see https://www.drupal.org/node/1650930#comment-8437127
*/
/* -- Delete this line if you want to use this
$databases['default']['default']['init_commands'] = array(
'isolation' => "SET SESSION tx_isolation='READ-COMMITTED'"
);
<?php
//assuming $node exists
$my_collection = entity_create('field_collection_item', array('field_name' => 'field_my_collection'));
$my_collection->setHostEntity('node', $node);
$my_collection->field_text_data[LANGUAGE_NONE][0]['value'] = "hello";
$my_collection->field_term_ref[LANGUAGE_NONE][0]['tid'] = 123;
$my_collection->field_node_ref[LANGUAGE_NONE][0]['target_id'] = 345;
$my_collection->save();
node_save($node);
@jtwalters
jtwalters / SassMeister-input-HTML.html
Created November 12, 2014 20:34
Generated by SassMeister.com.
<div class="gallery-item">
</div>
<div class="gallery-item">
</div>
<div class="gallery-item">
</div>
@jtwalters
jtwalters / cross-browser-window-load-function.js
Last active November 16, 2016 22:04
Cross browser addEvent function (window load, ready, etc.)
(function () {
//////////////////////////////
// Add event (cross browser)
// From http://stackoverflow.com/a/10150042
//////////////////////////////
function addEvent(elem, event, fn) {
if (elem.addEventListener) {
elem.addEventListener(event, fn, false);
} else {
elem.attachEvent('on' + event, function() {
// Cross-scope compatible placeholder boilerplate.
@mixin my-mixin($extend: true) {
@if $extend {
@extend %my-mixin;
}
@else {
// Mixin core
}
}