Skip to content

Instantly share code, notes, and snippets.

@perifer
perifer / ckedit.make
Created July 9, 2012 13:54
Drupal make file for ckeditor/wysiwyg
; Wysiwyg make file. Specify core version below.
; Place in Drupal root and run from the drupal
; root directory with
; drush make ckedit.make --no-core .
core = 6.x
;core = 7.x
api = 2
@perifer
perifer / aliases.drushrc.php
Created March 1, 2012 13:03
Automatic drush aliases from git remotes.
<?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 January 24, 2012 07:59
Track events on external pages - asynchronous Google Analytics
(function($) {
var passThrough = false;
var track = function(el, action) {
_gaq.push(["_trackEvent", "Connect/Log in", action]);
passThrough = true;
_gaq.push(function() {
$(el).trigger("click");
});
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 December 19, 2011 05:30
json-encode Drupal and Wordpress database settings
<?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;
@perifer
perifer / adaptive-menu.jquery.js
Created November 21, 2011 20:30
Responsive menu
(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 September 28, 2015 03:18
Clean up Drupal 6 db dump
-- 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 November 3, 2011 09:28
Script to move download/recreated features to correct folder. Perfect as an Automator Folder Action.
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$")
<?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;
@perifer
perifer / gist:1327738
Created October 31, 2011 15:22
Install XHProf

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