Skip to content

Instantly share code, notes, and snippets.

View VaclavSir's full-sized avatar

Václav Šír VaclavSir

View GitHub Profile
#!/bin/bash
for SUBDIR in $(ls -d -- */)
do
cd $SUBDIR
echo -ne "."
CMD="git log --all --grep='$1' 2>/dev/null"
RESULT=$(eval $CMD)
if [[ "$RESULT" != "" ]]
@VaclavSir
VaclavSir / dumpArray.php
Last active August 29, 2015 14:07
{{ dump_array({'foo': 'bar'}) }}
<?php
class AcmeDemoExtension extends \Twig_Extension {
public function getFunctions() {
return [
'dump_array' => new \Twig_Function_Method($this, 'dumpArray'),
];
}
public function dumpArray($arrayLikeObject, $indentLevel = 1) {
@VaclavSir
VaclavSir / preg_match.php
Last active October 6, 2015 06:38
PHP PCRE Tester
<?php
header('content-type: text/html; charset=utf-8');
$pattern = isset($_POST['pattern']) ? $_POST['pattern'] : '~^$~';
$subject = isset($_POST['subject']) ? $_POST['subject']: '';
?>
<h1>Preg_match tester</h1>
<form method="post">
<?php
/**
* Homepage presenter.
*/
class HomepagePresenter extends BasePresenter
{
private $a, $b, $c;
x@ACER2 /d (master)
$ /c/xampp/apache/bin/ab -n 1000 http://localhost:8080/
This is ApacheBench, Version 2.3 <$Revision: 1638069 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
@VaclavSir
VaclavSir / EntityFormBuilder.php
Created February 14, 2013 11:50
EntityFormBuilder
<?php
namespace VS\UI;
/**
* Simple form generator for plain old data objects.
*
* Creates a field for each scalar setter. Nothing more.
*
* @author Václav Šír
@VaclavSir
VaclavSir / dequote.php
Created May 7, 2013 06:40
Skript pro odstranění znaku "větší než" ze začátku řádků textu.
<?php
header('Content-type: text/html; charset=utf-8');
?>
<title>De-Quote</title>
<form method="post">
<textarea name="input" cols="80" rows="10"><?php echo htmlspecialchars(@$_POST['input']); ?></textarea><br>
<textarea name="output" cols="80" rows="10"><?php
if (isset($_POST['input'])) {
echo htmlspecialchars(
@VaclavSir
VaclavSir / Code Igniter
Created July 14, 2013 13:46
Hello World benchmark.
$ ab -n 2000 -c 10 http://localhost/framework-bench/helloworld/codeigniter/index.php/say/hello
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)
Completed 200 requests
Completed 400 requests
Completed 600 requests
Completed 800 requests
@VaclavSir
VaclavSir / optional-static-typing.latte
Last active December 19, 2015 23:08
Takový nápad...
{assertVariables
number => float,
message => string,
property => 'Hell\Model\Property',
identity => 'Nette\Security\IIdentity',
arrayOrIterator => 'Model\Item[]',
optionalParameter => 'SomeType|NULL'
anyType => mixed,
anyTypeOrNull => 'mixed|NULL',
anyArrayOrIterator => 'mixed[]'
<?php
namespace Articles;
use Nette\Application\UI\Presenter;
abstract class BasePresenter extends Presenter
{
public function formatTemplateFiles()