This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/etc/cron.daily/mysqldumpcron: | |
#!/bin/bash | |
# | |
# Create a MySQL user: GRANT SELECT, RELOAD, REPLICATION CLIENT ON *.* TO backup@localhost identified by 'password'; | |
USER=backup | |
PASSWORD=password | |
# | |
# Dump the mysql and pgsql databases to a daily dump file. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hosts=$( sed -ne 's/^[ ]*[Hh][Oo][Ss][Tt]\([Nn][Aa][Mm][Ee]\)\{0,1\}[ ]*\([^#*?]*\)\(#.*\)\{0,1\}$/\2/p' .ssh/config ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function mymod_menu() { | |
$items['view/path/that/returns/the/json] = array( | |
'title' => t('JSON Callback'), | |
'page callback' => 'mymod_callback', | |
'access callback' => TRUE, | |
'type' => MENU_CALLBACK, | |
); | |
return $items; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set password authentication on nominated hostname via the | |
# setenvif module. | |
<IfModule mod_setenvif.c> | |
AuthType Basic | |
AuthName "Enter a damn password you monkey" | |
AuthUserFile /some/htpasswd | |
Require valid-user | |
SetEnvIf Host .*\.example\.com$ NEED_AUTH | |
SetEnvIf Host .*\.example2\.com$ NEED_AUTH |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function mytheme_preprocess_node(&$variables) { | |
$author = node_load($variables['node']->uid); | |
$variables['author_mail'] = check_plain($author->mail); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_preprocess_node(&$variables) { | |
$terms = field_get_items('node', $variables['node'], 'field_topic'); | |
$parents = taxonomy_get_parents($terms[0]['tid']); | |
$parent = array_shift($parents); | |
$variables['top_topic'] = field_view_value('node', $node, 'field_topic', array('tid' => $parent->tid)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
CONFIG=/etc/mysql/conf.d/xtradb-cluster.cnf | |
# With a syntax of gcomm://foo,bar,frog this should work eh? | |
NODES="$(grep ^wsrep_cluster_address ${CONFIG} | cut -d '/' -f3- | tr ',' ' ')" | |
if [ -z "${NODES}" ]; then | |
echo "Cannot find cluster nodes in config file: ${CONFIG}" | |
exit 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Add yer string! | |
$data = ''; | |
define('PATTERN', '/s:(\d+):"(.*?)";([Obis]):((\d+):)?([^;]+);/'); | |
// Care not for arrays. | |
$blob = preg_replace('/a:\d+:{/', "\n", $data); | |
// Can't cope with objects. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$text = "Whatever stuff with URLs in it."; | |
$protocols = array('http', 'https', 'ftp'); | |
$protocols = implode(':(?://)?|', $protocols) . ':(?://)?'; | |
// Prepare domain name pattern. | |
// The ICANN seems to be on track towards accepting more diverse top level | |
// domains, so this pattern has been "future-proofed" to allow for TLDs | |
// of length 2-64. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/php | |
<?php | |
// define('FORMAT', 'jS F Y'); | |
// define('FORMAT', 'YYYY/mm/dd MMM M m mmm ddd j S EEEE'); | |
define('FORMAT', 'dd'); | |
define('LOCALE', 'nl_NL.UTF-8'); | |
$alpha = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z'); | |
/** |