Skip to content

Instantly share code, notes, and snippets.

View zerolab's full-sized avatar
🖖
Live long and prosper

Dan Braghiș zerolab

🖖
Live long and prosper
View GitHub Profile
@zerolab
zerolab / gist:220671
Created October 28, 2009 18:11
Drupal block visibility depending on the location on the website and geolocation
<?php
// requires the ip2cc module (http://drupal.org/project/ip2cc)
if (!function_exists('drupal_match_path')) {
// copy of http://api.drupal.org/api/function/drupal_match_path/6
function drupal_match_path($path, $patterns) {
static $regexps;
if (!isset($regexps[$patterns])) {
$regexps[$patterns] = '/^('. preg_replace(array('/(\r\n?|\n)/', '/\\\\\*/', '/(^|\|)\\\\<front\\\\>($|\|)/'), array('|', '.*', '\1'. preg_quote(variable_get('site_frontpage', 'node'), '/') .'\2'), preg_quote($patterns, '/')) .')$/';
@zerolab
zerolab / gist:221432
Created October 29, 2009 13:13
Gnome Clock Panel Settings (gconf-editor : apps > panel > applets > clock_screen* > prefs)
<sup><span rise="3000" font_desc="Droid Sans 7.5" color="#878787" weight="normal">%a %d %b</span></sup>%n<sub><span font_desc="Droid Sans 7.5" color="#878787" weight="bold">%I:%M %p</span></sub>
#!/bin/sh
# Author : Dan Braghis <dan [at] zerolab.org>
# Date : 31/10/2009
# depends: java, yuicompressor
# varsion: 1.0
# Minifies the selected files using YUI Compressor (http://developer.yahoo.com/yui/compressor/).
# The script assumes yuicompressor.jar is located in /opt/
IFS='
'
@zerolab
zerolab / gist:251948
Last active September 4, 2015 02:45
nginx config options.
./configure --prefix=/usr \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--user=www-data \
--group=www-data \
--with-http_realip_module \
@zerolab
zerolab / gist:340084
Created March 22, 2010 13:47
various linux shell commands
# Directory size
du --max-depth=1 ./ | sort -n -r
#################################
# full hard disk copy
dd if=/dev/hdx of=/dev/hdy
dd if=/dev/hdx of=/path/to/image
dd if=/dev/hdx | gzip > /path/to/image.gz
@zerolab
zerolab / gist:382534
Created April 28, 2010 18:47
Drupal 5 - Show block if a node has a specific taxonomy term
<?php
// Drupal 5
// Show block if a node has a specific taxonomy term
$show_block = FALSE;
if ( arg(0) == "node" && is_numeric(arg(1)) ) {
$node = node_load(arg(1));
$section_term_id = 1334; // replace this to the corresponding term id
$show_block = ( is_array($node->taxonomy) && in_array($section_term_id, array_keys($node->taxonomy)) );
}
@zerolab
zerolab / drupal_mass-delete_node.php
Created June 23, 2010 11:42
Mass-deletion of Drupal nodetypes
<?php
/**
* Mass delete nodes of $nodetype
* put the file in the Drupal root and adjust $nodetype and $limit as you like
*/
error_reporting(E_ALL);
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
$nodetype = "INSERT_NODETYPE_HERE";
@zerolab
zerolab / purge-gnome-config.sh
Created July 7, 2010 17:05
Quick Gnome config cleanup
### Source: http://www.linuxjournal.com/content/resetting-gnomes-settings-ubuntu
cd ~
rm -rf .gnome .gnome2 .gconf .gconfd .metacity
@zerolab
zerolab / gist:503290
Created August 1, 2010 12:08
Custom Drupal menu items images
<?php
/**
* Implements theme_menu_item_link()
* Courtesy of http://chrisshattuck.com/blog/how-use-images-menu-items-drupal-simple-preprocessing-function
*/
function yourtheme_menu_item_link($link) {
// Allows for images as menu items. Just supply the path to the image as the title
if (strpos($link['title'], '.png') !== false || strpos($link['title'], '.jpg') !== false || strpos($link['title'], '.gif') !== false) {
$link['title'] = '<img alt="'. $link['description'] .'" title="'. $link['description'] .'" src="'. url($link['title']) .'" />';
$link['localized_options']['html'] = TRUE;
@zerolab
zerolab / gist:509545
Last active September 5, 2015 15:04
Stop Apache from logging static files
# Apache, Drupal - don't log static files
# http://2bits.com/drupal-performance/reducing-size-and-io-load-apaches-web-server-log-files.html
SetEnvIf Request_URI "\.(jpg|xml|png|gif|ico|js|css|swf|js?.|css?.)$" DontLog
CustomLog /var/log/apache2/access-example.com.log combined Env=!DontLog