Skip to content

Instantly share code, notes, and snippets.

View pietvanzoen's full-sized avatar

Piet van Zoen pietvanzoen

View GitHub Profile
@pietvanzoen
pietvanzoen / find_in_files_goto.py
Created May 20, 2014 22:46
Sublime Text Plugin - goto file/line from "Find Results" page by hitting ENTER. Based on this stack overflow answer: http://stackoverflow.com/a/16779397
# Add this file to your Sublime Packages/User folder
import sublime
import sublime_plugin
import re
import os
class FindInFilesGotoCommand(sublime_plugin.TextCommand):
def run(self, edit):
view = self.view
if view.name() == "Find Results":
@pietvanzoen
pietvanzoen / .bash_profile
Last active August 29, 2015 14:01
Using ENV variables
export WIBBLE=woo
@pietvanzoen
pietvanzoen / .ps1_functions
Created May 12, 2014 22:48
ps1 functions
#!/usr/bin/env bash
#
# Source this file in your ~/.bash_profile or interactive startup file.
# This is done like so:
#
# [[ -s "$HOME/.rvm/contrib/ps1_functions" ]] &&
# source "$HOME/.rvm/contrib/ps1_functions"
#
# Then in order to set your prompt you simply do the following for example
@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 / 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 / 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 / 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 / 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 / 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 / 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