Skip to content

Instantly share code, notes, and snippets.

@frankdejonge
frankdejonge / gist:5c19f8e7ce329dbcc1ef
Created June 10, 2014 18:38
Flysystem and user downloads
<?php
$stream = $fs->readStream($file);
// send the right headers
header("Content-Type: " . $fs->getMimetype($file));
header("Content-Length: " . $fs->getSize($file));
header("Content-disposition: attachment; filename=\"" . basename($file) . "\"");
// dump the attachement and stop the script
@rintaun
rintaun / closurize.php
Created May 23, 2012 03:50
closurize(): Converts any valid PHP callable into a Closure. Requires PHP 5.4.0+.
<?php
/**
* Converts any valid PHP callable into a Closure. Requires PHP 5.4.0+.
*
* The ramifications of this are many, but basically it means that any function
* or method can be converted into a Closure, bound to another scope, and
* executed easily. Works properly even with private methods.
*
* - On success, returns a Closure corresponding to the provided callable.
* - If the parameter is not callable, issues an E_USER_WARNING and returns a
@trey
trey / rwd.css
Created January 26, 2012 20:14
Bootstrap's RWD breakpoints
/* http://twitter.github.com/bootstrap/scaffolding.html#responsive */
/* Landscape phones and down */
@media (max-width: 480px) { ... }
/* Landscape phone to portrait tablet */
@media (max-width: 768px) { ... }
/* Portrait tablet to landscape and desktop */
@media (min-width: 768px) and (max-width: 940px) { ... }
@croxton
croxton / gist:1505601
Created December 21, 2011 10:53
User friendly modal windows for touch devices using Colorbox and Modernizr
$(document).ready(function(){
// colorbox
if ($('#modal').length > 0) {
var modalConfig = {
inline : true,
href : "#modal",
opacity : .75,
onLoad:function(){
$('#modal').css('display','block');
@leevigraham
leevigraham / gist:1277716
Created October 11, 2011 09:43
Select top 5 entries grouped by category
SELECT *
FROM
(
SELECT cp.cat_id, cp.entry_id, ct.title,
@num := if(@group = cp.cat_id, @num + 1, 1) as row_number,
@group := cp.cat_id as group_key
FROM (SELECT @group:=null,@num:=0) n
CROSS JOIN exp_category_posts cp
LEFT JOIN exp_channel_titles ct on cp.entry_id = ct.entry_id
ORDER BY cp.cat_id
@manifestuk
manifestuk / wget.sh
Last active January 14, 2022 04:15
Gist for retrieving a full website using wget, because I always forget the options.
#
# Explanation:
# `--adjust-extension`
# Add `.html` file extension to any files of type `application/xhtml + xml` or `text/html`.
# Add `.css` file extension to any files of type `text/css`.
#
# `--convert-links`
# Convert full links to relative.
#
# `--level=inf` (`-l inf`)
@aarongustafson
aarongustafson / TinyMCE-config-HTML5.js
Created August 26, 2010 12:57
Working on a TinyMCE config that supports HTML5
// General
button_tile_map : true,
editor_selector : 'lg_mceEditor',
mode:'textareas',
theme : 'advanced',
// Cleanup/Output
apply_source_formatting : true,
convert_fonts_to_spans : true,
convert_newlines_to_brs : false,