This file contains 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 | |
/** | |
* Search a block of text for a given text string | |
* | |
* @param string $pattern | |
* A regexp to match against | |
* @param string|array $input | |
* A string or array (can't handle recursiveness) to search | |
* @param int $context | |
* Returns x number of lines surrounding the hit |
This file contains 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 | |
/** | |
* Make MySQL correctly sort nodes on swedish sites | |
*/ | |
function hook_install() { | |
db_query("ALTER TABLE {node} MODIFY | |
title VARCHAR(255) | |
CHARACTER SET utf8 | |
COLLATE utf8_swedish_ci"); | |
} |
This file contains 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 | |
// One liner to kill the bastards. | |
preg_replace('/\s(?!.*\s)/', ' ', $string); |
This file contains 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
// Character counter | |
$('#edit-field-tagline-0-value, #edit-body').keydown(function(event) { | |
var id = $(this).attr('id'); | |
var counter = $('label[for="' + id + '"]').children('span'); | |
if (!counter.length) { | |
$('label[for="' + id + '"]').append('<span></span>'); | |
counter = $('label[for="' + id + '"]').children('span'); | |
} | |
counter.text(' (Antal tecken: ' + $(this).val().length + ')'); |
This file contains 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/env bash | |
# Usage: fm nameoffile.php | |
# Searches the current dir you're in | |
function fm { | |
find . -name "$1" -exec mate {} \; | |
} |
This file contains 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 | |
/** | |
* @file | |
* Deploy site backups as new sites on a new server. | |
* Duplicate platform before doing this. | |
*/ | |
// Path to directory containing backups | |
define('BACKUP_PATH', '/var/aegir/backups'); |
This file contains 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
var language = (function ($) { | |
var current = 'en' | |
, languages = { sv: {} | |
, da: {} | |
, en: {} | |
} | |
, self = {}; | |
/** | |
* Set the language strings |
This file contains 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 | |
/** | |
* @file | |
* Helper class for encoding images as Base64. | |
* Has support for the Drupal module ImageCache, just provide it with your | |
* preset name if you'd like the class to use that version of an image instead. | |
* Is by no means dependent on Drupal though. Just a nice feature. | |
* Feel free to use it as you like. | |
* | |
* @author Simon Ljungberg <simon@nimnim.se> |
This file contains 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 | |
// Update translations | |
// This might need some 'splainin': | |
// RecursiveDirectoryIterator together with RecursiveIteratorIterator | |
// loops through all files in the give root directory. | |
// RegexIterator filters out the files we want (modules-topbar and | |
// themes-xskane) translations in this case. Matches the languages code | |
// and filename. Then we loop through it and win. | |
$di = new RecursiveDirectoryIterator('./sites/all/translations/'); | |
$it = new RecursiveIteratorIterator($di); |
This file contains 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
/** | |
* @file | |
* Generates some various HTML stuffs. | |
*/ | |
var fs = require('fs') | |
, jsdom = require('jsdom') | |
; | |
/** | |
* Welds some HTML together with a bunch of data |
OlderNewer