Skip to content

Instantly share code, notes, and snippets.

View michal's full-sized avatar

Michał Maliszewski michal

View GitHub Profile
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
<?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;
<?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;
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);
}
},
@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;
}
<?php
class Endo_Filter_Typografic implements Zend_Filter_Interface
{
public function filter($value)
{
$value = preg_replace('/(\s([\w]{1})\s)/u', ' ${2}&nbsp;', $value);
return $value;
}
}
@michal
michal / css-group.tmbundle
Created March 6, 2011 18:53
folding group syntax and snippet
foldingStartMarker = '/\*\*(?!\*)|\{\s*($|/\*(?!.*?\*/.*\S))|\/\*\s*@group\s*.*\s*\*\/';
foldingStopMarker = '(?<!\*)\*\*/|^\s*\}|\/*\s*@end\s*.*\s*\*\/';
/* @group ${1:name} */
${0:$TM_SELECTED_TEXT}
/* @end ${1:name} */
@michal
michal / .bash_profile
Created July 7, 2011 19:37
My bash profile
PATH=/usr/local/bin:/usr/local/sbin:$PATH
source `brew --prefix`/Library/Contributions/brew_bash_completion.sh
export EDITOR=/usr/local/bin/mate
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
export CLICOLOR=1
@michal
michal / css.tmlanguage
Created August 1, 2011 12:58
textmate css language
{ scopeName = 'source.css';
comment = '';
fileTypes = ( 'css', 'css.erb' );
foldingStartMarker = '/\*\*(?!\*)|\{\s*($|/\*(?!.*?\*/.*\S))|\/\*\s*@group\s*.*\s*\*\/';
foldingStopMarker = '(?<!\*)\*\*/|^\s*\}|\/*\s*@end\s*.*\s*\*\/';
patterns = (
{ include = '#comment-block'; },
{ include = '#selector'; },
{ name = 'meta.at-rule.charset.css';
begin = '\s*((@)charset\b)\s*';
@michal
michal / group.tmsnippet
Created August 1, 2011 13:00
textmate css group snippet
/* @group ${1:name} */
${0:$TM_SELECTED_TEXT}
/* @end ${1:name} */