Skip to content

Instantly share code, notes, and snippets.

@perifer
perifer / simple_geo_geocode_example.inc.php
Created March 1, 2011 13:47
Converts addresses from a node and saves them as simple_geo positions, using the Google Geocoding API.
<?php
/**
* Converts addresses from a node and saves them as simple_geo positions, using
* the Google Geocoding API: http://code.google.com/apis/maps/documentation/geocoding/
*/
// Add this to a hook_menu:
// $items['admin/simple-geo/geocode-example'] = array(
/* $Id: styles.css,v 1.2 2008/01/16 11:45:00 fha Exp $ */
body {
padding: 33px 0 0 0;
margin: 0;
background: #fff url(bg_top00.gif) 0 0 no-repeat;
color: #333;
font: 12px arial, helvetica, verdana, sans-serif;
position: relative;
}
@perifer
perifer / D6.php
Created June 13, 2011 07:40
"« 1 2 3 4 5 6 7 8 9 ... 44 »"-styled pager for Drupal.
<?php
/**
* Override default pager to get a pager with last and first page represented by numbers.
* E.g: « 1 2 3 4 5 6 7 8 9 ... 44 »
*/
function THEME_pager($tags = array(), $limit = 10, $element = 0, $parameters = array(), $quantity = 9) {
global $pager_page_array, $pager_total;
// Calculate various markers within this pager piece:
// Middle is used to "center" pages around the current page.
@perifer
perifer / ckeditor_settings.info
Created October 17, 2011 19:28
ckeditor module settings
name = CKEditor settings
description = Special settings for CKEditor/Wysiwyg module.
package = User interface
core = 7.x
dependencies[] = wysiwyg
@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
<?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: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$")
@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 / 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 / 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;