Skip to content

Instantly share code, notes, and snippets.

View energee's full-sized avatar
:atom:
Coding

Ted Slesinski energee

:atom:
Coding
View GitHub Profile
@energee
energee / hook_update.php
Created February 25, 2016 19:07
Iterating through nodes from an entity field query
**
* Update blog type fields to 'leadership' on current fields.
*/
function lm_content_update_7022(&$sandbox) {
if (empty($sandbox['total'])) {
$sandbox['progress'] = 0;
$sandbox['last_nid'] = 0;
// Count the total number of blog posts.
$count_query = new EntityFieldQuery();
@energee
energee / css
Last active August 29, 2015 14:22
Media object
.media {margin:10px;}
.media, .bd {overflow:hidden; _overflow:visible; zoom:1;}
.media .img {float:left; margin-right: 10px;}
.media .img img{display:block;}
.media .imgExt{float:right; margin-left: 10px;}
@energee
energee / gist:fb2717892a5b237fd786
Last active August 29, 2015 14:18
Center anything vertically in css (ie9+)
object {
position: relative;
top: 50%;
transform: translateY(-50%);
}
.parent-element {
-webkit-transform-style: preserve-3d;
-moz-transform-style: preserve-3d;
transform-style: preserve-3d;
@energee
energee / gist:07f27f1ce3e7c73a9d3a
Created January 27, 2015 23:41
Install Nginx, PHP-FPM, MySQL and phpMyAdmin on OS X Mavericks or Yosemite
Xcode
First of all, get the latest Xcode version (6.1) via the Mac App Store:
Download Xcode.app (via Mac App Store)
As soon as you have finished the download, open Xcode in your /Applications folder and agree to the licence.
Open a new Terminal window and install the Xcode Command Line Tools:

Install OS X 10.10 Yosemite in VirtualBox

(based on this pastebin i've found via Google, markdownified and adjusted to work with the official Yosemite release)

Yosemite's first developer preview was released right after Monday's WWDC opening keynote. For the general public, an open beta will be available to download later this summer. However, for those who want a sneak peek at the new hotness, there is a way to safely install it without risking your machine, using the free and powerful VirtualBox application from Oracle.

(LEGAL DISCLAIMER: This guide aims to explain how to create a virtual machine on a regularly purchased Apple computer, running a genuine Mac OS X operating system, for testing purposes only.)

@energee
energee / gist:74d4cf7fb917cab6b7e0
Created December 1, 2014 22:18
Log into MySQL Root without password
# kill the running mysql process
sudo service mysql stop
# start mysql in safe mode and skip grant tables
sudo mysqld_safe --skip-grant-tables --skip-networking &
# log in with root
mysql -u root
# ( optional ) flush privileges, create new user, grant privileges
(function ($) {
Drupal.behaviors.megamenu = {
attach: function (context, settings) {
(function(){
var mainNav = {};
// common stuff
@energee
energee / gist:9550287
Last active August 29, 2015 13:57
New directory to looks for templates
<?php
function MYTHEME_theme($existing, $type, $theme, $path) {
$template_path = drupal_get_path('theme', 'MYTHEME') .'/templates';
return drupal_find_theme_templates($existing, '.tpl.php', $template_path);
}
@energee
energee / gist:6934847
Created October 11, 2013 13:40
Field formatters in Drupal 7
function hook_field_formatter_info() {
}
function hook_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
}
@energee
energee / .gitconfig
Last active December 19, 2015 14:49
.gitconfig
[user]
name = ted
email = ted@slesinski.org
[mergetool]
keepBackup = true
[core]
excludesfile = /Users/ted/.gitignore_global
autocrlf = input
[color]
branch = auto