Skip to content

Instantly share code, notes, and snippets.

View pietvanzoen's full-sized avatar

Piet van Zoen pietvanzoen

View GitHub Profile
@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 / 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 / fuel_migrate.sh
Created July 16, 2013 23:11
Fuel Migrate Command :: Terminal command to run fuel's migration command. More info here: http://docs.getfuelcms.com/general/migrations #fuel
# update fuel to latest migration
php index.php fuel/migrate/latest
@pietvanzoen
pietvanzoen / smooth_animation.css
Created July 19, 2013 22:12
Smooth Animations :: Force hardware acceleration on elements for better animation rendering. #css
.smooth_animation { -webkit-transform: translate3d(0,0,0); -moz-transform: translate3d(0,0,0); -ms-transform: translate3d(0,0,0); -o-transform: translate3d(0,0,0); transform: translate3d(0,0,0);}
@pietvanzoen
pietvanzoen / find_next_nav_item.php
Last active December 20, 2015 07:59
Find Next Array Item :: This function will find the next item in an array. Useful for dynamically generating a nav link for the next sibling page based on the $nav array. #fuel
<?php
function find_next($array, $search, $key, $loop = false)
{
// $array = array to search
// $search = string to search against, e.g. current uri_string()
// $key = array key to compare $search against
// $loop = if set to TRUE will return first value if it reaches the end of the array
@pietvanzoen
pietvanzoen / array_vals_sorter.php
Created August 29, 2013 19:09
Array Values Sorter :: Sort a multi dimensional array by values based on key. #php
<?php
function array_vals_sorter($array, $val_key, $order = 'asc') {
$sorter = array();
foreach ($array as $key => $row)
{
$sorter[$key] = $row[$val_key];
}
array_multisort($sorter, SORT_ASC, $array);
if ($order != 'asc') $array = array_reverse($array,TRUE);
@pietvanzoen
pietvanzoen / youtube_placeholder.js
Created September 6, 2013 22:45
Youtube Helper :: Helper function constructs a placeholder with a video still image from youtube. On click the placeholder is replaced by the youtube iframe. #php
$('.js-loadvideo').on('click', function(e){
e.preventDefault();
var $vid_id = $(this).attr('href').split('v=')[1];
var width = $(this).attr('data-width');
var height = $(this).attr('data-height');
var $video = '<iframe width="'+width+'" height="'+height+'" src="//www.youtube-nocookie.com/embed/'+ $vid_id +'?rel=0&showinfo=0&wmode=opaque&autoplay=1&modestbranding=1" frameborder="0" allowfullscreen></iframe>';
$(this).parent('.playoverlay').html($video);
return false;
});
@pietvanzoen
pietvanzoen / collapser.js
Created October 11, 2013 18:56
Accordion / Collapser Javascript
var $collapseToggle = $('.js_collapse_toggle'),
$collapseContent = $('.js_collapse_content');
$collapseContent.hide();
$collapseToggle.on('click', function(event) {
event.preventDefault();
$(this).toggleClass('collapse_active');
$($(this).attr('href')+'.js_collapse_content').stop(true, false).slideToggle();
});
@pietvanzoen
pietvanzoen / timecop.php
Last active December 25, 2015 07:49
Time Cop
// Returns TRUE when time() is greater than $datatime_string
function time_cop($datetime_string = '3/27/2013 6AM')
{
if (empty($datetime_string)) {
return FALSE;
}
return time() >= strtotime($datetime_string);
}
@pietvanzoen
pietvanzoen / circle.yml
Last active October 31, 2016 21:51
Using Yarn in CircleCI
dependencies:
pre:
- ./install-yarn.sh
cache_directories:
- ~/.yarn
- ~/.yarn-cache
override:
- yarn install