Skip to content

Instantly share code, notes, and snippets.

View hkirsman's full-sized avatar

Hannes Kirsman hkirsman

  • Estonia, Tallinn
View GitHub Profile
@hkirsman
hkirsman / display_errors_all.php
Created November 24, 2015 11:54
Display all errors
error_reporting(E_ALL);
ini_set('display_errors', 1);
@hkirsman
hkirsman / js_for_loop.js
Last active November 23, 2015 14:38
Javascript for loop
for (var i = 0; i < cars.length; i++) {
text += cars[i] + "<br>";
}
@hkirsman
hkirsman / hook_wysiwyg_editor_settings_alter.php
Last active January 4, 2016 05:39
Alter default Drupal CKEditor.
<?php
/**
* Implements hook_wysiwyg_editor_settings_alter().
*/
function salva_wysiwyg_editor_settings_alter(&$settings, &$context) {
if ($context['profile']->editor == 'ckeditor') {
if (arg(0) == 'node') {
$nid = arg(1);
@hkirsman
hkirsman / rasterize.js
Last active December 30, 2015 08:29 — forked from FiloSottile/rasterize.js
Add 4x zoom.
var page = require('webpage').create(),
address, output, size;
if (phantom.args.length < 2 || phantom.args.length > 3) {
console.log('Usage: rasterize.js URL filename');
phantom.exit();
} else {
address = phantom.args[0];
output = phantom.args[1];
page.viewportSize = { width: 2000, height: 100 };
@hkirsman
hkirsman / add_css_class_to_first_block_in_region.php
Last active December 24, 2015 21:49
Find the first block in content region that is not messages block and add class first-content-block-in-region to it.
<?php
function THEME_preprocess_page(&$vars) {
foreach ($variables['page']['content']['content']['content'] as $key => &$var) {
if (isset($var['#block']) && $key !== 'delta_blocks_messages') {
$var['#block']->css_class = 'first-content-block-in-region';
break;
}
}
}
@hkirsman
hkirsman / lte-ie-8.css
Last active December 24, 2015 16:19
Drupal lte-ie-8.css
<?php
function THEME_preprocess_html(&$vars) {
drupal_add_css(drupal_get_path('theme', 'THEME') . '/css/lte-ie8.css', array(
'group' => 9999,
'weight' => 9999,
'browsers' => array(
'IE' => 'lte IE 8',
'!IE' => FALSE
),
@hkirsman
hkirsman / equalHeight.js
Created June 28, 2013 09:49
Equal height script
jQuery.fn.equalHeight = function() {
var $el = $(this);
var colsHighest = 0;
$el.css('min-height', 0).each(function() {
var height = $(this).height();
if (height > colsHighest) {
colsHighest = height;
}
});
@hkirsman
hkirsman / disable-menuitems.php
Created June 28, 2012 18:46
Wordpress plugin to disable some menu items
<?php
/**
* @package Disable_Menuitems
* @version 1.0
*/
/*
Plugin Name: Disable Menuitems
Plugin URI:
Description: Remove some admin menuitems
@hkirsman
hkirsman / mobtable.html
Created June 27, 2012 08:34
turn tables into mobile friendly
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="et">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>table</title>
<style type="text/css">
.odd { background-color: #808080; }
.generated_for_mobile { margin-bottom: 30px }
@hkirsman
hkirsman / functions.php
Created June 26, 2012 19:55
Wordpress WPML custom
<?php
function languages_list_custom() {
$languages = icl_get_languages('orderby=code');
$languages_count = count($languages);
if(!empty($languages) && $languages_count>1){
echo '<div id="lang_sel_list_custom"><ul>';
$i=1;
global $sitepress_settings;
$show_flags = $sitepress_settings['icl_lso_flags'];