Skip to content

Instantly share code, notes, and snippets.

View pietvanzoen's full-sized avatar

Piet van Zoen pietvanzoen

View GitHub Profile
@pietvanzoen
pietvanzoen / extend.less
Last active December 19, 2015 14:09
LESS Extend :: #css
/** EXAMPLE 1
---------------------------------------- **/
/* LESS */
.museo,h1,h2,h3 {
font-family:"Museo",sans-serif;
}
.nav {
/* some css */
&:extend(.museo);
@pietvanzoen
pietvanzoen / assume-unchanged.sh
Created July 9, 2013 22:09
Assume Unchanged :: Set a file as assume unchaged. Different to .gitignore. A file which is assumed unchanged can be in the repo but local changes aren't tracked. Handy for .htaccess or other config files. #git
#!/bin/bash
# from repo root foder
git update-index --assume-unchanged <file>
# or
git update-index --no-assume-unchanged <file>
@pietvanzoen
pietvanzoen / get_excerpt_stripped.php
Created July 9, 2013 20:35
Get_excerpt_stripped :: Record model method for Fuelcms modules to look for record excerpt, strip tags and set character. If no excerpt is found record content is used instead. #fuel
<?php
function get_excerpt_stripped($char_limit = NULL)
{
$this->_CI->load->helper('text');
$excerpt = (empty($this->excerpt)) ? $this->content : $this->excerpt;
// must strip tags to get accruate character count
$excerpt = strip_tags($excerpt);
if (!empty($char_limit))
{
@pietvanzoen
pietvanzoen / placeholders.php
Created July 8, 2013 17:11
Image Placeholders :: Helper functions for placeholder image services such as http://Placehold.it and http://Placekitten.com. #php
<?php
// http://placehold.it
function placeholdit($width = 100, $height = '', $text = '', $colors = '')
{
$dimentions = $width.( !empty($height) ? 'x'.$height : '');
$text = !empty($text) ? '&text='.urlencode($text) : '';
$colors = !empty($colors) ? explode(' ', $colors) : '';
$colors = !empty($colors) ? '/'.$colors[0].'/'.$colors[1] : '';
return 'http://placehold.it/'.$dimentions.$colors.$text;
}
@pietvanzoen
pietvanzoen / array_group.php
Created July 8, 2013 17:10
Array_group :: Divide an array into groups. #php
<?php
/**
* Returns an array of arrays.
*
* $array - an array to be divided
* $groups - number of groups to divide the array into
*/
function array_group($array, $groups)
{
@pietvanzoen
pietvanzoen / Numberstowords.php
Created July 8, 2013 17:05
Numbers to words :: A php library for converting numbers to words. Useful for bio copy that includes years since an event. Also useful for dynamically rendering grid systems that use words such as class="columns six". #php
<?php
// Goes in codeigniter/libraries
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Numbertowords {
function convert_number($number) {
if (($number < 0) || ($number > 999999999)) {