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
@fprochazka
fprochazka / README.md
Last active November 23, 2018 17:57 — forked from StefanWallin/README.md
Configuring HTTPS + SPDY
@fprochazka
fprochazka / sqlSelect.php
Created November 30, 2015 22:16 — forked from xbukovsk-zz/sqlSelect.php
sql select
<? php
public static function getAllIndicatorValuesOverview($userId = null) {
$surveys = self::getConnection()->query(
'SELECT surveys.surveyId,surveys.year,user.organizationName
FROM surveys
LEFT JOIN user ON surveys.userId=user.userId'
)->fetchAll();
foreach($surveys as &$survey) {
@fprochazka
fprochazka / BaseModel.php
Created May 17, 2011 08:30
Psáno na aktuální Nette (master - 50c3c40)
<?php
abstract class BaseModel extends Nette\Object
{
/** @var NotORM */
protected $connection;
/**
<?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");