Marcel Eichner // Ephigenia

  • Home
  • Illustration
  • Code
  • Kontakt

Aktuelle Projekte

Horrorblog.org
jQuery.slideShow
Franklin
code.marceleichner.de

This Blog-Website is built with Harrison!

Blogs & Freunde

Gimmixx
Martin Fleck
Torsten Bergler
Jens Franke
Robokid
Peter Kröner
Polycoder
Coding Horror
Lotterliebe
CodeBalancer
Pseudocoder
Migrador
Dachdeckermeister Peter Arold in Werda, Plauen, Hof und Umgebung La Petite Provence - Pension und Festsaal in Leisnig Piv-Berlin, Immobilienverwaltung Verwaltung Berlin blogoscoop

#507

04.07.2011 19:51
0 Kommentare
Share
  • php
  • apache
  • gd-lib
  • image
  • server
  • nginx
  • static
  • content
  • delivery
  • .htaccess
One problem when relaunching large projects with a ton of images is to re-create all the thumbnails that users have uploaded in the years. If you don’t use paperclip (ruby) or anything like it in PHP (is there any like it!?) where you can run run one command to re-create all the thumbnails in all specified sizes your can try to keep it flexible and create every image on demand.

Theory

The Webserver should serve the image if it exists. If the file does not exist, the request should be redirected to a PHP script that searches and creates the requested image file (in requested size) at exactly the location it was originally requested. The second request on the file will not be redirected to the PHP script and will server the image that now exists.

Practice

So the first thing to archive is to send the request of a not existing image to a PHP file. That’s easy if you’re familiar with all the nginx directives:

This rule can be combined with the anti-hotlinking rules for images with nginx I showed you last week.

After that we need to create a format that includes width and height of any requested image so that the
thumbnailer.php
knows which size the created image should have. A valid request for a resized file should always have all parameters (width, height) in it:
../img/public/9c4be029/438xauto/filename.jpg

This makes it easy to split up width, height with a regexp in
thumbnailer.php
. The following code is just an example. You’re surelly integrate the logic into your frameworks:

That’s it! After that you can request any image in any size on your webserver by only creating it once it’s requested.

There are some things you can add, like other parameters in the
$formatRegexp
string to add different resizing methods or even filters, or limitations on the
width
and
height
parameter.

Appendix: Apache

It’s almost the same thing with apache. Just add a few lines to your
.htaccess.
and all your image requests are redirected to the thumbnailer (or anything):

#483

25.08.2009 08:37
0 Kommentare
Share
  • code
  • php
  • programmieren
  • unit
  • tests
  • webdesign
  • mvc
  • framework
  • fun
  • joke
Bei PHPTerror findet man eine Lustige Variante von Web-Designten Unit Tests im PureMVC Framework. Anscheinend hat man auf der Seite des PureMVC Framworks einen Screenshot von Eclipse mit Photoshop gefaked.
Gefunden hab ich das ganze via PHPKitchen.

#462

18.06.2009 13:37
2 Kommentare
Share
  • code
  • php
  • osx
  • test
  • framework
  • terminal
  • shell
  • apache
  • unix
  • benchmark
  • performance
  • port
Wer sich mit Websiten beschäftigt die von mehr als 100 Besuchern am Tag besucht werden und nicht wirklich viel im Terminal macht freut sich eventuell über Apache Bench.

Das ist ein Programm das man auf OSX ganz einfach im Terminal laufen lassen kann um seinen Server mal so richtig schwitzen zu lassen.

Ein üblicher (und auch vergleichbarer) Aufruf ist der folgende:
ab -c 10 -t 60 http://localhost/myProject/
Was 60 Sekunden lang, immer 10 Requests auf die Seite abfeuert und einem danach folgende Ausgabe generiert:
Finished 3102 requests
Server Software:        Apache/2.0.59
Server Hostname:        localhost
Server Port:            80
Document Path:          /myProject/
Document Length:        2005 bytes
Concurrency Level:      10
Time taken for tests:   60.002 seconds
Complete requests:      3102
Failed requests:        303
   (Connect: 0, Receive: 0, Length: 303, Exceptions: 0)
Write errors:           0
Total transferred:      7530897 bytes
HTML transferred:       6211149 bytes
Requests per second:    51.70 [#/sec] (mean)
Time per request:       193.431 [ms] (mean)
Time per request:       19.343 [ms] (mean, across all concurrent requests)
Transfer rate:          122.57 [Kbytes/sec] received
Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   1.2      0      11
Processing:    30  186 663.6    157   20630
Waiting:        0  161  83.6    155     621
Total:         30  187 663.6    157   20631
Percentage of the requests served within a certain time (ms)
  50%    157
  66%    196
  75%    219
  80%    235
  90%    276
  95%    309
  98%    354
  99%    386
 100%  20631 (longest request)
In dieser Ausgabe kann man erkennen das das aktuelle Projekt so ca. 50 Leute gleichzeitig aushalten könnte. Im vergleich mit anderen Projekten kann man dann Rückschlüsse darauf ziehen wie gut man programmiert hat ;-)

Viele benutzen ab auch zum Vergleich von verschiedenen Frameworks die ich euch natürlich nicht vorenthalten möchte: Test1, Test2 und Test3.

ab kann man wie üblich über macports installieren (OSX Developer Tools müssen installiert sein):
sudo port install ab

#398

15.07.2008 22:24
0 Kommentare
Share
  • programmieren
  • tutorial
  • Web
  • fundstücke
  • framework
  • UI
  • Usability
  • Guide
  • Pattern
Hab ich glaube ich schon vor ein paar Wochen gefunden. In der Yahoo Design Pattern Library gibts Lösungen für oft gefragte Fragen wenn man Websites baut. Hauptsächlich für Communities. Altbewährtes und auch neue Sachen. Verständlich erklärt und schön sortiert.

#322

22.10.2006 01:43
4 Kommentare
Share
  • programmieren
  • berlin
  • Web
  • fundstücke
  • friedrichshain
  • photo
  • Feuer
OI, also das ist jetzt mal ne Real-Life Blog Geschichte.
Diesen Freitag erzählt mir Stephan (das ist mein WG Mitbewohner), dass er zum aller Ersten Mal einen Brand gemeldet hat. Ja - okay .. wo denn? Gegenüber!
Polizei und Feuerwehr gehen alles ganz locker an. Nach 2 Stunden war dann alles gelöscht und heute kann man schon gar nicht mehr sehen, dass da irgendwas passiert ist ...

Demnächst wird es auch nen grosses update geben. Seit über ein halbes Jahr bastel ich ja an einem Framework das auf meine Bedürfnisse zugeschnitten ist. Ein kleines Preview, oder Abfallprodukt ist der JS Calendar der schon im Blog von Jann erwähnt wurde

Ja und nich nur das ... demnächst mehr :)

Achja - und mein Pagerank ist auf 6 gestiegen ;-) Wie cool, ich würd ja werbung verkoofen (das geht wohl - man könnte über 400 Taken machen) - aber wer will das schon - sein Blog verschandeln mit irgendwelcher werbung!? (haha!)
marceleichner HTML5 Harrison Theme (Validate Source), © 2010 by Ephigenia M. Eichner, Impressum