Skip to content

Instantly share code, notes, and snippets.

View hrach's full-sized avatar

Jan Škrášek hrach

View GitHub Profile
@hrach
hrach / preparation.md
Created January 4, 2016 23:07 — forked from wodCZ/force-http.tpl
vestacp cert letsencrypt
# init & renew
# replace ikw.cz with domain AND admin with vesta user
letsencrypt certonly \
--authenticator webroot \
--renew-by-default \
--agree-tos \
--webroot-path /home/admin/web/ikw.cz/public_html \
--domains ikw.cz,www.ikw.cz
@hrach
hrach / config.neon
Created December 8, 2015 08:42
neon + aws sdk + guzzle + kdyby curl ca bundle
- Aws\Sdk({
credentials: {
key: %s3.key%,
secret: %s3.secret%,
},
version: latest,
region: 'eu-west-1',
http_handler: @Aws\Handler\GuzzleV6\GuzzleHandler,
})
- Aws\Handler\GuzzleV6\GuzzleHandler
@hrach
hrach / BaseMapper.php
Last active August 29, 2015 14:21
Orm: select entity for update
<?php
use Nextras\Orm\Collection\ICollection;
use Nextras\Orm\Entity\IEntity;
use Nextras\Orm\Mapper\Dbal\Mapper;
use Nextras\Orm\Mapper\Dbal\DbalCollection;
class BaseMapper extends Mapper
{
@hrach
hrach / Article.php
Last active August 29, 2015 14:17 — forked from lichtner/Article.php
<?php
class Article extends Base {
function getUploadDir() {
# e.g. something like this
return "upload/articles/article-$this[id]";
}
}
@hrach
hrach / dynamicReturnTypeMeta.json
Last active April 11, 2017 10:35
Dynamic Return Type
{
"methodCalls": [
{
"class": "\\Mockery",
"method": "mock",
"position": 0,
"mask": "%s|\\Mockery\\MockInterface"
},
{
"class": "\\Nette\\DI\\Container",
@hrach
hrach / debian-7.7-results.txt
Last active August 29, 2015 14:12
Nextras\ORM: optimizations between v1.0.0-beta4 and master (7eb46762364072badb0d81dff82ad1f1d88f4ded)
AFTER:
-----
NDB 2.0 | Time: 5.079 s | Memory: 16.7 MB | PHP: 5.5.20-1~dotdeb.1 | Nette: 2.0.18
NDB 2.1 | Time: 0.984 s | Memory: 16.5 MB | PHP: 5.5.20-1~dotdeb.1 | Nette: 2.1.8
NDB 2.2 | Time: 1.049 s | Memory: 16.1 MB | PHP: 5.5.20-1~dotdeb.1 | Nette: 2.2.x
Nextras\Orm | Time: 0.800 s | Memory: 21.1 MB | PHP: 5.5.20-1~dotdeb.1
NotOrm | Time: 1.418 s | Memory: 7.2 MB | PHP: 5.5.20-1~dotdeb.1
LeanMapper | Time: 0.754 s | Memory: 15.6 MB | PHP: 5.5.20-1~dotdeb.1
Doctrine2 | Time: 52.118 s | Memory: 28.0 MB | PHP: 5.5.20-1~dotdeb.1 | Doctrine: 2.4.2
@hrach
hrach / test1.php
Last active August 29, 2015 14:03
test inheritance php
<?php
class foo
{
private $name;
public function greet2()
{
$this->greet('jan');
echo $this->name;
}
@hrach
hrach / solution.sql
Last active August 29, 2015 14:02
@hrachcz: #anketa. model: author 1:n books m:n tags. zajima me sql, ktere vybere autory, kteri nenapsali zadnou knihu o PHP (tj. bez tagu PHP).
select *
from authors
where not exists (
select *
from books
left join books_x_tags on (books_x_tags.book_id = books.id)
left join tags on (tags.id = books_x_tags.tag_id)
where
books.author_id = authors.id
and tags.name = 'PHP'
@hrach
hrach / nginx.conf
Created June 9, 2014 20:50
nginx + Nette framework rewrite
server {
listen 80;
server_name example.com;
root d:/webs/example.com/www;
index index.php index.html;
try_files $uri $uri/ /index.php?$args;
location ~ \.phpt?$ {
try_files $uri @missing;

Keybase proof

I hereby claim:

  • I am hrach on github.
  • I am hrach (https://keybase.io/hrach) on keybase.
  • I have a public key whose fingerprint is 8365 AC07 6C01 7E90 E779 186B B1A1 EFCC E8D1 E45C

To claim this, I am signing this object: