Skip to content

Instantly share code, notes, and snippets.

View Seldaek's full-sized avatar
😀
😀

Jordi Boggiano Seldaek

😀
😀
View GitHub Profile
@Seldaek
Seldaek / Of redirects
Created December 1, 2010 16:42
Of redirects
// format: html, POST /register, dev calls setRedirectRoute('welcome')
302 => /welcome, browser redirects, gets a new page
// format: json, POST /register, dev calls setRedirectRoute('welcome')
302 => /welcome, browser redirects, /welcome returns a 200 with {"some json shit"}, ajax callback gets json
// format: html, GET|POST /anypage, dev calls setRedirectUri('http://google.com/FUUUUU')
imports:
- file:config.yml
- file:somestuff.yml
services:
foo.controller:
class: Application\FooBundle\Controller\FooController
arguments:
- @router
- @request
class FooController
{
public function viewArticleAction($articleId)
{
$article = $this->articleRepository->getById($articleId);
$parameters = array(
'article' => $article,
);
// beginner
@Seldaek
Seldaek / results
Created December 15, 2010 17:20
forms
<?php
class Field {
protected static $options = array('a', 'b');
public static function getOptions() {
return static::$options;
}
public static $options2 = array('a', 'b');
}
@Seldaek
Seldaek / res
Created December 16, 2010 14:13
float 3.8314838409424
float 2.6161198616028
# /usr/bin/grep -rh '<service id=' --include='*.xml' src/Symfony/ | sed -re 's/ *<service id="([^"]+)".+/\1/g'
assetic.filter_manager
assetic.asset_manager
assetic.asset_factory
assetic.filter.cssrewrite
assetic.filter.less
assetic.filter.sass
assetic.filter.scss
assetic.filter.google_closure_compiler
@Seldaek
Seldaek / ContactControllerTest.php
Created May 25, 2011 13:48
Mailer service mocking for Symfony2
<?php
namespace Nelmio\HomeBundle\Tests\Controller;
use Nelmio\HomeBundle\Controller\ContactController;
use Liip\FunctionalTestBundle\Test\WebTestCase;
class ContactControllerTest extends WebTestCase
{
public function testEmail()

Annotation Change RFC

Most of those changes are ideas taken from the php-annotations lib (see its wiki too) by Rasmus Schultz.

Goals

I am not the author of that lib but have been discussing with him for a while and I am convinced that this could benefit Symfony users and PHP as a whole on the long run, if we standardized the annotations a bit more than what we have right now.

@Seldaek
Seldaek / Default.sublime-theme
Created January 13, 2012 09:40
Patch for Sublime Text 2 "highlight_modified_tabs" (missing in b2165)
/* Path: Packages/Theme - Default/Default.sublime-theme, add add the end before the ']' */
/* Patch for highlight_modified_tabs */
,{
"class": "tab_control", "attributes": ["dirty"],
"tint_modifier": [255, 255, 0, 230],
"layer0.texture": "Theme - Default/dark_tab_mask3.png",
"layer2.texture": "Theme - Default/dark_unselected_tab_bg2.png",
"layer2.opacity": 1.0
},
@Seldaek
Seldaek / sha1hmac.js
Created February 3, 2012 13:37
SHA1 + HMAC in JS
var Crypto = {};
Crypto.sha1_hmac = function (msg, key) {
"use strict";
var oKeyPad, iKeyPad, iPadRes, bytes, i, len;
if (key.length > 64) {
// keys longer than blocksize are shortened
key = Crypto.sha1(key, true);
}