Skip to content

Instantly share code, notes, and snippets.

View paulrichards19's full-sized avatar

Paul Richards paulrichards19

View GitHub Profile
#!/bin/bash
#
# Watch current directory (recursively) for file changes, and execute
# a command when a file or directory is created, modified or deleted.
#
# Written by: Senko Rasic <senko.rasic@dobarkod.hr>
#
# Requires Linux, bash and inotifywait (from inotify-tools package).
#
# To avoid executing the command multiple times when a sequence of
@paulrichards19
paulrichards19 / gist:5063338
Created March 1, 2013 08:52
Set a variable to Zend Layout
<?php
$this->_helper->layout()->getView()->activepage = 'userlist';
@paulrichards19
paulrichards19 / gist:5063330
Last active December 14, 2015 09:09
Zend Framework - get a bootstap'ed item from the controller
<?php
$bootstrap = $this->getInvokeArg('bootstrap');
$log = $bootstrap->getResource('Log');
@paulrichards19
paulrichards19 / basic_auth.php
Created March 5, 2012 16:06
Basic Auth for PHP
<?php
// Realm
$realm = 'Restricted area ';
//Passwords
$users = array('admin' => 'password');
if (empty($_SERVER['PHP_AUTH_DIGEST'])) {
send_auth_headers( $realm );
// if someone hits the cancel button
@paulrichards19
paulrichards19 / gist:1688255
Created January 27, 2012 10:50
Disable Layout and Views in Zend Framework from a controller
<?php
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
@paulrichards19
paulrichards19 / gist:1599650
Created January 12, 2012 09:57
Javascript function to return the get parameters of a page
function getUrlVars()
{
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
item = { key: hash[0], value: hash[1] };
vars.push(item);
}
@paulrichards19
paulrichards19 / gist:1582553
Created January 9, 2012 11:23
Jquery plugin to ensure CORS will work on IE8 ( but will never work on IE7 )
(function( jQuery ) {
// Create the request object
// (This is still attached to ajaxSettings for backward compatibility)
jQuery.ajaxSettings.xdr = function() {
return (window.XDomainRequest ? new window.XDomainRequest() : null);
};
// Determine support properties
(function( xdr ) {
jQuery.extend( jQuery.support, { iecors: !!xdr });
@paulrichards19
paulrichards19 / subdomain.js
Created January 9, 2012 11:02 — forked from benvinegar/subdomain.js
Subdomain tunneling with jQuery and document.domain
/**
* Replace $.ajax on your subdomain with a copy taken
* from your base domain. All jQuery AJAX actions go
* through $.ajax (i.e. $.get, $.post), so it's all good.
*/
(function() {
var iframe,
onload,
queue = [];