[Symfony 2] Security Bundle: Set User Locale on Form Login

[UPDATE]
A recent update to this article may be found here: https://nerdpress.org/symfony-2-set-default-locale-on-form-login-2/

Das Security Bundle ist ein wenig magisch. Da muss man eine HTML-Form definieren, der Rest wird irgendwie konfiguriert (Namen der Post-Parameter wie “_username”, “_password” etc., den Redirect zum Referrer, Remember-Me Funktion und so weiter, das alles wird von der Firewall intern geregelt. Man muss nur eine Login-Route definieren, einen Stub-Controller + Action-Callable (der aber nie ausgeführt wird, weil die Firefall sich davorhängt), fertig.

Das ist angenehm einfach, solange man keine Fragen stellt. Aber wie führe ich zusätzliche Aktionen direkt nach erfolgtem Login aus, ohne Einfuss auf den Code des Security Bundles zu haben?

Continue reading “[Symfony 2] Security Bundle: Set User Locale on Form Login”

Synchronous http request in node.js, that you dont want, probably

Achtung dummy code!

…and so it goes Asynchronous:

 for(var i = 0; i < loop.length; i++)
 {
	var proxy = http.createClient(PORT,SERVER);
	var request = proxy.request('GET', url, 
        {
            "host": SERVER
        });
	request.end();
	...
 }

fire, fire, fire, fire

… and so it dont, Synchronous then:

var proxy = http.createClient(PORT,SERVER);
 
for(var i = 0; i < loop.length; i++)
 {
	var request = proxy.request('GET', url, 
        {
            "host": SERVER
        });
	request.end();
	...
 }

point – shoot, point – shoot, point – shoot

well i didnt know that :)

Lighttpd, Plesk und PHP

Will man auf seinem Server(debian) Lighttpd paralell zu Plesk’s Apache zum laufen kriegen sollte man auf jeden fall PHP als FPM laufen lassen.
Das kommt sich nicht mit dem von Plesk und Apache regierten PHPs in die Quere und ist sowieso schneller und kann auch die Prozesse killen und neuladen.
Falls man mal was in der ini ändern will.

FPM installieren geht so, wie er es dort beschreibt:

Allerdings in der conf den Port nicht als String, sondern numeric:

server.modules   += ( "mod_fastcgi" )

## Start an FastCGI server for php (needs the php5-cgi package)
fastcgi.server    = ( ".php" =>
        (
"localhost" =>
        (
                "host" => "127.0.0.1",
                "port" => 9000
        ))
)

Bleibt noch das Problem mit dem APC Konflikt, falls da jemand eine Lösung weiß, nur her damit.

Man, das war ein kampf ;)
Mal sehen wie lang das hält…

jQuery .scrollToViewPort()

yesterday i found this very useful jQuery-script on github:

https://gist.github.com/853841

jQuery.fn.scrollToViewPort = function(animTimeInterval) {
  animTimeInterval = (typeof animTimeInterval == "undefined")?"slow":animTimeInterval;
  return this.each(function(){
    $('html,body').animate({scrollTop: $(this).offset().top},animTimeInterval);
  });
}

it moves the users’ viewport to show the element that it has been called on.

I modified it somehow so that it will check now if the element is already in the viewport.
So we can avoid auto-scrolling in that case.
A offset Parameter has also been added in case we need some margin.

https://gist.github.com/1018842

jQuery.fn.scrollToViewPort = function(options) {
  var animTimeInterval = (typeof options.interval == "undefined")?"slow":animTimeInterval;
  return this.each(function(){
    var offSet = (typeof options.offset == "undefined")? $(this).offset().top : options.offset;
    if( $(this).offset().top <= $(window).scrollTop() || ( $(this).offset().top + $(this).height() ) >= ( $(window).scrollTop() + $(window).height() ) ){
      $('html,body').animate( { scrollTop: offSet }, animTimeInterval );
    }
  });
}

usage:

 $(this).scrollToViewPort( { offset : ( ( $(this).offset().top + my_custom_offset ) - $(window).height() ) } );

SilverStripe Image Gallery installation

Theres a lot of old, deprecated and now wrong installation guides for the SilverStripe Image Gallery Module on the web that will lead you to where you dont want to. Dont trust them!

Unclecheese made some changes to the module dependencies and also moved to git, some time ago. He now uses the new Uploadify module instead of the SwfFileUpload module.

So a working installation of the image-gallery for git-people is to:

Continue reading “SilverStripe Image Gallery installation”