Transferring Files with rsync and ssh from Server to Server

February 8th, 2010

This rsync Command is really helpful for transferring data to another server.
I need this very often.
rsync -vrlptgoD -e ssh ./yourfile.tar.gz root@XXX.XX.47.73:/root

If you need to change the ssh Port, you can write it as a string:
rsync -vrlptgoD -e 'ssh -p1356' ./yourfile.tar.gz root@XXX.XX.47.73:/root

Firefox 3.5.x problem with css files parsed by php

February 8th, 2010

A few years ago I built a Website, styled with CasCading-Stylesheets.
Because of using vars in this external Stylesheet, i had to rename it from styles.css to styles.php.

So it’s being parsed by the PHP Interpreter, but the file headers has to be modified because it should not be a real php-file, it should to be used like a css file… this header modification works fine for that:
header('content-type: text/css');

The Website works fine for years… up to now.

I upgraded my Firefox to Version 3.5.7 and when i now visit the Website, the external CSS is not being used anymore! In Safari there is no Problem! In IE there is no Problem!

I tried to find other Websites with php files used as css and i saw there is the same problem with my Firefox!

(Edited)
okay I just looked at one other Website, but there was really the same problem… bad luck.

But now I found the problem… There was given a wrong charset in my php.ini file.
(I know, I should use UTF-8… but this Website is very old and my first real project)
We’ve made a transfer of the Website to another Server a few days ago and in the php.ini file i have written ISO-8559-1 instead of ISO-8859-1.

I dont know why, but this is the reason why the CSS has completely not been interpreted by Firefox, Safari and IE did its job…

change owner of files or directories globally by searching for a group

January 22nd, 2010

Sometimes, thankfully not very often, I need to change the group or the user of many directories or files in a global way. This could happen owing to unfortunate circumstances, e.g when you switch a Serversystem to another and something went wrong or something happens you did not plan before.

With this command I find all directories inside of /var/www with the group-id 501.
then it will execute the command chgrp for changing the group-id to 33:

find /var/www -gid 501 -type d -exec chgrp 33 ‘{}’ ‘;
(You can also write ‘…chgrp www-data’)

I have to say, this command had saved my life, for more than one time.

select_year´s and select_month´s option selected by params

July 31st, 2009

I searched for an opportunity to have the options of a selectbox selected that have been chosen by the user and sent by its form.

1. Checking if the form with the selectboxes was sent or not.
If it has not been sent, i use the current month and year. Otherwise the params['date'] is filled and can be used.

<% if params[:date] == nil
	@month = Time.new.month
	@year = Time.new.year
else
	@month = params[:date][:month]
	@year = params[:date][:year]
end %>

2. The selectboxes are generated and the selected option is the local variable (current date, or detected from params)
When using params we have a string that must be converted to an integer with to_i method.

<%= select_month(@month.to_i, {:add_month_numbers => true }) %>
<%= select_year(@year.to_i, {:start_year => 2006}) %>

short PHP if statement written in one line (ternary operator)

June 6th, 2009

Its an easy way to write short If-Statements in PHP, also known as the ternary operator.
Ternary because of the three operands: a condition, a result for true, and a result for false.

But I always need to look up this snippet, so now I write it down for reference.

$notice = ($price < 20) ? 'cheap' : 'expensive';

This code is equal to this:

if($price < 20) {
    $notice = "cheap";
}
else {
    $notice = "expensive";
}

If the variable “price” is less than 20, the variable “notice” is set to “cheap”.
Otherwise (price is equal, or greater than 20) the notice is set to “expensive”.

Verlag zu Scherzen aufgelegt

May 13th, 2009

Bei der Heimwerker-Zeitschrift “Selber machen” die vom Jahreszeiten Verlag herausgegeben wird, gab es in der diesmonatigen Ausgabe (Mai 2009) einen recht unauffälligen, aber durchaus eindrucksvollen Hingucker zu entdecken!

Das Impressum der Zeitschrift wurde nicht wie gewohnt in den Druck gegeben, sondern wurde scheinbar bewusst umformuliert.
Laut Impressum kann man sich über den Bestellservice an die Heroinherstellung wenden. Desweiteren werden seltsame und nicht internetkonforme E-Mail- und Internetadressen als Kontaktmöglichkeit angegeben.

Es lässt nun Spekulationen offen ob dies ein Scherz oder gar eine art Racheakt eines Mitarbeiters war, oder ob der Verlag bewusst versucht Aufmerksamkeit auf sich zu ziehen. Wie auch immer, aus meiner Sicht ist es gelungen für ein wenig Aufmunterung zu sorgen.

domain matching regex

May 11th, 2009

A regular expression that validates a given domain without its top level domain. I didnt need to validate the tld because this comes from a selectbox, so its predefined and always valid. The http protocol or the second level domain www. are both optional, it can be written or not.

$regex = "/^(?:(http:\/\/)?)(?:(w{3}\.)?)([A-Z0-9\-".utf8_encode("äÄöÖüÜ")."]{3,})$/i";
if(!preg_match($regex,$domainname)) {
	return false;
}

