Skip to content

Instantly share code, notes, and snippets.

@321zeno
321zeno / php-explore-recursive.php
Last active December 17, 2015 04:28
A recursive PHP function that returns all the contents of a folder
function explore_recursive($path) {
$contents = glob($path .'*', GLOB_BRACE);
if (count($contents) > 0) {
foreach ($contents as $item) {
$file['name'] = basename($item);
// $file['location'] = $item;
$found = explore_recursive($item . '/');
if ($found) { $file['contents'] = $found; }
$branch[] = $file;
}
@321zeno
321zeno / gist:5495395
Created May 1, 2013 13:55
Basic gruntfile to use for Foundation projects
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
files: {
grunt: ['Gruntfile.js'],
js: ['javascripts/foundation/jquery.js',
'javascripts/**/*.js',
'javascripts/*.js',
@321zeno
321zeno / bottom-footer
Created April 25, 2013 12:26
push the footer to the bottom of the browser
@321zeno
321zeno / get-height-of-hidden-element-using-jquery
Last active December 16, 2015 13:29
Get height of hidden element using jQuery. Credits go to http://stackoverflow.com/users/414385/hitautodestruct
jQuery(function( $ ){
$.fn.actualHeight = function(){
// find the closest visible parent and get it's hidden children
var visibleParent = this.closest(':visible').children(),
thisHeight;
// set a temporary class on the hidden parent of the element
visibleParent.addClass('temp-show');
@321zeno
321zeno / read-image-file-for-output-as-base64-src
Last active October 6, 2015 22:07
read image file for output as base64 in img tag
public function getImage($name){
$folder_path = '/physical/path/to/file/';
$image_path = $folder_path.$name;
$filetype = pathinfo($image_path, PATHINFO_EXTENSION);
if (file_exists($image_path)) {
$file_data = file_get_contents($image_path);
return 'data:image/' . $filetype . ';base64,' . base64_encode($file_data);
}
}