The popular open-source contract for web designers and developers by Stuff & Nonsense
- Originally published: 23/12/2008
- Revised date: 15/12/2013
- Original post
<?php | |
function serve_file_resumable ($file, $contenttype = 'application/octet-stream') { | |
// Avoid sending unexpected errors to the client - we should be serving a file, | |
// we don't want to corrupt the data we send | |
@error_reporting(0); | |
// Make sure the files exists, otherwise we are wasting our time | |
if (!file_exists($file)) { |
Class: | |
CSSParser | |
Functions: | |
1 - minifier() | |
2 - beautifier() | |
3 - parser() | |
Input variables: | |
$this->input->post('content') OR $_POST['content'] |
jQuery.fn.center = function(parent) { | |
if (parent) { | |
parent = $(this).parent(); | |
} else { | |
parent = window; | |
} | |
$(this).css({ | |
"margin-top": ((($(parent).height() - $(this).outerHeight()) / 2) + $(parent).scrollTop() + "px"), | |
"margin-left": ((($(parent).width() - $(this).outerWidth()) / 2) + $(parent).scrollLeft() + "px") | |
}); |
window.GetQueryString = function(q) { | |
return (function(a) { | |
if (a == "") return {}; | |
var b = {}; | |
for (var i = 0; i < a.length; ++i) { | |
var p = a[i].split('='); | |
if (p.length != 2) continue; | |
b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " ")); | |
} | |
return b; |
<?php | |
class CI_Controller { | |
private static $instance; | |
public $data = array(); | |
/** | |
* Constructor | |
*/ |
AddType image/svg+xml svg svgz | |
AddEncoding gzip svgz | |
# Webfonts | |
AddType application/vnd.ms-fontobject eot | |
AddType application/x-font-ttf ttf ttc | |
AddType font/opentype otf | |
AddType application/x-font-woff woff | |
#Gzip |
<?php | |
/** | |
* A helper class for use in the Symfony Framework. Although there's no restriction to use it in | |
* any other framework or script. Just the autoloader needs to be setup before using this class. | |
* Sample code for initializing XenForo from your own script: | |
* | |
* <code> | |
* $startTime = microtime(true); | |
* $xenforoRoot = '/absolute/path/to/xenforo/root/directory'; |
<?php | |
require_once('./config.php'); | |
if ($_SERVER['REQUEST_METHOD'] == 'POST') { | |
$postdata = file_get_contents("php://input"); | |
$event = json_decode($postdata); | |
if ($event->type == 'invoice.payment_succeeded') { | |
$customer_id = $event->data->object->customer; | |
$customer = Stripe_Customer::retrieve($customer_id); | |
$invoice = Stripe_Invoice::retrieve($event->data->object->id); |
function string_limit_words($string, $word_limit) | |
{ | |
$words = explode(' ', $string, ($word_limit + 1)); | |
if(count($words) > $word_limit) | |
array_pop($words); | |
return implode(' ', $words); | |
} |