So the string can look like this:
http://www.liquidbass or www.liquidbass or http://liquidbass

detailed Description:

/^

This is the beginning of the regex. The ^ is used for searching all matches from the beginning of the given string.

(?:(http:\/\/)?)(?:(w{3}\.)?)

Here we have the optional protocol and the optional second level domain www. …

([A-Z0-9\-".utf8_encode("äÄöÖüÜ")."]{3,})

This part of the regex allows all characters from a to z, hyphens and all numerics from 0 to 9.
Additionally german special chars are allowed too.
All these possible characters must match a stringlength of minimum 3.

$/i

the dollar stands for the strings end, so it would be searched for matches from beginning to the end.
the /i stands for case sensivity - the given string can be in capital letters or in lowercase.

XIX TIPA awards, 2009

May 4th, 2009
XIX TIPA Awards, 2009

XIX TIPA Awards, 2009

Jedes Jahr vergibt die TIPA Ihre Auszeichnungen für Produkte aus der Fotoindustrie.

Im April 2009 hat die Technical Image Press Association wieder Produkte aus verschiedenen Kategorien mit ihren Awards ausgezeichnet.

Die Gewinnerliste: XIX TIPA Awards, 2009

Unter den Gewinnern sind Herstellernamen zu finden wie:
Canon, Hasselblad, Broncolor, …

40 Jahre AMD

May 1st, 2009

In diesem Sinne einen herzlichen Glückwunsch!

Als Dankeschön an die treuen Kunden startet AMD einen Video und Foto Contest bei dem es schöne Gewinne abzustauben gibt.

Man kann sich entscheiden ob man ein Video oder ein Foto einschickt, es ist allerdings nur jeweils eines erlaubt.

Es gibt ein paar Vorgaben die bei dem Video Contest eingehalten werden sollen:
Das eingeschickte Video darf bis zu 60 Sek. lang sein, außerdem muss der Satz “Happy 40th Anniversary AMD” in irgendeiner Form auftauchen.

Für eingeschickte Videos gibt es zu gewinnen:
3 x ATI Radeon™ HD 4890 Grafikkarten.
40 x ATI Radeon 4650 Grafikkarten.
Außerdem werden ausgewählte Videos vom AMD YouTube Channel verlinkt.

Für den Foto Contest sind keine speziellen Vorgaben gesetzt. wichtig ist nur, dass ein Foto eingeschickt wird und keine digital zusammengesetzte Fotomontage o.ä.

Zu gewinnen gibt es:
5x AMD Phenom™ II X4 Black Edition mit einem ASUS M4A78T-E Mainboard.
8x AMD Athlon 7850 processor mit einem Gigabyte GA-MA780G-UD3H Mainboard.

Hier gehts zur ofiziellen Geburtstagsseite und der Contest Kundgebung von AMD

Telefonnummern Routing-Problem

May 1st, 2009

Unser geschäftlicher ISDN Telefonanschluss kann von diversen Anrufern nicht erreicht werden, derjenige erhält entweder ein Besetztzeichen, oder sofern er vom Mobiltelefon aus anruft die Information dass Netz sei belegt.

Bei den Telefonanbietern ist dieses Problem bekannt, scheinbar wird aber nicht gerne darüber mit dem Kunden gesprochen oder diskutiert - Bereits vor unserem Wechsel des Telekommunikationsanbieters Arcor AG zur deutschen Telekom AG trat dieses Phänomen vereinzelt auf, allerdings in einem noch erträglichen Maße.

Es scheint irgendwo ein Routingproblem zu geben, über das man uns leider nicht so recht aufklären will oder kann. Nach unserer Rufnummernübernahme von Arcor zur deutschen Telekom tritt dieses Problem nun so massiv auf, dass wir die nicht durchkommenden Anrufer sehr schnell selektieren konnten. Es handelt sich dabei immer um Anschlüsse von externen Anbietern.

Erste Gespräche mit dem jetzigen Anbieter verliefen erfolglos, Providerseitige Tests waren fehlerfrei, wären wir dennoch der Meinung es bestünde ein Problem so müsse jemand vorbeikommen und das wird dann natürlich berechnet.

Nach dem das Auswechseln der Telefonanlage wie bereits erwartet keine Besserung brachte versuchten wir es wieder bei dem Provider. Diesmal kannte man plötzlich das Problem, wies es aber typischerweise weit von sich. Es kann wohl sehr lange dauern bis dieses Problem behoben ist, denn Arcor lässt nicht mit sich reden, so hieß es. Wir sollten also selbst Arcor ein wenig anstoßen.

Ein Anruf bei Arcor verlief wie erwartet. Man wusste nichts mit unserem Anruf anzufangen und sagte es uns das dies das falsche Vorgehen sei.

Wir bekommen deutlich weniger Anfragen von potenziellen Neukunden und generell klingelt das Telefon deutlich seltener.