Skip to content

Instantly share code, notes, and snippets.

@cbeier
cbeier / drupal.conf
Last active February 22, 2017 14:17 — forked from podarok/drupal.conf
server {
server_name yourserver.com www.yourserver.com;
root /usr/share/nginx/www/drupal;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
location = /favicon.ico {
log_not_found off;
access_log off;
}
@cbeier
cbeier / DebugQuery.php
Last active August 15, 2017 11:00
Drupal 8: Debug Database Query
<?php
namespace Drupal\YOURNAMESPACE\Helper;
use Drupal\Core\Database\Query\SelectInterface;
class DebugQuery {
/**
* Debug a database query and print it out.
@cbeier
cbeier / gist:f331eeb3a99db1c35646
Last active October 15, 2015 21:02
Drupal 7: Debug Query
<?php
function debug_query($query) {
$querystring = $query->__toString();
$querystring = str_replace("{", '', $querystring);
$querystring = str_replace("}", '', $querystring);
foreach ($query->getArguments() as $key => $item) {
if (!$item) {
$item = 'NULL';
@cbeier
cbeier / .bashrc
Created November 2, 2012 08:51
Drush and Drush Make on DomainFactory Managed Server
alias drush='~/drush/drush'
alias php='/usr/local/bin/php5-53STABLE-CLI'
export DRUSH_PHP=/usr/local/bin/php5-53STABLE-CLI
@cbeier
cbeier / gist:2787268
Created May 25, 2012 10:47
Field Formatter to add an Read More Link in text body
/**
* Implements hook_field_formatter_info().
*/
function hook_field_formatter_info() {
return array(
// The 'summary or trimmed' field formatter for text_with_summary
// fields displays returns the summary element of the field or, if
// the summary is empty, the trimmed version of the full element
// of the field.
// If the Read More link option is used, a link will be placed after
@cbeier
cbeier / gist:1669002
Created January 24, 2012 09:05
Settings for Environment Indicator module
/**
* Settings for Environment Indicator module
*
* Text:
* - DEVELOPMENT ENVIRONMENT
* - STAGING ENVIRONMENT
* - PRODUCTION ENVIRONMENT
*
* Color (based on http://ethanschoonover.com/solarized):
* - Development: #268bd2
<?php
// Ersetze template mit dem Namen deines Templates
template_preprocess_node(&$variables) {
$variables['content']['body]['#items'][0]['summery']['#prefix'] = '<p>;
$variables['content']['body]['#items'][0]['summery']['#prefix'] = '</p>;
}
?>
@cbeier
cbeier / gist:557544
Created August 30, 2010 15:19
Redaxo: Erweiterte Datenfelder
// Redaxo Modul Aktion für die Erweiterung der möglichen Datenfelder
// Zuordnung der Redaxo Aktion zum entsprechenden Modul nicht vergessen! ;)
// Presave/Postsave-Action (jeweils in das Textfeld einfügen)
<?php
$newname = "";
for ($c=0;$c<99;$c++)
$newname .= $rexname[$c]."~";
if ($REX_ACTION[VALUE][1] != "")
@cbeier
cbeier / patch_building_forms.css
Created April 6, 2010 08:30
Fix for YAML sup/sub bug (IE6 / IE7)
/**
* Bugfix for line-height bug on sup/sub element
*
* @bugfix
* @affected IE 5.x/Win, IE6, IE7
* @css-for IE 5.x/Win, IE6, IE7
* @yalid yes
*/
html sup,
@cbeier
cbeier / gist:344692
Created March 26, 2010 08:58
calculate the exact age
def age(birthday)
y = Date.today.year - birthday.year
m = Date.today.month - birthday.month
d = Date.today.day - birthday.day
case
when m < 0
age = y-1
when m = 0
case
when d = 0