Skip to content

Instantly share code, notes, and snippets.

@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
@beberlei
beberlei / TxController.php
Created August 6, 2012 09:44
Transactional Service Proxy
<?php
class TxController extends Controller
{
public function context($id)
{
return new TxProxy($this->get($id), $this->get('doctrine.orm.default_entity_manager'));
}
}
@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 :)

I am thrilled to announce the arrival of a new stable version of Node.js.

Compared with the v0.6 releases of Node, this release brings significant improvements in many key performance metrics, as well as cleanup in several core APIs, and the addition of new debugging features.

tl;dr

@Janiczek
Janiczek / genetics.coffee
Created April 12, 2012 13:43
Evoluční algoritmus
#======================================================================#
# Biologicke algoritmy (2) - Evoluční algoritmy #
# http://www.root.cz/clanky/biologicke-algoritmy-2-evolucni-algoritmy/ #
#======================================================================#
#
# hledame kruznice, ktere nejvic sedi na danou mnozinu bodu
#
# ----------------------------------------------------------
#
# jedinec = trojice kruznic
@lancejpollard
lancejpollard / less2stylus.coffee
Created February 9, 2012 19:33
Convert LESS to Stylus for Twitter Bootstrap
# Quick hack of regular expressions to convert twitter bootstrap from LESS to Stylus
less2stylus = (string) ->
string = string
.replace(/^(\ *)(.+)\ +\{\ *\n?\ */mg, "$1$2\n$1 ") # remove opening brackets
.replace(/^(\ *)([^\ \n]+)\ +\{\ *\n?\ */mg, "$1$2\n$1 ") # remove opening brackets
.replace(/\ *\{\ *\n*/g, "\n") # remove opening brackets again (some random cases I'm too lazy to think through)
.replace(/\ *\}\ *\n*/g, "\n") # remove closing brackets
.replace(/\;\ *?$/gm, "") # remove semicolons
.replace(/@(\w+):(\ *)\ /g, (_, $1, $2) -> # replace @variable: with $variable =
"$#{$1}#{$2} = "
@juzna
juzna / EntityForm.php
Created December 27, 2011 14:14
Data binding in Nette
<?php
class EntityForm extends Form {
/**
* Bind entity to this form and set default values from it
*
* @param \Nella\Models\IEntity $entity
* @throws \Nette\InvalidStateException
*/
public function bind(\Nella\Models\IEntity $entity)
(function($) {
// Used by dateinput
$.expr = {':': {}};
// Used by bootstrap
$.support = {};
// Used by dateinput
$.fn.clone = function(){
var ret = $();
@pepakriz
pepakriz / ConfigBuilder.php
Created November 1, 2011 16:02
ConfigBuilder for Nette Framework
<?php
/**
* Venne:CMS (version 2.0-dev released on $WCDATE$)
*
* Copyright (c) 2011 Josef Kříž pepakriz@gmail.com
*
* For the full copyright and license information, please view
* the file license.txt that was distributed with this source code.
*/
/**
* Beta
*
* Sibling of netteForms.js "rewritten to jQuery"
* @author Pavel Kučera
* @author David Grudl author of netteForms.js, of the idea and the one who I copied from
*
* Disclaimer: I'm not a javascript programmer, actually I hate javascript, so consider that please if you want to complain about quality of this utility.
*
* Dependencies