Skip to content

Instantly share code, notes, and snippets.

View staabm's full-sized avatar
👋

Markus Staab staabm

👋
View GitHub Profile
@staabm
staabm / parser.php
Created July 18, 2012 08:31
Email conversation parser
<?php
preg_match_all("/^((?:\h*>+\h*)*)(.*)$/m", $s, $matches, PREG_SET_ORDER);
$indent = 0;
$s = '';
foreach ($matches as $match) {
$newIndent = substr_count($match[1], '>');
$diff = $newIndent - $indent;
/*
@staabm
staabm / base64decode.php
Created September 26, 2012 06:59
native stream filter conversion
<?php
function convert($size) {
$unit = array('b', 'kb', 'mb', 'gb', 'tb', 'pb');
return @round($size / pow(1024, ($i = floor(log($size, 1024)))), 2) . ' ' . $unit[$i];
}
function mem() {
return convert(memory_get_usage(true));
}
@staabm
staabm / mysql profiling notes.md
Last active December 12, 2015 01:18
mysql native profiling
SELECT CONCAT(table_schema, '.', table_name),
ROUND(table_rows / 1000000, 2) rowsInMega,
ROUND(data_length / ( 1024 * 1024 * 1024 ), 2) dataInGiga,
ROUND(index_length / ( 1024 * 1024 * 1024 ), 2) idxInGiga,
ROUND(( data_length + index_length ) / ( 1024 * 1024 * 1024 ), 2) totalSizeInGiga,
ROUND(index_length / data_length, 2) idxfrac
FROM information_schema.TABLES
ORDER BY data_length + index_length DESC
LIMIT 30;
@staabm
staabm / stylesheet.css
Last active December 15, 2015 11:48
atmosphere javadoc css
/* Javadoc style sheet, based on the default stylesheet */
/* Define colors, fonts and other style attributes here to override the defaults */
/* XXX Custom Additons */
dl dd p {
margin-top: 15px;
margin-bottom: 15px;
}
/* XXX /Custom Additons */
@staabm
staabm / baseclass.php
Last active December 17, 2015 01:09
watson
<?php
// baseclass
public abstract class AbstractWatsonSearcher {
/**
* @return string[] an array of supported keywords
* /
abstract function keywords();
/**
@staabm
staabm / strip.sh
Last active December 25, 2015 18:59
strip php closing tags from all files within a directory.
#!/bin/bash
# vim:ft=sh:ts=3:sts=3:sw=3:et:
# origin taken from http://bryan.ravensight.org/2010/07/remove-php-closing-tag/
# with some custom changes.
###
# Strips the closing php tag `?>` and any following blank lines from the
# end of any PHP file in the current working directory and sub-directories. Files
# with non-whitespace characters following the closing tag will not be affected.
@staabm
staabm / gist:7240968
Created October 30, 2013 21:50
Hhvm analyze
$ find . -name '*.php' > /tmp/files.list
$ hvm --hphp -t analyze --input-list /tmp/files.list
(snip...)
$ ls -1 /tmp/hphp_xegBug/
@staabm
staabm / callgraph.svg
Created December 30, 2013 12:58
callgraph svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@staabm
staabm / composer.json
Created January 16, 2014 09:11
composer.json for phpunit 3.6 on Ubuntu 10 (requred, because of php 5.2)
{
"require": {
"php": ">=5.2.0",
"staabm/thincache": "0.*",
"rmccue/requests": "1.6.*",
"ircmaxell/password-compat": "1.0.*",
"staabm/xhprof.io": "dev-master"
},
"require-dev": {
"lstrojny/phpunit-clever-and-smart": "dev-master",