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):

#506

28.06.2011 11:16
0 Kommentare
Share
  • config
  • facebook
  • server
  • nginx
  • hotlinking
  • referer
  • block
  • how-to
Almost two weeks ago I moved my personal blog-project horrorblog.org from a domainfactory managed hosting server to a JiffyBox which is a scalable cloud server solution also by domainfactory. I won’t talk about the setup for now (but later this or next week) but I want to show you an example for a nginx config file that prevents your images from beeing hotlinked but still enabling google and facebook.

Prevent hotlinking in nginx is really simple and some rules and examples can be found via google:
# apply this rule on any location that’s an image using Regexp
location ~* \.(png|gif|jpg|jpeg|swf|ico)(\?[0-9]+)?$ {
  # block empty blocked or whiteliste referers
  valid_referers none blocked horrorblog.org www.horrorblog.org;
  if ($invalid_referer) {
    return 403;
  }
}

This works fine, unless you won’t have your images displayed on facebook when anybody likes your stuff with the facebook share button (og:image) or in google image search. The solution that enables facebook to grab the images from your host is by adding
~\.facebook\.
and
~\.fbcdn\.
to the whitelist of hosts:
# apply this rule on any location that’s an image using Regexp
location ~* \.(png|gif|jpg|jpeg|swf|ico)(\?[0-9]+)?$ {
  # block empty blocked or whiteliste referers
  valid_referers none blocked horrorblog.org www.horrorblog.org ~\.google\. ~\.yahoo\. ~\.bing\. ~\.facebook\. ~\.fbcdn\.;
  if ($invalid_referer) {
    return 403;
  }
}

#496

27.05.2010 03:49
0 Kommentare
Share
  • osx
  • usa
  • software
  • windows
  • game
  • Case
  • Sensitive
  • Steam
  • Valve
  • Spiele
  • Plattform
Es ist schon erstaunlich und lobenswert, dass VALVE nach Jahren der Abstinenz auf -nix-basierten Systemen endlich seine STEAM-Plattform auch für Macs anbietet. Dumm nur wenn man, wie ich, den kram runterlädt, starten will, aber nur mit dieser lapidaren Meldung abgespeist wird die ihr oben sehen könnt. Anscheinend kann man STEAM nur benutzen, wenn man seine Festplatte richtig formatiert hat.

Nach dem ich Google befragt habe, finde ich ein paar Anleitungen wie man STEAM auch auf einem Case-Insensitiven System zum laufen bekommen kann. Ich bin aber gar nicht davon angetan, meine volle Fesplatte noch weniger, dass ich eine weitere Partition nur für STEAM, in case-sensitive anlegen soll! Das kann ja eigentlich auch nicht hinhauen. Ich bin selbst Programmierer und bin der Meinung, dass die Jungs bei VALVE mal ihren Code aufräumen müssen, nicht ich meine Platte umgestalten!

#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

#457

05.06.2009 13:49
0 Kommentare
Share
  • code
  • osx
  • App
  • terminal
  • tool
  • script
  • scripting
  • apple
iTerm ist eine willkommene Alternative zu der nativen Terminal App für OSX. Jetzt kann man die auch mit AppleScript verwursten.
Wenn man es Leid ist immer wieder die selben Terminal Fenster aufzumachen um Apache-Logs zu lesen oder die Datenbank zu überwachen sollte man überlegen ob das nicht noch besser geht. Klaro geht das besser! Mit Apple-Script!
tell application "iTerm"
  activate
 
  -- create server log terminal
  make new terminal
  tell the last terminal
    activate current session
    launch session "Default Session"
    tell the last session
      write text "clear;"
      write text "tail -f /Applications/MAMP/logs/apache_access.log"
      set background color to {15000, 200, 200}
    end tell
  end tell
  set the bounds of the first window to {0, 700, 840, 900}
  set the name of the first window to "apace_access.log"
 
  -- creat working terminal
  make new terminal
  tell the last terminal
    activate current session
    launch session "Default Session"
    tell the last session
      write text "welcome user, start now"
    end tell
  end tell
  set the bounds of the first window to {0, 0, 840, 660}
  set the name of the first window to "workspace"
 
end tell
So kann man ganze Fenster Setups zusammencoden und erspart sich so hoffentlich einen Haufen Zeit.

Nachtrag:
Man kann dann das Apple-Script auch automatisch bei jedem Start von iTerm ausführen lassen indem man es in ~/Library/iTerm/AutoLaunch.scpt ablegt. Weitere Beispiele gibt es auf der Scripting Seite von iTerm.

#445

02.03.2009 13:12
0 Kommentare
Share
  • programmieren
  • berlin
  • Referenz
  • Portfolio
  • Web
  • tipp
  • design
  • 3d
  • Work
Maiko Gubler aka Mongrelnation hat endlich ihr Portfolio online gestellt! Zu sehen gibt es verschiedene Arbeiten von ihr aus dem Bereich 3D - Renderings von Diamanten, Schnürsenkeln und ganze Trailer für’s TV.

Die Seite basiert auf NMS.Folio, dem selben System mit dem auch meine Seite läuft und für Maiko war es ein Kinderspiel ihre Arbeiten einzupflegen. Bald gibt es mehr darüber bei NoMoreSleep.

#435

06.01.2009 21:36
0 Kommentare
Share
  • Web
  • osx
  • fundstücke
  • security
  • mac
  • news
  • hacking
Das erste mal konnte ich live miterleben wie jemand oder mehrere eine Website hacken! Heute Abend hat ja bekanntlich die Macworld stattgefunden die schon mit den ganzen 17'' MacBook Pros durch alle Blogs geistert. Das muss ich nich auch noch bloggen!
Nach einer Weile eher langweiligen neuen Features für iWork und tralala konnte ich fast erschrocken lesen "Steve Jobs just died" ... Nach einer Minute wurde dementiert und es folgten im Sekundentackt neue Nachrichten (wie man sie auch oben sehen kann) :)
Lustig anzusehen, aber auch wieder ein schönes Beispiel wie wichtig es ist seine System geschlossen zu halten und ruhig mal einen Tag oder mehr damit zu verbringen es zu sichern oder sich mit dem Thema allgemein zu beschäftigen.
Hacker sind unheimlich kreative Leute und finden teilweise Lösungen in etwas einzusteigen auf die noch keiner gekommen ist. Wie es gelungen ist die Macrumorslive Übertragung zu manipulieren ist bisher aber noch unklar.

#404

01.08.2008 15:43
1 Kommentar
Share
  • code
  • programmieren
  • Referenz
  • Portfolio
  • Web
  • Musik
  • seele
  • Work
WAZAAAAM! Metallica! Metallica! Oh wie krass!
Im Auftrag von Schumanncombo entstand in den letzten 7 Tagen eine Seite zu 5 Coversongs von Metallica. Im 3 Tage-Abstand wird ein neues Video und der dazugehörige Song veröffentlicht. Wer sich anmeldet kann die Songs auch downloaden! Für lau!

#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.
  • 1
  • 2
  • weiter »
marceleichner HTML5 Harrison Theme (Validate Source), © 2010 by Ephigenia M. Eichner, Impressum