Skip to content

Instantly share code, notes, and snippets.

@perifer
perifer / aliases.drushrc.php
Created Mar 1, 2012
Automatic drush aliases from git remotes.
View aliases.drushrc.php
<?php
/**
* Place this file in e.g ~/.drush.
* See `drush topic docs-aliases` for more info.
*/
// Use require_once since this file is invoked multiple times.
require_once('git_remote_alias.php');
git_remote_alias_set('live', $aliases);
git_remote_alias_set('staging', $aliases);
@perifer
perifer / gist:1668761
Created Jan 24, 2012
Track events on external pages - asynchronous Google Analytics
View gist:1668761
(function($) {
var passThrough = false;
var track = function(el, action) {
_gaq.push(["_trackEvent", "Connect/Log in", action]);
passThrough = true;
_gaq.push(function() {
$(el).trigger("click");
});
View ssh_pipe_example.py
import os
import re
from fabric.api import *
from urlparse import urlparse
def task(project):
try:
# User can set their project directory with
# export PROJECT_DIR= in their shell
@perifer
perifer / gist:1495543
Created Dec 19, 2011
json-encode Drupal and Wordpress database settings
View gist:1495543
<?php
// Drupal 6
$settings_file = '/Users/anders/Projects/drupal-6.local/public_html/sites/default/settings.php';
require($settings_file);
$parsed_db_url = parse_url($db_url);
$parsed_db_url['database'] = substr($parsed_db_url['path'], 1);
$parsed_db_url['password'] = $parsed_db_url['pass'];
$parsed_db_url['username'] = $parsed_db_url['user'];
$parsed_db_url['prefix'] = $db_prefix;
View adaptive-menu.jquery.js
(function($){
$.fn.adaptiveMenu = function(options) {
// Create some defaults, extending them with any options that were provided
var settings = $.extend({
resize: true,
resizeDelay: 20
}, options),
resizeTimer = false,
els = this;
@perifer
perifer / cleard7.sql
Last active Sep 28, 2015
Clean up Drupal 6 db dump
View cleard7.sql
-- Munge emails and reset passwords.
UPDATE users SET mail = CONCAT(name, '@localhost'), init = CONCAT(name, '@localhost'), pass = 'pass';
-- UPDATE authmap SET authname = CONCAT(aid, '@localhost');
-- Remove irrelevant data that bulks up the dump and contains IP-addresses
TRUNCATE cache;
TRUNCATE cache_block;
TRUNCATE cache_bootstrap;
TRUNCATE cache_field;
TRUNCATE cache_filter;
@perifer
perifer / gist:1336127
Created Nov 3, 2011
Script to move download/recreated features to correct folder. Perfect as an Automator Folder Action.
View gist:1336127
import sys
import os
import os.path
import re
import subprocess
import shutil
destination = "/Users/USER/Projects/SITE/public_html/sites/all/modules/feauters"
module = re.compile(r".*/(PREFIX)[^/]*.tar$")
View gist:1330608
<?php
/**
* Implementation of hook_preprocess().
*/
function manniskohjalp_preprocess(&$vars, $hook) {
// Static variable used for passing data from preprocess functions,
// e.g from preprocess-view to preprocess-page.
$manniskohjalp_shared = &drupal_static(__FUNCTION__, array());
$vars['manniskohjalp_shared'] = $manniskohjalp_shared;
View gist:1327738

1. Download and install latest version:

cd ~/Projects
git clone https://github.com/facebook/xhprof.git xhprof.YOURDOMAIN
cd xhprof.YOURDOMAIN/extension
phpize
CFLAGS="-arch x86_64 -arch i386"
./configure
make
@perifer
perifer / ckeditor_settings.info
Created Oct 17, 2011
ckeditor module settings
View ckeditor_settings.info
name = CKEditor settings
description = Special settings for CKEditor/Wysiwyg module.
package = User interface
core = 7.x
dependencies[] = wysiwyg