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

#475

21.07.2009 17:32
0 Kommentare
Share
  • code
  • tip
  • sql
  • mysql
  • name
Im aktuellen Projekt bin ich auf die einfache Frage gestoßen wie man Namen die komplett in einer Spalte stehen wieder in Vorname / Nachname aufsplitten kann:
-- namen sind als [nachname] [vorname] gespeichert
SELECT
  name,
  -- lastname
  SUBSTRING(name, 1, NULLIF(LOCATE(' ', name) - 1, -1))
  -- firstname
  SUBSTRING(name, LOCATE(' ', name) + 1, LENGTH(name)),
FROM users
-- namen sind als [vorname] [nachname] gespeichert
SELECT
  name
  -- firstname
  CASE WHEN LOCATE(' ', name) > 0
    THEN SUBSTRING(name, 1, LOCATE(' ', name)-1)
    ELSE name
  END,
  -- lastname
  CASE WHEN LOCATE(' ', name) > 0
    THEN SUBSTRING(name, LOCATE(' ', name) + 1, LENGTH(name))
    ELSE ''
  END,
FROM users

#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.

#371

26.10.2007 14:44
2 Kommentare
Share
  • osx
  • tip
  • Termine
  • mac
  • apple
  • seele
  • First
Ich geb' ja ungerne an, aber hier muss ick mal den Macker raushängen lassen ;-) Noch vor dem offiziellen Launch (laut Apples Homepage) ist Mac OS-X 10.5 bei mir eingetroffen :)
Der sicherheitsbackup läuft in 1..2 Stunden installier ick denn endlich :) Heissa Juhu!

EDIT #1: Nach vielen erfolglosen Installationsversuchen ... Der Installer nur stumm "OSX kann auf ihrem Rechner nicht installiert werden" meldet und man solle es wenn man Bock hat nochmal probieren. Jetzt hab ich den original MacBook Speicher, zum Glück hatte ich den noch, wieder eingebaut (im Support Center von Apple steht, man solle das mal probieren) läuft die Installation jetzt endlich durch.
Wie kann ich das hier schreiben? Ha! Auf nem anderem Mac ;-)

EDIT #2: Soar, OS X ist drauf! Läuft! alles am start, selbst nach nem totalen titlt auf alle Daten auf der Pladde kannste die alten Sachen wieder reinziehen! Super Sache! (Wie war das nochmal auf Windows - gar nicht dran denken ;-))

Subjektiv ist der Erfolg, endlich das neue System drauf zu haben immens, und der objektive Schaden, mit dem Installationsquatsch wie da hin gewaschen! Einfach original Speicher in det Book und schon flutscht das echt fein!

#343

03.01.2007 01:58
0 Kommentare
Share
  • buch
  • tip
  • Termine
  • film
  • Musik
  • seele
  • Bücher
  • Funstücke
So - es ist spät - in zweierlei Hinsicht
Meine 2-cent-charts für 2006! (ispired by Mr. T ;-))

Neu kennengelernt, gefunden und verloren ...
Die Musik ist stark einseitig Postrock ;-)
Seit dem späten Somme bin ich endlich in Besitz von Monitorboxen und ner korrekten Anlage - kann endlich gut Musik hören, 2006 ist auch das Jahr des Postrocks! - wenn wer den Typen von postrock.de kennt? ;-)

Muzik:
1. The Strokes - First Impressions of Earth
(dazu auch noch det Mercy Mercy Me! Boar ick werd zu Plaste!)
2. Seidenmatt - IYUTSOBI!!
3. alles von Godspeed(!) You Black Emperor 4. Silence Kit - Silence Kit (def ganz frühe Stuff)
5. Samuel Jackson Five - Easily Misunderstood

Songs 1. Shellac - Didn't We Deserve a Look at You the Way You Really Are
2. Saxon Shore - With a Red Suit you will become a man
3. The Strokes - Mercy Mercy Me!
4. Explosions in the Sky - Look into the air
5. Tracer AMC - Copenhagen
(6. The Silence Kit - Soul Departure (Extra!!))

(Wenn wer links zum kaufen von Platten parat hat -her damit!)

Filmse:
1. Friday Night Lights Total untergegangen, bin über den Soundtrack drauf gekommen. Zwischen den Zeilen oder whatever, super Film! Die Promotin für den Film ist einfach derbe daneben!
2. Quiet Earth oi - besser als Soylent Green und Omega Mann, (aber noch hinter 28 Days Later)
anders, klassisch - mit Preis!
3. Napoleon Dynamite
joar, kenn einigen schon, aber ich hab den erst jetzt gesehen ;-) Man sagt nur EAAAArrrrrrggghhh - Karatetrick!
4. Underground Okay, nochma alt und kennt jeder, aber HAMMERTEIL! Emotional, Verarschend, total mitreissend (vor allem am Anfang)
5. Ed Wood Kennen auch viele - Bela B. ? Vampier - Jo, Knalle in Schwarz Weiss über den Regisseur von Plan 9 from outher Space! Seelenwerk. Immerhin ist Ed Wood der schlechteste Ressigseur des 20. Jahrhunderts!

Bücher: 1. das Peter Prinzip
fast wissenschaftliche Abhandlung über Unfähigkeit
2. getting real
year! i wanna get real, das hilft dabei :) Tolle Tips, hälfte ist Bekannt und so
3. Das Leben der Anderen
Als Drehbuch gelesen, interessant

Also ja, Bücher hab ich nich viel gelesen aber schon Filme geschaut und Muzik gehört und ja, alles Gute euch da draussen, das ihr euch treu bleibt und kein Scheiss verzapft :D
marceleichner HTML5 Harrison Theme (Validate Source), © 2010 by Ephigenia M. Eichner, Impressum