Skip to content

Instantly share code, notes, and snippets.

View VaclavSir's full-sized avatar

Václav Šír VaclavSir

View GitHub Profile
<?php
abstract class BasePresenter extends Nette\Application\UI\Presenter
{
/**
* Path to theme templates.
*
* @var string
*/
#!/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) {
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 / text.md
Created December 3, 2016 09:26
Why Is Context-Aware Escaping a Leaky Abstraction

This is what the documentation says:

All is done automatically, consistently and correctly. You don't have to worry about security holes.

This is simply not true. What if you write this:

<a href="javascript:{$variable}">...</a>
<?php
abstract class Service
{
public function doSomething()
{
something();
$this->getLogger()->log('¯\_(ツ)_/¯');
}
@VaclavSir
VaclavSir / tmp.js
Created February 20, 2017 11:08
package.json: Find duplicities between devDependencies and dependencies
const packageJson = require('./package.json');
console.log(
Object.keys(packageJson.devDependencies).filter(packageName => packageJson.dependencies.hasOwnProperty(packageName))
);
@VaclavSir
VaclavSir / howto.md
Created March 16, 2017 09:19
How to read articles at martinfowler.com
  1. Open developer tools.
  2. Open Console.
  3. Execute $('#content')[0].style.margin='0 auto'
<div
data-embed-component="Hello"
data-embed-props='{"recipient": "World"}'
></div>

Keybase proof

I hereby claim:

  • I am vaclavsir on github.
  • I am vaclavsir (https://keybase.io/vaclavsir) on keybase.
  • I have a public key ASCkrZLdR5A2e52GUmPaRlhhiowbq7CzpM2qMue4_eg9wgo

To claim this, I am signing this object: