Skip to content

Instantly share code, notes, and snippets.

@peteboere
peteboere / named_args.php
Last active August 29, 2015 13:57
Named arguments in PHP 5.4
<?php
function named_args($required, $options = [])
{
extract($options + [
'option_one' => false,
'option_two' => true,
'option_three' => 100,
]);

Sass/CSS-Crush Comparison

This is an adaptation of the Sass/Less comparison document.

Not a comprehensive overview of features of either library but a comparison of commonalities.

Variables

Sass | Crush

@peteboere
peteboere / theme_image.php
Last active April 13, 2018 13:03
Drupal theme overrides for better accessibility
<?php
/*
theme_image() override.
*/
function THEME_image($vars)
{
// [Accessibility] Images must always have an alt attribute.
if (! isset($vars['alt'])) {
$vars['alt'] = '';
@peteboere
peteboere / README.md
Created November 26, 2012 12:20
Avoid console errors in browsers that lack a console.
@peteboere
peteboere / svg.bash
Created August 8, 2012 11:16
Utilities for working with svgs
#
# Utilities for working with svgs
#
# svg2png - Create png file from source svg using inkscape
# svg2pngr - Create png file from source svg using inkscape recursively
# svgz - Create svgz file from source svg
# svgzr - Create svgz file from source svg recursively
#
@peteboere
peteboere / jquery.balanceheights.js
Created February 17, 2012 09:53
Small jQuery plugins
/*
* Equalise the height of boxes (uses min-height).
*/
jQuery.fn.balanceHeights = function() {
// Get max height from list then apply to all.
var heights = [];
this.each( function () {
heights.push(jQuery(this).outerHeight());
});
return this.css('min-height', Math.max.apply({}, heights));
@peteboere
peteboere / dabblet.css
Created February 3, 2012 12:31 — forked from anonymous/dabblet.css
Watermark background with CSS3 multiple-backgrounds, element() and linear-gradient()
/**
* Watermark background with CSS3 multiple-backgrounds, element() and linear-gradient()
*/
h1 {
font:italic 4em Georgia,serif;
text-align:center;
padding: 1em 0 0;
margin:0 0 .3em;
}
@peteboere
peteboere / jquery.alterclass.js
Created December 24, 2011 12:49
jQuery alterClass plugin: Remove element classes with wildcard matching. Optionally add classes.
/**
* jQuery alterClass plugin
*
* Remove element classes with wildcard matching. Optionally add classes:
* $( '#foo' ).alterClass( 'foo-* bar-*', 'foobar' )
*
* Copyright (c) 2011 Pete Boere (the-echoplex.net)
* Free under terms of the MIT license: http://www.opensource.org/licenses/mit-license.php
*
*/
@peteboere
peteboere / pretty-number.js
Created November 25, 2011 19:26
Format number with commas
var prettyNumber = function ( number ) {
var number = ( number ).toString(),
point = number.indexOf( '.' ),
floatPart = '',
out = [],
stream;
if ( -1 !== point ) {
floatPart = number.substring( point );
number = number.substring( 0, point );
}
@peteboere
peteboere / up.sh
Created October 22, 2011 18:05
Bash function for 'cd'ing up the directory tree
#
# Bash function for 'cd'ing up the directory tree
#
# Example use:
# Move working directory up 5 levels
# $> up 5
# Equivalent to
# $> cd ../../../../../
#