Skip to content

Instantly share code, notes, and snippets.

@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",
@nikic
nikic / guestbook.markdown
Created July 29, 2012 14:21
Quick doesn't have to mean dirty: Also applies to PHP!

Quick doesn't have to mean dirty: Also applies to PHP!

This is just a quick response to http://me.veekun.com/blog/2012/07/28/quick-doesnt-mean-dirty/. I won't bother to write a proper blog post for this, so a Gist will have to do ;)

When I read that article, one thing really striked me: If you want to quickly create a web app in PHP, you do exactly the same. I mean, exactly.

I never used the Silex microframework before, so I took this as a chance to see how it works. I'll just do the same as eevee did, only with a bit less commentary (this is a Gist after all!)

I hope that this will show you that PHP and Python are really similar to work with. Also this should show that just because you're using PHP, doesn't mean that you write dirty code. The similarity in the process and code is really incredible :)

@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;
@paranoiq
paranoiq / makeScrollable.js
Created August 24, 2011 16:18
Scrollable table body
/**
* Make table body scrollable, with the table header always visible.
* Table shrinks vertically to fit the browser viewport.
*
* requirements:
* - jQuery framework required (tested with 1.6.2)
* - header must be wrapped in <thead> element
*
* warnings:
* - table <caption> is not supported
@redhead
redhead / live-form-validation.js
Created August 26, 2010 21:16
Live Form Validation for Nette 2.0
/**
* Live Form Validation for Nette 2.0
*
* @author Radek Ježdík, MartyIX, David Grudl
*/
var LiveForm = {
options: {
controlErrorClass: 'form-control-error', // CSS class for an invalid control
errorMessageClass: 'form-error-message', // CSS class for an error message
@Majkl578
Majkl578 / BufferedTextResponse.php
Created October 22, 2012 20:09
BufferedTextResponse
<?php
namespace App\Application\Responses;
use Nette;
class BufferedTextResponse extends Nette\Application\Responses\TextResponse
{
public function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $httpResponse)
{
@juzna
juzna / retina.js
Created October 12, 2012 22:47
Retina images quality simulator
/**
* Simulates how normal low-res images look on retina display
*
* It resamples all images (within <img> tags) to a lower resolution.
* We should use half the resolution of original image to be precise (because retina has 2x the density of pixels),
* but that doesn't show * perceived* effect. It's enough to scale by 1.75.
*
* Also, it would be good to resample also images used in CSS background, but I dunno how to do it :/
*
* Requires jQuery
@fprochazka
fprochazka / Nette Extension
Created October 5, 2012 09:45
Velocity http://velocity.apache.org/engine/ template for PhpStorm & #nettefw
<?php
#set( $Class_prefix = ${NAME.substring(0, $NAME.indexOf('Extension'))} )
#set( $Extension_name = ${Class_prefix.toLowerCase()} )
#parse("PHP File Header.php")
namespace Kdyby\Extension\\${Class_prefix};
use Kdyby;
use Nette;
@dg
dg / gist:3644321
Created September 5, 2012 20:36
Texy on nette.org
<?php
/**
* Texy parser for wiki page.
*/
class Parser extends Nette\Object
{
/**
* @return void
@Mikulas
Mikulas / Google.php
Created August 21, 2012 13:21
GoogleAuth
<?php
use \Nette\Utils\Json;
/**
* Minimalistic Google OAuth2 connector
* @author Mikuláš Dítě
* @license BSD-3
*/
class Google extends Nette\Object