Skip to content

Instantly share code, notes, and snippets.

@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>
// Cross-scope compatible placeholder boilerplate.
@mixin my-mixin($extend: true) {
@if $extend {
@extend %my-mixin;
}
@else {
// Mixin core
}
}
@jtwalters
jtwalters / SassMeister-input-HTML.html
Created December 11, 2014 17:31
Generated by SassMeister.com.
<div class="gallery-item">1</div>
<div class="gallery-item">2</div>
<div class="gallery-item">3</div>
<div class="gallery-item">4</div>
<div class="gallery-item">5</div>
<div class="gallery-item">6</div>
<div class="gallery-item">7</div>
<div class="gallery-item">8</div>
<div class="gallery-item">9</div>
<div class="gallery-item">10</div>
@jtwalters
jtwalters / 0_reuse_code.js
Last active August 29, 2015 14:12
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@jtwalters
jtwalters / d7-remote-file-save.php
Created January 20, 2015 17:52
Save a remote file URI in Drupal 7
<?php
$file = remote_stream_wrapper_file_create_by_uri($uri);
$file_result = file_save($file);
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Form</title>
</head>
<body>
<form>