Skip to content

Instantly share code, notes, and snippets.

<?php
declare(strict_types=1);
namespace DanBettles\Marigold\Utils;
use function array_replace;
use function pathinfo;
use const null;
@danbettles
danbettles / _mixins.scss
Created May 21, 2016 12:52
Sass mixin for Compass that vertically centres a descendant of the element in which it is included. The mixin neatly wraps-up Sebastian Ekström's updated solution in http://zerosixthree.se/vertical-align-anything-with-just-3-lines-of-css/
@import "compass/css3/transform";
@mixin vertically-centre-descendant($descendant-selector, $descendant-position: relative) {
@include transform-style(preserve-3d);
position: relative;
#{$descendant-selector} {
@include transform(translateY(-50%));
position: $descendant-position;
top: 50%;
@danbettles
danbettles / css_minifier.php
Created June 14, 2013 13:34
Basic, but very effective, CSS minifier for CodeIgniter - or anything else if you extract the behaviour.
<?php
/**
* @author Dan Bettles <danbettles@yahoo.co.uk>
*
* @license http://creativecommons.org/licenses/by-nc-sa/2.0/uk/ by-nc-sa
*/
if ( ! defined('BASEPATH'))
{
exit('No direct script access allowed');
@danbettles
danbettles / active_resource_model.php
Created June 28, 2012 09:37
Simple, GET-only version of Rails' ActiveResource for CodeIgniter
<?php
/**
* Active_resource_model is a simple, GET-only version of Rails' ActiveResource
* (http://api.rubyonrails.org/classes/ActiveResource/Base.html) for CodeIgniter.
*
* Only JSON data sources are supported at present. Active_resource_model requires the CodeIgniter "curl" library
* (http://getsparks.org/packages/curl/show).
*
* Copy this file into application/models and then add "Active_resource_model" to the models array in
* application/config/autoload.php.
@danbettles
danbettles / build_jsmin.sh
Created May 29, 2012 07:51
Building JSMin on Linux
#!/bin/sh
TEMP_DIR="/tmp/jsmin"
SRC_FILENAME="http://www.crockford.com/javascript/jsmin.c"
SRC_BASENAME="jsmin.c"
BIN_BASENAME="jsmin"
BIN_DIR="/bin"
mkdir $TEMP_DIR
cd $TEMP_DIR