Archive for the ‘micro-howto’ Category

Let Google host the jQuery of your Trac!

März 13, 2010

Situation

If you work on big amounts of content collaboratively, you might end up with hosting your own Subversion of Git repository with a Trac in your storeroom. Although Trac uses AJAX to make the sourcecode browser quite fast once the page is loaded, the first pageload can be relatively slow. This is especially annoying, when one is using another machine to present something or to dig something up for printing.

Solution

As we all know, there are very good reasons to let Google host jQuery for you. Unfortunately, Trac doesn’t support loading jQuery from Google and there does not seem to be a plugin for Trac doing this, either. But as long as .htaccess-files are enabled or — even better — Apache’s config-files can be changed, one can set up a redirect pointing to ajax.googleapis.com.

Implementation

Add this line to your .htacces-file or to the apache configuration for every virtualhost with a Trac on it:

Redirect 301 <path to trac instance>chrome/common/js/jquery.js http://ajax.googleapis.com/ajax/libs/jquery/1.2/jquery.min.js

Where <path to trac instance> is the path to the trac instance relative to your domain. For example the mainpage of the wiki would be at http://example.com<path to trac instance>. Also note that requesting ajax.googleapis.com/[…]/1.2/jquery.min.js will give you the latest version of JQuery (1.2.x) that Google is hosting.

Performance

jQuery is currently about 30 KB in size. This means 56% of the pageweight in this case or — transferred over an ADSL connection with 1 MBit/s Upstream — over 1 second just for uploading jQuery. The whole page weighs in at about 53 KB distributed over 13 requests, which take about 2.7 seconds to load.

With the redirect applied, we see a „301 Moved Permanently“ in response to the request of the Trac’s jQuery and a new request to apis.google.com for jquery.min.js.

The first one only takes 12 ms in this case, because I am using the same internet connection as my server and all traffic only needs to travel trough my ISP’s routers and the response is very lightweight. With latencies typically not exceeding 60 ms, it should still be negligible when accessed via longer distance. The second attempt to get the jQuery takes only 78 ms of which the bigger part is due to network latency, because I redirected to the minified version of jQuery and google uploads at much faster rates than my server could via internet connection.

The page now loads in 1.7 seconds, almost 1 second or 36 % faster than before. The minified jQuery also causes the page to turn out about 13 KB or 24 % lighter.

Drawbacks

Because Trac’s jQuery still needs to be requested in order to issue a redirect to GoogleAPIs, there is a „useless“ request now, which could be prevented by Trac issuing the „right“ request in the first place. The penalty for it is only one round-trip time and should therefore be negligible, though.

Linux: SMB! Windows: Passwort?

Mai 31, 2007

Notiz an die Welt:
Die Lösung für die Passwortabfrage von Windows beim Verbinden auf eine smb-Freigabe von Linux:

Mit

sudo gedit /etc/samba/smb.conf

die samba-Konfiguration öffnen und die Zeile

;security = user

mit

security = share

ersetzen.

Danach mit

sudo /etc/init.d/samba restart

den samba-Deamon neustarten.

Erläuterung: „security = user“ scheint der Dafault-Wert zu sein, auch wenn es auskommentiert ist. Danach wird eine Authorisierung jedes Zugriffs auf die SMB-Freigaben durch Benutzername und Passwort des Hostrechners verlangt. Mit share, wird jedem erlaubt, die Freigaben zu sehen; in den Freigaben gelten die Rechte der Freigabe (Schreiben erlaubt?) und übergeordnet die Rechte der Ordner und Dateien.

Das Ausführen einzelner Befehle als Superuser vom Userspace aus mit „sudo“ ist nicht auf allen Systemen möglich. Dann muss man sich per

su root

als Root anmelden und kann per

su <eigenerBenutzerName>

wieder zum eigenen Benutzernamen zurückwechseln.

Mit

exit

kann man sich jeweils wieder abmelden.