Skip to content

Instantly share code, notes, and snippets.

View michal's full-sized avatar

Michał Maliszewski michal

View GitHub Profile
@michal
michal / gist:738925
Created December 13, 2010 11:38
php is ajax request?
function isAjax() {
return (isset($_SERVER['HTTP_X_REQUESTED_WITH'])
&& $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') ? true : false;
}
runCallbacks = function (type, property, key, value) {
var i, j, callbacks = propertyMap[property][type];
for (i = 0, j = callbacks.length; i < j; i += 1) {
(function(callbacks, i, key, value) {
window.setTimeout(function () {
callbacks[i](key, value);
}, 0);
})(callbacks, i, key, value);
}
},
<?php
class Endo_Controller_Plugin_Modular extends Zend_Controller_Plugin_Abstract
{
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$module = $request->getModuleName();
$module = empty($module) ? 'frontend' : $request->getModuleName();
$namespace = Zend_Auth_Storage_Session::NAMESPACE_DEFAULT;
$member = Zend_Auth_Storage_Session::MEMBER_DEFAULT
. '-' . $module;
<?php
$dump = '/...';
$date = date('Ymd');
$version = 1;
foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dump)) as $file) {
if (preg_match('/^'.$date.'/', $file->getFilename())) {
$version++;
}
}
$version = substr('000', 0, -(strlen($version))) . $version;
while [ 1 ]; do ps aux | grep --exclude=grep php-cgi | grep -v grep | awk 'BEGIN{s=0;}{s=s+$6;}END{print s/1024.2;}'; sleep 2; done