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 / d5-paging_ordered_cck_fields.patch
Created August 30, 2010 20:55
Fixes the Drupal 5 + Paging 5.x-1.2 and missing CCK fields (http://drupal.org/node/286260)
--- paging.module 2009-01-23 23:53:18.000000000 +0000
+++ paging.module 2010-08-30 21:26:41.081673004 +0100
@@ -242,14 +242,63 @@ function _paging_nodeapi(&$node, &$node_
$node->body = check_markup($node->pages[$page], $node->format, false);
$position = variable_get('paging_pager_widget_position', 'below');
$node->paging = theme('pager', NULL, 1, $element);
+
+ // Remove internal <!--paging_filter--> tag from final output.
+ $node->body = str_replace('<!--paging_filter-->', '', $node->body);
+
@zerolab
zerolab / gist:562254
Created September 2, 2010 13:02
convert OGV to h264
ffmpeg -i input.ogv -vcodec libx264 -vpre fast -crf 22 -threads 2 output.mp4
@zerolab
zerolab / timeline-2.4.x.js
Created September 10, 2010 08:58
packed Timeline pre-2.4.0
/* Timeline API pre 2.4.0
* Copyright Massachusetts Institute of Technology
* and Contributors 2006-2009 ~ Some rights reserved
* Timeline is open source software and is licensed
* under the BSD license.
* http://www.simile-widgets.org/timeline/
*/
(function(){var Timeline,SimileAjax;var loadMe=function(){Timeline=window.Timeline=new Object();Timeline.DateTime=SimileAjax.DateTime;try{(function(){if(typeof Timeline_urlPrefix=="string"){Timeline.urlPrefix=Timeline_urlPrefix;if(typeof Timeline_parameters=="string"){parseURLParameters(Timeline_parameters)}}else{var heads=document.documentElement.getElementsByTagName("head");for(var h=0;h<heads.length;h++){var scripts=heads[h].getElementsByTagName("script");for(var s=0;s<scripts.length;s++){var url=scripts[s].src;var i=url.indexOf("timeline-2.4.x.js");if(i>=0){Timeline.urlPrefix=url.substr(0,i);var q=url.indexOf("?");if(q>0){parseURLParameters(url.substr(q+1))}return}}}throw new Error("Failed to derive URL prefix for Timeline API code file
/*------------------- Horizontal / Vertical lines ----------------*/
/* style for ethers */
.timeline-ether-lines{border-color:#666; border-style:dotted; position:absolute;}
.timeline-horizontal .timeline-ether-lines{border-width:0 0 0 1px; height:100%; top: 0; width: 1px;}
.timeline-vertical .timeline-ether-lines{border-width:1px 0 0; height:1px; left: 0; width: 100%;}
@zerolab
zerolab / win2unicode.js
Created October 7, 2010 13:02
Windows-1251 to Unicode converter
/**
* Windows-1251 to Unicode converter
* Useful when having to use GET query parameters.
* e.g. unescaped "%F2%E5%EA%F1%F2", "òåêñò" becomes "текст"
* Source: http://xpoint.ru/know-how/JavaScript/PoleznyieFunktsii?38#PerekodirovkaIzWindows1251IKOI
*/
function win2unicode(str) {
var charmap = unescape(
"%u0402%u0403%u201A%u0453%u201E%u2026%u2020%u2021%u20AC%u2030%u0409%u2039%u040A%u040C%u040B%u040F"+
"%u0452%u2018%u2019%u201C%u201D%u2022%u2013%u2014%u0000%u2122%u0459%u203A%u045A%u045C%u045B%u045F"+
#! /bin/sh
# Source: http://bugs.launchpad.net/ubuntu/+source/linux/+bug/352228/comments/109
#
# bring them down
pkill nm-app
sudo modprobe -v -r iwlagn
sudo /etc/init.d/network-manager stop
sudo /etc/init.d/network-interface stop
sudo /etc/init.d/networking stop
# start again
@zerolab
zerolab / gist:814716
Created February 7, 2011 17:00
Drupal: perform any action when a node is published
<?php
/**
* Implementation of hook_nodeapi()
* Perform any action when a node is published
* Note: because no extra data added via $op = 'load', a node "reload" is necessary on presave
*/
function mymodule_nodeapi(&$node, $op) {
if ($op == 'presave') {
if ($node->type == 'my_node_type' && $node->status == 1) {
@zerolab
zerolab / gist:825745
Created February 14, 2011 11:22
Drupal / LAMP stack optimizations
;Expires
;=======
ExpiresByType text/html "access plus 3 hours"
ExpiresByType image/gif "modification plus 1 year"
ExpiresByType image/png "modification plus 1 year"
ExpiresByType image/jpg "modification plus 1 year"
ExpiresByType image/ico "modification plus 1 year"
ExpiresByType text/js "modification plus 1 month"
ExpiresByType text/css "modification plus 1 mont
@zerolab
zerolab / gist:826873
Created February 15, 2011 00:28
GMail-like buttons
<!--
GMail-style buttons
/via http://gregbabula.com/
-->
<style>
a {
font: 12px/12px "Helvetica Neue", Helvetica, sans-serif;
border-top: 1px solid #eee;
border-right: 1px solid #ccc;
border-bottom: 1px solid #ccc;
@zerolab
zerolab / gist:996854
Created May 28, 2011 13:13
Patch Drupal between versions
#
# Get the last 2 versions and unpack
#
wget DRUPAL-new && tar zxvf DRUPAL-new
wget DRUPAL-old && tar zxvf DRUPAL-old
#
# Create a diff patch
#
diff DRUPAL-old DRUPAL-new > drupal-XtoY.patch