This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/opt/local/bin/php | |
<?php | |
/* | |
1) replace the shebang (first line) with the path to your php binary | |
(probably something like /usr/bin/php) | |
2) move the file to /usr/local/bin/datauri.php | |
(this should be in your PATH) | |
3) chmod ugo+rx /usr/local/bin/datauri.php | |
(make the script executable for everyone) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# configure stuff | |
width=640 | |
height=320 | |
size=$width"x"$height | |
# show help | |
if [[ "$1" == "" || "$1" == "-h" || "$1" == "--help" ]]; then | |
echo "USAGE: "; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare( encoding = 'UTF-8' ); | |
namespace shurlook\net | |
{ | |
class URL | |
{ | |
const PROTOCOL = 'scheme'; | |
const HOST = 'host'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RewriteEngine on | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_URI} !^/excluded-directories-like-css-or-js/ | |
RewriteRule ^(.*)$ not-found.php [QSA,L] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (extension_loaded('xdebug')) { | |
echo "WARNING: xdebug is enabled\n"; | |
} | |
function _count() | |
{ | |
$array = array(1, 5, 8, 'Michael', 5, 4, 9, 'Martin', 18, 12, 'Michael', 4, 12); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$string = '{foreach $element->children as $c} | |
{-if $c->max_count == 1} | |
{-$c->getClassName()} {$c->getMemberVariableName()-}; | |
{-else-} | |
{$c->getClassName()} {$c->getMemberVariableName()}; | |
std::vector<{$c->getClassName()}> {$c->getMemberVariableName()}s; | |
{-/if-} | |
{-/foreach} hello |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
This hack is supposed to help using regular file-based templates without writing to compiled_c directory. This should only be used in installers or similar! | |
*/ | |
// load smarty | |
require_once '…/Smarty.class.php'; | |
// extend regular File Resource to suggest a source must be recompiled on every invocation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// tested on PHP 5.3 / Smarty 3.1 | |
// Plugin wasn't exactly developed for convenience, more a proof of concept thingy | |
// This code is provided under the MIT License - http://www.opensource.org/licenses/mit-license.php | |
// define the (absolute) path to document_root | |
define('BOOSTER_HTDOCS', realpath(__DIR__ . '/../../htdocs/') . '/'); | |
require_once BOOSTER_HTDOCS . 'booster/booster_inc.php'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// http://www.phpgangsta.de/algorithmus-gesucht-strings-in-string-suchen | |
function _outputStringPositionsFunction($longText, $searchTexts) { | |
// of 10000 tokens only 9143 are unique | |
$tokens = array_unique($searchTexts); | |
$positions = array(); | |
// make similar tokens appear in order |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// port of https://gist.github.com/909692 | |
// TODO: check char-map of https://github.com/jbroadway/urlify/blob/master/URLify.php for characters we've missed | |
// TODO: check performance against http://stackoverflow.com/questions/1946040/using-javascript-to-normalize-url-rewriting-strings-entered-by-users | |
var Urlifyer = function(options) { | |
var _key, _code, i, _source, _sources; | |
// Allow instantiation without the 'new' keyword | |
if (!(this instanceof Urlifyer)) { | |
return new Urlifyer(options); |