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 / bundle.css
Created August 17, 2012 17:17
Test book bundle layout
.card {
float: left;
margin: 0 16px 16px 0;
background: #fff;
border: 1px solid #eaeaea;
border-radius: 4px;
padding-left: 122px;
width: 300px;
box-sizing: border-box;
}
@zerolab
zerolab / gist:3994995
Created November 1, 2012 16:51
Empty all files in a directory matching extension
#!/bin/bash
# this example 'touches' all PDFs
for file in $(find . -type f -iname '*.pdf')
do
echo " " > $file
done
@zerolab
zerolab / updatecore.sh
Last active December 10, 2015 13:48
Quick update Drupal core
#!/bin/bash
#
# Upgrades/Installs Drupal core. Targeted at Drupal 6
# Script based on gopressflow.sh
# @see https://gist.github.com/zerolab/4733662
#
# * Run this script in your DRUPAL_ROOT
# * Backup your files before doing anything!
#
@zerolab
zerolab / gist:4598966
Created January 22, 2013 22:05
Example usage of onbeforeunload(). Used extensively in GMail, Google Docs, CodePen etc when there are unsaved changes.
// Pseudo code for using onbeforeunload()
$(window).on('unsaved', function(event) {
window.onbeforeunload = function() {
return "SOMETHING BAD if you navigate away.";
}
}).on("save", function(event) {
window.onbeforeunload = void(0);
});
@zerolab
zerolab / gopressflow.sh
Last active May 19, 2016 10:50
Update Pressflow
#!/bin/bash
#
# Upgrades/Installs Pressflow over your Drupal installation
#
# * Must be run from your Drupal root directory
# * Backup your files before doing anything!
# * e.g. run: ./gopressflow.sh 6.38.121
#
# You can get the exact release version from https://github.com/pressflow/6/releases
#
@zerolab
zerolab / ascii sample
Last active March 16, 2016 23:30
Druplicon ASCII art
,;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;,,'''''''''''''''.
,;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;,,''''''''''''''''''
,;;;;;;;;;;;;;;;;;;;;;;;;;;;cldxkkOkkxxdlc;;;;;;;;;;;;;;;;;;;;;;;;,,''''''''''',''''''''
,;;;;;;;;;;;;;;;;;;;;;;;:ox0XWMMMMMMMMMWNX0kxdc;;;;;;;;;;;;;;;;,,,'''''''';cdk00Okl,''''
,;;;;;;;;;;;;;;;;;;;;;cxKWMMMMMMMMMMMMMMMMMMMWN0xl;;;;;;;;;;,,,'''''''';lkKWMMMMMMW0c'''
',;;;;;;;;;;;;;;;;;;:dKWMMMMMMMMMMMMMMMMMMMMMMMMMN0xl;;;;;,,'''''''';okXWMMMMMMMMMMM0:'.
.,;;;;;;;;;;;;;;;;;:kNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMN0xl;''''''',:oOXWMMMMMMMMMMMMMMNd'.
.',;;;;;;;;;;;;;;;;xWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMN0xolccoxONMMMMMMMMMMMMMMMMMMWd'.
.,;;;;;;;;;;;;;;;oXMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWNWMMMMMMMMMMMMMMMMMMMMMMXl..
.',;;;;;;;;;;;;;;xNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWX0OOOKNMMMMMMMMMMMMMMMMMMMM0;.
@zerolab
zerolab / gist:5065610
Last active December 14, 2015 09:29
Drupal Apache Solr: prevent facet's filtering influence on facet item count
<?php
// Add tags to fq and facet.field fields to exclude each facet's filtering
// from influencing its own facet item count
// @see http://drupal.org/node/1446824#comment-5634040
$params = $query->getParams();
$fq = $params['fq'];
if (!empty($fq)) {
$facet_field = $params['facet.field'];
@zerolab
zerolab / gist:5200481
Last active December 15, 2015 04:19
Detect the user's home dir on Linux/Windows
<?php
/**
* Get the home directory
*
* @see http://techblog.zabuchy.net/2012/how-to-detect-user-home-directory-php-linux-windows/
*/
function homedir() {
// getenv('HOME') isn't set on windows and generates a Notice.
$home = getenv('HOME');
diff --git includes/ds.features.inc includes/ds.features.inc
index ba92367..96558df 100644
--- includes/ds.features.inc
+++ includes/ds.features.inc
@@ -115,6 +115,9 @@ function ds_features_revert($module = NULL) {
foreach ($setting as $build_mode => $conf) {
// Remove old settings.
+ db_query("DELETE FROM {ds_settings} WHERE build_mode = '%s' AND module = '%s' AND type = '%s'", $build_mode, $ds_module, $object_type);
+
@zerolab
zerolab / 561990-variable_init.patch
Last active December 19, 2015 00:09
Prevent variable_init from returning an empty array. @see https://github.com/pressflow/6/pull/37
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc
index 8c5b294..2bf283a 100644
--- a/includes/bootstrap.inc
+++ b/includes/bootstrap.inc
@@ -568,6 +568,13 @@ function variable_init($conf = array(), $regenerate = FALSE, $recursion_depth =
else {
if (defined('MAINTENANCE_MODE') || lock_acquire('variable_cache_regenerate')) {
$result = db_query('SELECT * FROM {variable}');
+ // Exit here if the database went away. Do not want to pollute the cache
+ // with bad data. This request isn't going to end well anyway; end it