Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# usage: drupal-quick-dump user host database
USER="$1"
HOST="$2"
DB="$3"
DATE=`date +%Y%m%d`
# Get User Password
echo "Please provide the password for ${USER} on db ${DB} hosted at ${HOST}:"
@marioangulo
marioangulo / httpd.base
Created April 21, 2014 21:17
httpd base example
<VirtualHost *:80>
ServerName example.com
DocumentRoot /var/www/domains/example.com/html
ErrorLog /var/www/domains/example.com/apache.error.log
CustomLog /var/www/domains/example.com/apache.access.log common
php_flag log_errors on
php_flag display_errors on
php_value error_reporting 30719
php_value error_log /var/www/domains/example.com/php.error.log
</VirtualHost>
@marioangulo
marioangulo / cron_hook.module
Last active August 29, 2015 14:00
Cron Once Per Day.
function mymodule_hook() {
// today's date as of midnight, exp. 04/16/09 12:00:00 am
define('TODAY', mktime(0, 0, 0, date('n'), date('j'), date('Y'), 0));
if (variable_get('daily_cron', TODAY) != TODAY) {
variable_set('daily_cron', TODAY);
// do whatever else you need
}
}
@marioangulo
marioangulo / drupal-default.vcl
Created June 17, 2014 23:47
drupal-default.vcl
# This is a basic VCL configuration file for varnish. See the vcl(7)
# man page for details on VCL syntax and semantics.
#
# TODO: Update internal subnet ACL and security.
# Define the internal network subnet.
# These are used below to allow internal access to certain files while not
# allowing access from the public internet.
# acl internal {
@marioangulo
marioangulo / sshfs_mac
Last active August 29, 2015 14:06
Macfusion SSHFS
Here are the options I used to get it working like a charm. Probably
the lonely needed is noappledouble but I noticed some improvements
with the others.
sshfs -o no_readahead,noappledouble,nolocalcaches user@server:. /mount/point
Just add "-o no_readahead,noappledouble,nolocalcaches" in the extra
options field if you use MacFusion. Maybe this should be default
options.
@marioangulo
marioangulo / 0_reuse_code.js
Last active August 29, 2015 14:06
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
@marioangulo
marioangulo / screen_size_redirect.js
Created September 16, 2014 19:03
Redirect Based of Screen Size
function determineIfSmallSize(redirect_url) {
// Detect pixel ratio for true resolution
window.dpr = 1;
if(window.devicePixelRatio !== undefined) {
window.dpr = window.devicePixelRatio;
}
// Screen orientation - innerWidth and innerHeight works for any device and its orientation, including desktops
@marioangulo
marioangulo / change_max_length.php
Created September 18, 2014 21:09
Drupal 7 Change Field Max Length Function
<?php
/*
* Utility to change the max length of a text field
*/
function change_text_field_max_length($field_name, $new_length) {
$field_table = 'field_data_' . $field_name;
$field_revision_table = 'field_revision_' . $field_name;
$field_column = $field_name . '_value';
// Alter value field length in fields table
@marioangulo
marioangulo / drush_field_info.drush
Created October 8, 2014 19:36
Drush Field Info
<?php
/**
* @file
* Drush commands for displaying info on fields and field instances.
*
* To use, save this file as drush_field_config.drush.inc in your home directory's .drush/ folder.
*/
/**
* Implements hook_drush_command().

In a module file:

This will enable an additional view mode for use on the specified entity type(s). Many examples will show the custom settings here being set to TRUE. If TRUE is used then that view mode is added to all entities of the specified type regardless of if it should be on the bundle or not.

/**
 * Implements hook_entity_info_alter().
 */
function HOOK_entity_info_alter(&$entity_info) {