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
/**
* Optimised GA async snippet
*
* @see http://mathiasbynens.be/notes/async-analytics-snippet
*/
<script>
var _gaq = [['_setAccount', 'UA-XXXXX-X'], ['_trackPageview']];
(function(d, t) {
var g = d.createElement(t),
s = d.getElementsByTagName(t)[0];
@zerolab
zerolab / gist:1474455
Created December 13, 2011 23:28
Detect taxonomy term loops in Drupal 6
<?php
/**
* Detect taxonomy term loops in Drupal 6
* http://davidherron.com/content/save-your-server-detect-taxonomy-term-loops-drupal-6
*/
$result = db_query('SELECT tid, name FROM {term_data}');
while ($term = db_fetch_object($result)) {
drush_print( '>>> '. $term->name);
$parents = safe_get_parents_all($term->tid);
@zerolab
zerolab / data_icon.css
Created December 14, 2011 20:23 — forked from nathansmith/data_icon.css
Terse Font Icons
a[data-icon]:before,
span[data-icon]:before {
font-family: 'Icon Font Here';
content: attr(data-icon);
}
/*
This would also work, but other web developers might
yell at you about "performance" which may/not matter:
@zerolab
zerolab / gist:1633661
Created January 18, 2012 15:52
Convert smart quotes with regular ones (and vice-versa)
<?php
//Quotes: Replace smart double quotes with straight double quotes.
//ANSI version for use with 8-bit regex engines and the Windows code page 1252.
preg_replace('[\x84\x93\x94]', '"', $text);
//Quotes: Replace smart double quotes with straight double quotes.
//Unicode version for use with Unicode regex engines.
preg_replace('[\u201C\u201D\u201E\u201F\u2033\u2036]', '"', $text);
@zerolab
zerolab / hack.sh
Created April 4, 2012 08:41 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@zerolab
zerolab / git-notes.md
Last active October 5, 2015 16:48
Note on Git commit messages

Capitalized, short (50 chars or less) summary

More detailed explanatory text, if necessary. Wrap it to about 72 characters or so. In some contexts, the first line is treated as the subject of an email and the rest of the text as the body. The blank line separating the summary from the body is critical (unless you omit the body entirely); tools like rebase can get confused if you run the two together.

Write your commit message in the present tense: "Fix bug" and not "Fixed

@zerolab
zerolab / gist:2991196
Created June 25, 2012 20:57
Drupal cron fail info with drush
# from http://millwoodonline.co.uk/blog/drupal-cron-failing-not-sure-why-heres-handy-drush-command
drush php-eval ' global $timers; $hook = 'cron'; $return = array(); foreach (module_implements($hook) as $module) { $function = $module . '_' . $hook; print($function ." - "); timer_start($function); $result = call_user_func_array($function, $args); if (isset($result) && is_array($result)) { $return = array_merge_recursive($return, $result); } else if (isset($result)) { $return[] = $result; } timer_stop($function); print($timers[$function]['time'] ."\r\n"); }'
@zerolab
zerolab / gist:3220492
Created July 31, 2012 20:59
Scrolling stack effect
/*
Stack effect a la http://googleventures.com
<div id="layer_base"></div>
<div id="layer_one"></div>
*/
#layer_base {
height: 100px;
@zerolab
zerolab / gist:3358410
Created August 15, 2012 10:10
Colors
Berlin Blue - #0046AE
@zerolab
zerolab / overlay.css
Created August 17, 2012 16:20
simple iphone/android promo overlay
div.modal {
background:rgba(0, 0, 0, 0.5);
position:fixed;
top:0;
right:0;
bottom:0;
left:0;
}
.promo {