Skip to content

Instantly share code, notes, and snippets.

View ForestMars's full-sized avatar
๐Ÿ’ญ
๐‘โ„Ž=๐‘๐‘ (๐›ผโˆ—(๐‘๐‘–+๐‘๐‘œ))

Forest Mars ForestMars

๐Ÿ’ญ
๐‘โ„Ž=๐‘๐‘ (๐›ผโˆ—(๐‘๐‘–+๐‘๐‘œ))
View GitHub Profile
@ForestMars
ForestMars / hack.sh
Created April 1, 2012 00:38 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@ForestMars
ForestMars / gist:3379937
Created August 17, 2012 15:32 — forked from davereid/custom.admin_menu.inc
Useful Drupal 7 functions
<?php
/**
* Implements hook_block_view().
*/
function custom_block_view($delta) {
$function = 'custom_block_view_' . strtr($delta, '-', '_');
module_load_include('inc', 'custom', 'custom.blocks');
if (function_exists($function)) {
return $function();
@ForestMars
ForestMars / bash_aliases
Created October 18, 2012 00:39
bash aliases
alias al='source ~/.bash_aliases'
alias ali='vi ~/.bash_aliases'
# Apache aliases
alias areload='sudo /etc/init.d/apache2 reload'
alias sar='sudo service apache2 reload'
alias sarr='sudo service apache2 restart'
# Chef aliases
@ForestMars
ForestMars / chef-install.sh
Created October 18, 2012 04:05
Chef install script - installs client
## Run this script (with sudo) to install Chef & Chef Server on a Debian based system.
#!/bin/sh
## script to install Ruby prerequisites on Ubuntu so that Chef can be used to manage configuration.
## authored by Forest Mars for Elephant Ventures
## please run this script as a user with sudo
# First we'll add opscode as a trusted repository (and update again)
echo "deb http://apt.opscode.com/ precise-0.10 main" | sudo tee /etc/apt/sources.list.d/opscode.list
@ForestMars
ForestMars / panfiles.sh
Created October 18, 2012 14:23
Pantheon Drupal files script
## Script to automatically pulldown all the files from any Pantheon environment to your local environment.
## To execute the script, copy the Pantheon download link onto your clipboard
#!/bin/bash
## Path to local developement environment is defined here:
declare siteroot=
echo "enter path to files tarball on s3"
read panfilepath
@ForestMars
ForestMars / drush-db-bu-rotate.sh
Created October 18, 2012 14:25
Drush database backup and rotate
## This will create a file called my_db.sql with your most recent dump and keep a history of archived (& tagged) backups.
## NB: needs some error handling when sql connect fails (currently it returns the error, but continues script execution.)
#!/bin/sh
#declare siteroot=/home/engineer/archetypes
declare siteroot=/Applications/MAMP/htdocs/archetypes
declare budir=~/dbbackups
echo "tag?"
read tag
<?php
/**
* @file
* Contains \Drupal\node\Plugin\Core\Condition\NodeType.
*/
namespace Drupal\node\Plugin\Core\Condition;
use Drupal\condition\Plugin\ConditionPluginBase;
# Meta
alias al='source ~/.bash_aliases'
alias ali='vi ~/.bash_aliases'
# Git
alias gt='git'
alias gpm='git pull origin master'
alias gnb='git checkout -b'
alias gcm='git commit -m'
alias gaa='git add .'
@ForestMars
ForestMars / gist:7060710
Last active December 25, 2015 23:59
Theme suggestion for node type.
function newtheme_preprocess_page(&$vars, $hook) {
if (isset($vars['node'])) {
// If the node type is "blog" the template suggestion will be "page--blog.tpl.php".
$vars['theme_hook_suggestions'][] = 'page__'. str_replace('_', '--', $vars['node']->type);
}
}
// Add a single suggestion for nodes that have the "Promoted to front page" box checked.
function newtheme_preprocess_node(&$variables) {
if ($variables['promote']) {
$view = new view();
$view->name = 'taxonomy_term';
$view->description = 'A view to emulate Drupal core\'s handling of taxonomy/term.';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'Taxonomy term';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */