Skip to content

Instantly share code, notes, and snippets.

View fprochazka's full-sized avatar
🏠
Working from home

Filip Procházka fprochazka

🏠
Working from home
View GitHub Profile
{
"methodCalls": [
{
"class": "\\Mockery",
"method": "mock",
"position": 0,
"mask": "%s|\\Mockery\\MockInterface"
},
{
"class": "\\Nette\\DI\\Container",
@fprochazka
fprochazka / README.md
Last active November 23, 2018 17:57 — forked from StefanWallin/README.md
Configuring HTTPS + SPDY
<?php
require __DIR__ . '/../vendor/autoload.php';
$configurator = new Nette\Configurator;
$configurator->setDebugMode(TRUE); // debug mode MUST NOT be enabled on production server
$configurator->enableDebugger(__DIR__ . '/../log');
$configurator->setTempDirectory(__DIR__ . '/../temp');
<?php
// .phpstorm.meta.php
namespace NEON_META { // we want to avoid the pollution
$CONFIG_KEYS = [
'dibi' => [ 'host' => '', 'dbname' => '', 'user' => '', 'password' => '' ], // unobstrusive static definition
'nette' => \Nette\Config\Extensions\NetteExtension::$defaults, // no problem the property is actually not static
'nette' => [
'session' => [
/**
* Acquires an indexing lock if possible.
*
* @return boolean
*/
private function acquireLock()
{
$redis = $this->getRedis();
if ($redis->setNX(self::LOCK_KEY, $this->getTimeout())) {
@fprochazka
fprochazka / gist:3644347
Created September 5, 2012 20:37 — forked from dg/gist:3644321
Texy on nette.org
<?php
/**
* Texy parser for wiki page.
*/
class Parser extends Nette\Object
{
/**
* @return void
@fprochazka
fprochazka / gist:3207083
Created July 30, 2012 14:02
Get random table row with doctrine DQL in Symfony2
<?php
//
// Theory (for MySQL): http://jan.kneschke.de/projects/mysql/order-by-rand/
//
class QuestionRepository extends EntityRepository
{
public function findOneRandom()
{
$em = $this->getEntityManager();
@fprochazka
fprochazka / play.js
Created January 24, 2012 17:28 — forked from juzna/01-choose.png
GitHub Play
(function() {
var commits = [], repo = document.location.href.match(/github\.com\/([^\/]+\/[^\/]+)\//)[1];
// Play for all commits
$('.commit-group .commit-links')
.append($('<a href="#" class="browse-button github-play-select">Play</a>'));
// show next commit
var nextCommit = function () {
$('.site .container').load(commits.shift() + ' #.site .container', function () {
@fprochazka
fprochazka / Strings
Created October 6, 2011 14:57 — forked from Majkl578/gist:1267600
Strings::blend
<?php
/**
* @param string $a
* @param string $b
* @return string
*/
public static function blend($a, $b)
{
$pos = strrpos($a, $b);
@fprochazka
fprochazka / HomepagePresenter.php
Created June 2, 2011 05:55 — forked from vaclavbohac/HomepagePresenter.php
Mobile device detection in Nette
<?php
class HomepagePresenter extends BasePresenter
{
public function actionDefault()
{
$detector = $this->context->detector;
if ($detector->isMobile()) {
$this->redirect("mobile");