<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>treibsand.com</title>
	<atom:link href="http://www.treibsand.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.treibsand.com</link>
	<description></description>
	<lastBuildDate>Thu, 16 Feb 2012 11:41:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Rails 3 Routing mit Bedingungen</title>
		<link>http://www.treibsand.com/2012/02/16/rails-3-routing-mit-bedingungen/</link>
		<comments>http://www.treibsand.com/2012/02/16/rails-3-routing-mit-bedingungen/#comments</comments>
		<pubDate>Thu, 16 Feb 2012 11:41:56 +0000</pubDate>
		<dc:creator>Toast</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.treibsand.com/?p=644</guid>
		<description><![CDATA[Ja es ist lange her, seit dem letzten Artikel Es ist also mehr als überfällig wieder etwas über Rails zu schreiben. Vor kurzem bin ich über eine recht nette Sache beim Rails routing gestolpert, nämlich den constraints. In Rails 2 waren diese noch als requirements bekannt, allerdings waren sie damals nicht so mächtig. So konnte [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.treibsand.com/wp-content/uploads/2010/06/rails-full.png" rel="lightbox[644]"><img class="alignleft size-full wp-image-512" title="rails-full.png" src="http://www.treibsand.com/wp-content/uploads/2010/06/rails-full.png" alt="" width="87" height="111" /></a>Ja es ist lange her, seit dem letzten Artikel <img src='http://www.treibsand.com/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' />  Es ist also mehr als überfällig wieder etwas über Rails zu schreiben.</p>
<p>Vor kurzem bin ich über eine recht nette Sache beim Rails routing gestolpert, nämlich den constraints. In Rails 2 waren diese noch als requirements bekannt, allerdings waren sie damals nicht so mächtig. So konnte man mit Rails 2 nur einfache Bedingungen für Routen definieren, z.B. dass ein übergebener Wert eine 4-stellige Zahl sein muss. Mit Rails 3 ist man hier nun wesentlich flexibler geworden, es lassen sich z.B. Bedingungen anhand das UserAgents festlegen, oder direkt die remote IP in einer Datenbank nachschlagen lassen, bevor die Route überhaupt geprüft wird. So könnte man z.B. eine dynamische IP basierte Zugriffskontrolle für Ressourcen aufbauen ohne umfangreiche Konfigurationen an Webservern vornehmen zu müssen.</p>
<p><span id="more-644"></span></p>
<p>Als erstes einfaches Beispiel dient hier die Prüfung auf ein korrektes Datumsformat.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">match <span style="color:#996600;">&quot;/:year(/:month(/:day))&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;blog#show&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:constraints</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:year</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">/</span>\d<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006666;">4</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">/</span>, <span style="color:#ff3333; font-weight:bold;">:month</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">/</span>\d<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006666;">2</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">/</span>, <span style="color:#ff3333; font-weight:bold;">:day</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">/</span>\d<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006666;">2</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">/</span> <span style="color:#006600; font-weight:bold;">&#125;</span></pre></div></div>

<p>Hier wird geprüft, dass das Jahr als 4-stellige Zahl, der Monat und der Tag als 2-stellige Zahl angegeben werden müssen.</p>
<p>Das ging bereits auch schon mit Rails 2, mit Rails 3 könnten wir jetzt z.B. eine Route nur für einen bestimmten Browser verfügbar machen&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">match <span style="color:#996600;">&quot;/ffonly&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;info#ff&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:constraints</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:user_agent</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">/</span>Firefox<span style="color:#006600; font-weight:bold;">/</span> <span style="color:#006600; font-weight:bold;">&#125;</span></pre></div></div>

<p>In meinem Fall brauchte ich aber eine Limitierung auf die remote IP Adresse, so dass bestimmte Ressourcen für eine Liste von IPs verfügbar sind. Klar kann man das recht einfach direkt im Webserver konfigurieren, nur lassen sich dann die freigeben Hosts nicht gleich direkt in die Rails Anwendung integrieren. </p>
<p>Um den constraint an ein Model zu binden, brauchen wir erst mal eine Migration und ein Model, welches für die IP Adressen zuständig ist.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> CreateHosts <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Migration</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> change
    create_table <span style="color:#ff3333; font-weight:bold;">:hosts</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>t<span style="color:#006600; font-weight:bold;">|</span>
      t.<span style="color:#CC0066; font-weight:bold;">string</span> <span style="color:#ff3333; font-weight:bold;">:hostname</span>
      t.<span style="color:#CC0066; font-weight:bold;">string</span> <span style="color:#ff3333; font-weight:bold;">:ip</span>
      t.<span style="color:#9900CC;">timestamps</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Das entsprechende Model ist auch recht schnell gemacht&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> Host <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span>
  validates <span style="color:#ff3333; font-weight:bold;">:hostname</span>, <span style="color:#ff3333; font-weight:bold;">:presence</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">true</span>
  validates <span style="color:#ff3333; font-weight:bold;">:ip</span>, <span style="color:#ff3333; font-weight:bold;">:presence</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">true</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Um nun die Überprüfung der remote IP machen zu können brauchen eine weitere Klasse, welche aus den Routes aufgerufen werden kann.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> IpRestrictor
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">matches</span>?<span style="color:#006600; font-weight:bold;">&#40;</span>request<span style="color:#006600; font-weight:bold;">&#41;</span>
    Host.<span style="color:#9900CC;">all</span>.<span style="color:#9900CC;">map</span><span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>h<span style="color:#006600; font-weight:bold;">|</span> h.<span style="color:#9900CC;">ip</span><span style="color:#006600; font-weight:bold;">&#125;</span>.<span style="color:#9966CC; font-weight:bold;">include</span>?<span style="color:#006600; font-weight:bold;">&#40;</span>request.<span style="color:#9900CC;">ip</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Hier wird nur geprüft, ob die remote IP in der Tabelle hosts enthalten ist. Am besten man legt die Klasse in das <em>extras</em> Verzeichnis vom Rails Projekt.</p>
<p>Nun können einzelne Ressourcen an die Restriktionen in der Datei <em>routes.rb</em> gebunden werden&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">constraints IpRestrictor <span style="color:#9966CC; font-weight:bold;">do</span>
  resources <span style="color:#ff3333; font-weight:bold;">:customers</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Die Ressource customers ist nun nur von IPs ansprechbar, welche in der hosts Tabelle gespeichert wurden. </p>
<p>Mit den constraints lassen sich recht einfach beliebige Restriktionen oder Checks einbauen, welche direkt in der Applikation eingebunden werden können, ohne dabei gleich den Webserver neu konfigurieren zu müssen.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.treibsand.com/2012/02/16/rails-3-routing-mit-bedingungen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby Entwicklung mit RVM</title>
		<link>http://www.treibsand.com/2011/03/21/ruby-entwicklung-mit-rvm/</link>
		<comments>http://www.treibsand.com/2011/03/21/ruby-entwicklung-mit-rvm/#comments</comments>
		<pubDate>Mon, 21 Mar 2011 12:23:31 +0000</pubDate>
		<dc:creator>Toast</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[RVM]]></category>
		<category><![CDATA[Shell]]></category>

		<guid isPermaLink="false">http://www.treibsand.com/?p=631</guid>
		<description><![CDATA[Die Entwicklung mit Ruby, vor allem mit Ruby on Rails, ist wirklich traumhaft. Webprojekte können mit Ruby on Rails relativ schnell umgesetzt werden. Das einzige was wirklich traurig ist, ist das Handling der benötigten Gems. Im Vergleich zu Python und Django werden sehr viele Gems benötigt. Das erinnert etwas an das grausame CPAN von Perl, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.treibsand.com/wp-content/uploads/2011/03/RubyLogo.png" rel="lightbox[631]"><img src="http://www.treibsand.com/wp-content/uploads/2011/03/RubyLogo.png" alt="" title="RubyLogo" width="145" height="163" class="alignleft size-full wp-image-632" /></a> Die Entwicklung mit Ruby, vor allem mit Ruby on Rails, ist wirklich traumhaft. Webprojekte können mit Ruby on Rails relativ schnell umgesetzt werden. Das einzige was wirklich traurig ist, ist das Handling der benötigten Gems. Im Vergleich zu Python und Django werden sehr viele Gems benötigt. Das erinnert etwas an das grausame CPAN von Perl, wo einige Perl Module eine Unzahl von Abhängigkeiten haben, so dass schnell 100 Module installiert sind.</p>
<p>Ein ähnliches Problem kann mit Ruby aufkommen. Sobald sich mehrere Projekte angehäuft haben, werden u.U. verschiede Ruby bzw. Rails Versionen, wenn nicht sogar jRuby benötigt. Sind alle Gems direkt im System installiert, kann das ganze schon ziemlich unübersichtlich werden. </p>
<p>Genau dieses Problem löst <a href="http://rvm.beginrescueend.com/">RVM</a>, hierbei handelt es sich um ein Tool, mit welchem sich unterschiedliche Ruby Versionen bzw. Gems verwalten lassen. Alles wird hier direkt in das Home Verzeichnis des Benutzers installiert. Sobald RVM in die lokale .bashrc eingebunden ist, kann per Kommando die Ruby Installation gewechselt werden. </p>
<p><span id="more-631"></span></p>
<p>Die Installation von RVM ist mehr als einfach. Sofern Git installiert ist, kann direkt die letzte Version aus Git installiert werden:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">bash</span> <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight: bold;">&lt;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span> curl http:<span style="color: #000000; font-weight: bold;">//</span>rvm.beginrescueend.com<span style="color: #000000; font-weight: bold;">/</span>releases<span style="color: #000000; font-weight: bold;">/</span>rvm-install-head <span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>Eine Installation über Tarball ist auch möglich:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">bash</span> <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight: bold;">&lt;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span> curl http:<span style="color: #000000; font-weight: bold;">//</span>rvm.beginrescueend.com<span style="color: #000000; font-weight: bold;">/</span>releases<span style="color: #000000; font-weight: bold;">/</span>rvm-install-latest <span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>Für die dauerhafte Aktivierung von RVM, muss die lokale <em>.bashrc</em> bzw. <em>.profile</em> Datei angepasst werden.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-s</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$HOME</span>/.rvm/scripts/rvm&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> . <span style="color: #ff0000;">&quot;<span style="color: #007800;">$HOME</span>/.rvm/scripts/rvm&quot;</span>  <span style="color: #666666; font-style: italic;"># This loads RVM into a shell session.</span></pre></div></div>

<p>Mit dem Kommando</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">source</span> ~<span style="color: #000000; font-weight: bold;">/</span>.rvm<span style="color: #000000; font-weight: bold;">/</span>scripts<span style="color: #000000; font-weight: bold;">/</span>rvm</pre></div></div>

<p>kann die RVM Installtion initial eingelesen werden, ohne dass ein neuer Login notwendig ist. Jetzt sollte das Kommando</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">type</span> rvm <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">head</span> <span style="color: #660033;">-1</span></pre></div></div>

<p>die Ausgabe</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">rvm is a <span style="color: #000000; font-weight: bold;">function</span></pre></div></div>

<p>bringen. Dann ist RVM volständig installiert.</p>
<p>Als nächstes brauchen wir eine Ruby Installation. Um zu sehen, welche alle verfügbar sind, reicht das Kommando</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ rvm list known</pre></div></div>

<p>Wenn wir z.B. Ruby 1.8.7 installieren wollen, können wir das wie folgt machen</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ rvm  <span style="color: #c20cb9; font-weight: bold;">install</span> ruby-1.8.7
Installing Ruby from <span style="color: #7a0874; font-weight: bold;">source</span> to: ...
&nbsp;
$ ruby <span style="color: #660033;">-v</span>
ruby 1.8.7 <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">2011</span>-02-<span style="color: #000000;">18</span> patchlevel <span style="color: #000000;">334</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>i686-darwin10.6.0<span style="color: #7a0874; font-weight: bold;">&#93;</span></pre></div></div>

<p>Damit unser Environment auch das neu installierte Ruby benutzt, und nicht u.U. ein im System installiertes, können wir mit RVM die Ruby Installation wechseln</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ rvm  ruby-1.8.7
Switching to ruby 1.8.7 <span style="color: #000000;">334</span> ...</pre></div></div>

<p>Auch das Kommando <em>gem</em> wird jetzt aus der RVM Installation verwendet, sodass alle Gems in das Home Verzeichnis installiert werden.</p>
<p>Nun zu der wirklich interessanten Funktion von RVM, den Gemsets. Nehmen wir an, es gibt ein Verzeichnis <em>projects</em>, in welchem ein Rails 2 Projekt (<em>project_a</em>) ist und ein Rails 3 Projekt (<em>project_b</em>). Um für <em>project_a</em> nun die Entwicklungsumgebung zu installieren, legen wir hierfür direkt im Projektverzeichnis eine <em>.rvmrc</em> an.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'rvm 1.8.7@rails2 --create'</span> <span style="color: #000000; font-weight: bold;">&gt;</span> .rvmrc</pre></div></div>

<p>Durch den Inhalt der <em>.rvmrc</em> weiss nun RVM, dass es, sobald man in dieses Verzeichnis wechselt, Ruby 1.8.7 mit dem Gemset <em>rails2</em> verwenden soll. Noch haben wir allerdings keine Gems in dem Gemset. Um zum Gemset zu wechseln reicht</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ rvm 1.8.7<span style="color: #000000; font-weight: bold;">@</span>rails2</pre></div></div>

<p>und Rails 2.3.8 kann einfach mit</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ gem <span style="color: #c20cb9; font-weight: bold;">install</span> rails <span style="color: #660033;">-v</span> 2.3.8</pre></div></div>

<p>instaliert werden.</p>
<p>Für unser Rails 3 Projekt machen wir das gleiche</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'rvm 1.8.7@rails2 --create'</span> <span style="color: #000000; font-weight: bold;">&gt;</span> .rvmrc
$ rvm 1.8.7<span style="color: #000000; font-weight: bold;">@</span>rails3
$ gem <span style="color: #c20cb9; font-weight: bold;">install</span> rails</pre></div></div>

<p>Für unsere Projekte sind nun verschiedene Rails Versionen hinterlegt und man muss nur in das entsprechende Projekt Verzeichnis wechseln, damit die korrekte Version für das Projekt verwendet wird <img src='http://www.treibsand.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.treibsand.com/2011/03/21/ruby-entwicklung-mit-rvm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FreeBSD Installation mit System Mirror und ZFS Raid</title>
		<link>http://www.treibsand.com/2011/02/16/freebsd-installation-mit-system-mirror-und-zfs-raid/</link>
		<comments>http://www.treibsand.com/2011/02/16/freebsd-installation-mit-system-mirror-und-zfs-raid/#comments</comments>
		<pubDate>Wed, 16 Feb 2011 13:28:34 +0000</pubDate>
		<dc:creator>Toast</dc:creator>
				<category><![CDATA[Unix]]></category>
		<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[RAID]]></category>
		<category><![CDATA[ZFS]]></category>

		<guid isPermaLink="false">http://www.treibsand.com/?p=617</guid>
		<description><![CDATA[In meinem letzten Posting habe ich ja geschrieben, dass ich mir den HP Microserver angeschafft habe. Nun geht es um die Installation von FreeBSD, bei welcher das System selber über alle Festplatten gespiegelt und der restliche Plattenplatz als ZFS Raid genutzt wird. Bestückt ist der Server mit 4x 500GB SATA Festplatten (ad4,ad6,ad8 und ad10). Auf [...]]]></description>
			<content:encoded><![CDATA[<p>In meinem letzten Posting habe ich ja geschrieben, dass ich mir den HP Microserver angeschafft habe. Nun geht es um die Installation von FreeBSD, bei welcher das System selber über alle Festplatten gespiegelt und der restliche Plattenplatz als ZFS Raid genutzt wird.</p>
<p><span id="more-617"></span></p>
<p>Bestückt ist der Server mit 4x 500GB SATA Festplatten (ad4,ad6,ad8 und ad10). Auf jeder Festplatte werden 3 Partitionen angelegt, einmal 25GB für das Betriebssystem, 1GB Swap und der Rest für ZFS. </p>
<p>Nachdem von der FreeBSD CD (ich verwende 8.1 amd64) gebootet wurde und sysinstall gestartet ist, kann die normale Installation gestartet werden. Sobald man bei der Partitionierung ist müssen die Platten wie folgt aufgeteilt werden:</p>
<ol>
<li>die Platte (ad4) auswählen</li>
<li>Eine Partition mit 25000M erstellen, mit dem Typ 165</li>
<li>Eine Partition mit 1000M erstellen, ebenfalls Typ 165</li>
<li>Eine Partition mit restlich verfügbaren Platz erstellen, auch Typ 165</li>
<li>Partitions Manager mit q verlassen</li>
<li>BootMgr als Boot Manager auswählen (nicht Standard!)</li>
<li>Die obigen Schritte 2-6 nun nochmal für die restlichen Platten (ad6, ad8 und ad10) ausführen</li>
</ol>
<p>Als nächstes können die Slices angelegt werden.</p>
<ol>
<li>Ein Slice in ad4s2, ad6s2, ad8s2 und ad10s2 anlegen und als Swap definieren</li>
<li>Ein Slice mit 1024M in ad4s1 anlegen und als Mountpoint / setzen</li>
<li>Ein Slice mit 1024M in ad4s1 anlegen und als Mountpoint /tmp setzen</li>
<li>Ein Slice mit 2048M in ad4s1 anlegen und als Mountpoint /var setzen</li>
<li>Ein Slice mit dem restlich verfügbaren Platz anlegen und als Mountpoint /usr setzen</li>
</ol>
<p>Es müssen keine weiteren Slices für die anderen Partitionen angelegt werden. Es nur wichtig, dass bei alle Platten adXs2 als Swap definiert wurde. Anschließend kann die Installation normal durchgeführt werden und das System mit sysinstall konfiguriert werden.</p>
<p>Sobald die Installation abgeschlossen ist, kann rebootet werden, allerdings muss wieder von der CD gebootet werden, damit die gmirror Konfiguration vorgenommen werden kann. Wenn die CD gebootet ist, FixIt in sysinstall auswählen und die Shell von CD starten.</p>
<p>In der Shell muss zuerst ein Symlink angelegt werden, damit gmirror in der Shell von CD funktioniert.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>dist<span style="color: #000000; font-weight: bold;">/</span>boot<span style="color: #000000; font-weight: bold;">/</span>kernel <span style="color: #000000; font-weight: bold;">/</span>boot</pre></div></div>

<p>Danach kann gmirror geladen und initialisiert werden:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">gmirror load
gmirror label <span style="color: #660033;">-v</span> gm0s1 <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>ad4s1</pre></div></div>

<p>Damit FreeBSD den Mirror beim Booten verwendet muss dies noch eingetragen werden:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>mirror<span style="color: #000000; font-weight: bold;">/</span>gm0s1a <span style="color: #000000; font-weight: bold;">/</span>mnt
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">geom_mirror_load</span>=<span style="color: #ff0000;">&quot;YES&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>boot<span style="color: #000000; font-weight: bold;">/</span>loader.conf</pre></div></div>

<p>Schließlich muss noch die Datei <strong>/mnt/etc/fstab</strong> angepasst werden, dort stehen diese noch mit <strong>ad4</strong> drin. Dort muss jeder Eintrag mit <strong>/dev/ad4s1X</strong> zu <strong>/dev/mirror/gm0s1X</strong> geändert werden. </p>
<p>Jetzt kann der Rechner direkt von der Festplatte gebootet werden. Sobald das System hochgefahren ist, können die anderen Platten in den Mirror eingehängt werden:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">gmirror insert gm0s1 <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>ad6s1
gmirror insert gm0s1 <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>ad8s1
gmirror insert gm0s1 <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>ad10s1
gmirror status</pre></div></div>

<p> Es kann jetzt ein paar Minuten dauern, bis <strong>gmirror status</strong> angibt, dass Platten gespiegelt sind. Sobald das erledigt ist, können wir uns um ZFS kümmern.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">zfs_enable</span>=<span style="color: #ff0000;">&quot;YES&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>rc.conf</pre></div></div>

<p>Dadurch wird ZFS beim Starten aktiviert. Jetzt kann ein ZFS Raid Pool angelegt werden:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">zpool create tank raidz ad4s3 ad6s3 ad8s3 ad10s3</pre></div></div>

<p>Nach der Erstellung des Pools können die einzelnen Mountpoints angelegt werden.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">zfs create tank<span style="color: #000000; font-weight: bold;">/</span>home
zfs create tank<span style="color: #000000; font-weight: bold;">/</span>stuff</pre></div></div>

<p>Soll z.B. der Mountpoint tank/stuff komprimiert werden, dann kann dies wie folgt gemacht werden:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">zfs <span style="color: #000000; font-weight: bold;">set</span> <span style="color: #007800;">compression</span>=<span style="color: #c20cb9; font-weight: bold;">gzip</span> tank<span style="color: #000000; font-weight: bold;">/</span>stuff</pre></div></div>

<p>Wenn z.B. die Home Verzeichnisse aus ZFS verwendet werden sollen, so können diese auch direkt unter /home gemountet werden:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">zfs <span style="color: #000000; font-weight: bold;">set</span> <span style="color: #007800;">mountpoint</span>=<span style="color: #000000; font-weight: bold;">/</span>home tank<span style="color: #000000; font-weight: bold;">/</span>home</pre></div></div>

<p>Sobald alles abgeschlossen ist, hat man ein wunderbares FreeBSD System, welches redundant über alle Festplatten installiert ist <img src='http://www.treibsand.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.treibsand.com/2011/02/16/freebsd-installation-mit-system-mirror-und-zfs-raid/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HP&#8217;s neuer Server Winzling</title>
		<link>http://www.treibsand.com/2011/02/14/hps-neuer-server-winzling/</link>
		<comments>http://www.treibsand.com/2011/02/14/hps-neuer-server-winzling/#comments</comments>
		<pubDate>Mon, 14 Feb 2011 11:21:38 +0000</pubDate>
		<dc:creator>Toast</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[HP]]></category>
		<category><![CDATA[Server]]></category>

		<guid isPermaLink="false">http://www.treibsand.com/?p=579</guid>
		<description><![CDATA[Ich konnte es ja kaum glauben, als ich das erste mal vom neuen HP Microserver N36L gelesen habe. Der Microserver ist eigentlich für Kleinunternehmen mit bis zu 10 Mitarbeitern ausgelegt, die nicht direkt die Leistung eines großen Servers brauchen. Trotzdem hat er genug Power für die alltäglichen Server Dienste. Der vorherige Einstieg in die Proliant [...]]]></description>
			<content:encoded><![CDATA[<p>Ich konnte es ja kaum glauben, als ich das erste mal vom neuen HP Microserver N36L gelesen habe. Der Microserver ist eigentlich für Kleinunternehmen mit bis zu 10 Mitarbeitern ausgelegt, die nicht direkt die Leistung eines großen Servers brauchen. Trotzdem hat er genug Power für die alltäglichen Server Dienste. </p>
<p><span id="more-579"></span></p>
<p>Der vorherige Einstieg in die Proliant Klasse war der HP Proliant ML110, welcher in der Grundausstattung ca. 1000,- EUR kostet. Das unterbietet der Microserver bei weitem, dieser kostet nämlich nur knapp unter 300,- EUR. Durch den Preis wird er vermutlich auch in den Blick von Privatpersonen fallen, welche für Zuhause einen günstigen Server brauchen, z.B. als NAS.</p>
<p>Durch das kompakte Gehäuse ist der HP MicroServer bis zu 50 Prozent kleiner und leiser als vergleichbare Server, und verbraucht auch noch sehr wenig Strom. Im Ruhemodus verbraucht er ca. 28 Watt und unter Last ca. 40-50 Watt. </p>
<p>Auch die Hardware Ausstattung kann sich durchaus sehen lassen:</p>
<ul>
<li>AMD Athlon II Modell NEO N36L (2 Cores, 1,30 GHz, 1 MB L2, 15 W)</li>
<li>1GB DDR3 Speicher (max. 8GB)</li>
<li>Integriertes SATA-RAID mit 4 Ports</li>
<li>2 zusätzliche PCI-Ex Steckplätze</li>
<li>4 SATA Festplatten Slots</li>
<li>5,25&#8243; Zoll Laufwerksschacht</li>
</ul>
<p>Die Bauweise erinnert etwas an die Shuttle XPC Systeme, allerdings erscheint mir den HP Server etwas mehr durchdacht zu sein. Das Mainboard lässt sich z.B. mit 2 Schrauben lösen und einfach herausziehen. Ziemlich praktisch, wenn man zusätzlichen Speicher einbauen will. Man muss dann nicht gleich das ganze Gehäuse zerlegen.</p>
<p>Meiner Meinung nach, hat HP mit dem Server einen Volltreffer gelandet. Für mich ist er der perfekte Server für Zuhause, und mit 4x 500GB SATA Festplatten hat man ausreichend Platz um Filme für die Playstation 3 bereit zu stellen <img src='http://www.treibsand.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>

<a href='http://www.treibsand.com/2011/02/14/hps-neuer-server-winzling/bild0-1943191503-22g_400/' title='HP Microserver N36L'><img width="150" height="150" src="http://www.treibsand.com/wp-content/uploads/2011/02/Bild0-1943191503-22G_400-150x150.jpg" class="attachment-thumbnail" alt="HP Microserver N36L" title="HP Microserver N36L" /></a>
<a href='http://www.treibsand.com/2011/02/14/hps-neuer-server-winzling/zbild1-1943191503-22g_400/' title='HP Microserver N36L Rückseite'><img width="150" height="150" src="http://www.treibsand.com/wp-content/uploads/2011/02/zbild1-1943191503-22G_400-150x150.jpg" class="attachment-thumbnail" alt="HP Microserver N36L Rückseite" title="HP Microserver N36L Rückseite" /></a>
<a href='http://www.treibsand.com/2011/02/14/hps-neuer-server-winzling/zbild0-1943191503-22g_400-1/' title='HP Microserver N36L'><img width="150" height="150" src="http://www.treibsand.com/wp-content/uploads/2011/02/zbild0-1943191503-22G_400-1-150x150.jpg" class="attachment-thumbnail" alt="HP Microserver N36L" title="HP Microserver N36L" /></a>
<a href='http://www.treibsand.com/2011/02/14/hps-neuer-server-winzling/01425i238520sz100/' title='HP Microserver N36L Open'><img width="150" height="150" src="http://www.treibsand.com/wp-content/uploads/2011/02/01425i238520sz100-150x150.jpg" class="attachment-thumbnail" alt="HP Microserver N36L Open" title="HP Microserver N36L Open" /></a>

]]></content:encoded>
			<wfw:commentRss>http://www.treibsand.com/2011/02/14/hps-neuer-server-winzling/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Kann man mit dem iPhone ein Foto Shooting machen?</title>
		<link>http://www.treibsand.com/2010/12/10/kann-man-mit-dem-iphone-ein-foto-shooting-machen/</link>
		<comments>http://www.treibsand.com/2010/12/10/kann-man-mit-dem-iphone-ein-foto-shooting-machen/#comments</comments>
		<pubDate>Fri, 10 Dec 2010 11:44:12 +0000</pubDate>
		<dc:creator>Toast</dc:creator>
				<category><![CDATA[Fotografie]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[Foto]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Studio]]></category>

		<guid isPermaLink="false">http://www.treibsand.com/?p=572</guid>
		<description><![CDATA[Manche Leute behaupten ja, das die Kamera im iPhone richtig gut ist. Ich persönlich bin der Meinung, dass diese gerade so für Schnappschüsse ausreicht und richtige Fotos mit einer vernünftigen SLR gemacht werden sollten. Allerdings bin ich vor kurzem über ein Video gestolpert, in welchem ein professioneller Fotograf ein Fashion Shooting mit dem iPhone versucht. [...]]]></description>
			<content:encoded><![CDATA[<p>Manche Leute behaupten ja, das die Kamera im iPhone richtig gut ist. Ich persönlich bin  der Meinung, dass diese gerade so für Schnappschüsse ausreicht und richtige Fotos mit einer vernünftigen SLR gemacht werden sollten.</p>
<p>Allerdings bin ich vor kurzem über ein Video gestolpert, in welchem ein professioneller Fotograf ein Fashion Shooting mit dem iPhone versucht. Die Ergebnisse können sich sogar durchaus sehen lassen&#8230;</p>
<p><object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/TOoGjtSy7xY?fs=1&amp;hl=de_DE"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/TOoGjtSy7xY?fs=1&amp;hl=de_DE" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.treibsand.com/2010/12/10/kann-man-mit-dem-iphone-ein-foto-shooting-machen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zukünftig kein XServe mehr von Apple</title>
		<link>http://www.treibsand.com/2010/11/05/zukunftig-kein-xserve-mehr-von-apple/</link>
		<comments>http://www.treibsand.com/2010/11/05/zukunftig-kein-xserve-mehr-von-apple/#comments</comments>
		<pubDate>Fri, 05 Nov 2010 12:33:53 +0000</pubDate>
		<dc:creator>Toast</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[XServe]]></category>

		<guid isPermaLink="false">http://www.treibsand.com/?p=556</guid>
		<description><![CDATA[Wie MacLife heute berichtet, stellt Apple die XServe Reihe zum 31.1.2011 komplett ein. Die komplette Baureihe wird nicht mehr weiter entwickelt, und als Alternative soll man Mac Pros bzw. Mac minis mit Snow Leopard Server verwenden. Apple nimmt damit komplett Abschied von der 19&#8243; Bauweise. Warum verstehe ich allerdings überhaupt nicht. Warum sollte man sich [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.treibsand.com/wp-content/uploads/2010/11/xserveg5_300x181.shkl_.jpg" alt="" title="Apple XServe" width="300" height="181" class="alignright size-full wp-image-557" />Wie <a href="http://www.maclife.de/mac/rechner/pro/apple-stellt-xserve-ein-veroeffentlicht-„xserve-transition-guide“-0">MacLife</a> heute berichtet, stellt Apple die XServe Reihe zum 31.1.2011 komplett ein. Die komplette Baureihe wird nicht mehr weiter entwickelt, und als Alternative soll man Mac Pros bzw. Mac minis mit Snow Leopard Server verwenden.</p>
<p>Apple nimmt damit komplett Abschied von der 19&#8243; Bauweise. Warum verstehe ich allerdings überhaupt nicht. Warum sollte man sich ein Desktop Tower System in ein Rechenzentrum stellen, welches 12 Höheneinheiten braucht? Vor allem, wenn der Rechenzentrumsbetreiber womöglich noch nach Höheneinheiten abrechnet (ja da gibt es einige). Na gut, man könnte wahrscheinlich 2 Mac Pro Maschinen nebeneinander hinstellen, dass wären dann aber für 2 Server immer noch 12 Einheiten im Vergleich zu 2 mit je einem XServe. </p>
<p>In dem PDF <a href="http://images.apple.com/xserve/pdf/L422277A_Xserve_Guide.pdf">Xserve Transition Guide</a> von Apple werden die Leistungen der 3 Maschinen verglichen und es wird festgehalten, dass der Mac Pro wesentlich leistungsstärker als ein XServe ist, ausserdem wird die flexible Erweiterbarkeit des Tower System nochmal besonders hervorgehoben. Was einen aber auch nicht gerade verwundert, da erst vor kurzem die Mac Pro Reihe aktualisiert wurde und der XServe Reihe keine Aktualisierung gegönnt wurde.</p>
<p>Ich jedenfalls verstehe die Entscheidung nicht, ein Mac Pro braucht wesentlich mehr Platz in einem Rechenzentrum und ein Mac mini hat natürlich nicht die gleiche Leistung. Ein weiteres Killer Kriterium gegen die Desktop Systeme ist die fehlende redundante Stromversorgung. Wer verbaut heute noch einen Server in ein Rechenzentrum, wenn nur ein Netzteil vorhanden ist? Das könnte ziemlich böse Enden <img src='http://www.treibsand.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.treibsand.com/2010/11/05/zukunftig-kein-xserve-mehr-von-apple/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>has_many :through mit Checkboxen</title>
		<link>http://www.treibsand.com/2010/11/03/has_many-through-mit-checkboxen/</link>
		<comments>http://www.treibsand.com/2010/11/03/has_many-through-mit-checkboxen/#comments</comments>
		<pubDate>Wed, 03 Nov 2010 16:04:34 +0000</pubDate>
		<dc:creator>Toast</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.treibsand.com/?p=543</guid>
		<description><![CDATA[Nehmen wir an, wir haben eine Rails Applikation mit einer Many-to-Many Beziehung, bei welcher die Verknüpfungen über Checkboxen und nicht über Multiselect Listen oder ähnliches verwirklicht werden sollen. Die Umsetzung ist gar nicht mal so aufwändig&#8230;;-) Als Beispiel könnte man die Bestellung einer Pizza nehmen. Ein Kunde will eine Pizza über ein Formular bestellen. Im [...]]]></description>
			<content:encoded><![CDATA[<p><img class="linked-to-original" src="http://www.treibsand.com/wp-content/uploads/2010/06/rails-thumb.png" height="111" align="right" width="87" style=" display: inline; float: left; margin: 0 10px 10px 0;" />Nehmen wir an, wir haben eine Rails Applikation mit einer Many-to-Many Beziehung, bei welcher die Verknüpfungen über Checkboxen und nicht über Multiselect Listen oder ähnliches verwirklicht werden sollen. Die Umsetzung ist gar nicht mal so aufwändig&#8230;;-)</p>
<p>Als Beispiel könnte man die Bestellung einer Pizza nehmen. Ein Kunde will eine Pizza über ein Formular bestellen. Im Formular werden alle verfügbaren Beläge in einer Liste mit jeweils eine Checkbox dargestellt, so dass der Kunde einfach per Klick auf die Checkboxen die gewünschte Kombination auswählen kann.</p>
<p><span id="more-543"></span></p>
<p>Die Models würden dann wie folgt aussehen:</p>
<p><strong>app/models/pizza.rb</strong></p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> Pizza <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span>
  has_many <span style="color:#ff3333; font-weight:bold;">:pizza_toppings</span>, <span style="color:#ff3333; font-weight:bold;">:dependent</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:destroy</span>
  has_many <span style="color:#ff3333; font-weight:bold;">:toppings</span>, <span style="color:#ff3333; font-weight:bold;">:through</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:pizza_toppings</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p><strong>app/models/topping.rb</strong></p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> Topping <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span>
  has_many <span style="color:#ff3333; font-weight:bold;">:pizza_toppings</span>, <span style="color:#ff3333; font-weight:bold;">:dependent</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:destroy</span> 
  has_many <span style="color:#ff3333; font-weight:bold;">:pizzas</span>, <span style="color:#ff3333; font-weight:bold;">:trhough</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:pizza_toppings</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p><strong>app/models/pizza_topping.rb</strong></p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> PizzaTopping <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span>
  belongs_to <span style="color:#ff3333; font-weight:bold;">:Topping</span>
  belongs_to <span style="color:#ff3333; font-weight:bold;">:Pizza</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Nachdem die Beziehungen definiert sind können wir ohnen großen Aufwand die Beläge den Pizzen zuordnen:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#006600; font-weight:bold;">&lt;%</span> form_for <span style="color:#0066ff; font-weight:bold;">@pizza</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">-%&gt;</span>
  <span style="color:#006600; font-weight:bold;">&lt;%</span> Topping.<span style="color:#9900CC;">all</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>topping<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
    &lt;div&gt;
      <span style="color:#006600; font-weight:bold;">&lt;%</span>= check_box_tag <span style="color:#ff3333; font-weight:bold;">:topping_ids</span>, topping.<span style="color:#9900CC;">id</span>, <span style="color:#0000FF; font-weight:bold;">false</span>, <span style="color:#ff3333; font-weight:bold;">:name</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'pizza[topping_ids][]'</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
      <span style="color:#006600; font-weight:bold;">&lt;%</span>= label_tag <span style="color:#ff3333; font-weight:bold;">:topping_ids</span>, topping.<span style="color:#9900CC;">name</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
    &lt;/div&gt;
  <span style="color:#006600; font-weight:bold;">&lt;%</span> <span style="color:#9966CC; font-weight:bold;">end</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
  <span style="color:#006600; font-weight:bold;">&lt;%</span>= submit_tag <span style="color:#006600; font-weight:bold;">%&gt;</span>
<span style="color:#006600; font-weight:bold;">&lt;%</span> <span style="color:#9966CC; font-weight:bold;">end</span> <span style="color:#006600; font-weight:bold;">%&gt;</span></pre></div></div>

<p>Wenn das Formular abgeschickt wird, dann wird jeder ausgewählter Belag durch PizzaToppings mit der Pizza verknüpft. Sobald allerdings in einem gespeicherten Datensatz einmal alle Checkboxen abgewählt werden, dann wird das nicht an den Controller geposted. Dies kann man aber leicht im Controller fixen:</p>
<p><strong>app/controllers/pizza_controller.rb</strong></p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#0066ff; font-weight:bold;">@pizza</span>.<span style="color:#9900CC;">attributes</span> = <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#996600;">'topping_ids'</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#125;</span>.<span style="color:#9900CC;">merge</span><span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:pizza</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">||</span> <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.treibsand.com/2010/11/03/has_many-through-mit-checkboxen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iPhone Wecker verschläft Zeitumstellung</title>
		<link>http://www.treibsand.com/2010/11/02/iphone-wecker-verschlaft-zeitumstellung/</link>
		<comments>http://www.treibsand.com/2010/11/02/iphone-wecker-verschlaft-zeitumstellung/#comments</comments>
		<pubDate>Tue, 02 Nov 2010 09:07:38 +0000</pubDate>
		<dc:creator>Toast</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Bug]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://www.treibsand.com/?p=538</guid>
		<description><![CDATA[Irgendwie wurde ich heute doch schon etwas stutzig. Mein Wecker im iPhone hat mich nicht wie üblich um 6:30 Uhr geweckt, sonder erst um 7:30 Uhr. Na gut, evtl. habe ich ja aus Versehen die falsche Zeit eingestellt&#8230; Nein, hab ich nicht. Der Wecker war wirklich auf 6:30 Uhr gestellt. Nach der Umstellung auf die [...]]]></description>
			<content:encoded><![CDATA[<p>Irgendwie wurde ich heute doch schon etwas stutzig. Mein Wecker im iPhone hat mich nicht wie üblich um 6:30 Uhr geweckt, sonder erst um 7:30 Uhr. Na gut, evtl. habe ich ja aus Versehen die falsche Zeit eingestellt&#8230;<br />
<span id="more-538"></span></p>
<p>Nein, hab ich nicht. Der Wecker war wirklich auf 6:30 Uhr gestellt. Nach der Umstellung auf die Winterzeit hat das wohl den Wecker nicht mehr interessiert. Auf Golem habe ich heute auch gleich einen Artikel darüber gefunden. Scheinbar handelt es sich hier um einen Bug im iOS 4.1, der dafür sorgt, dass wiederholende Wecker Einstellungen eine Stunde zu spät starten. </p>
<p>Momentan gibt es dafür noch keinen Fix, man sollte wohl den Wecker eine Stunde früher einstellen. Im <a href="http://discussions.apple.com/thread.jspa?threadID=2633190&#038;tstart=0">Apple Support Forum</a> gibt es auch bereits eine Diskussion über den Bug.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.treibsand.com/2010/11/02/iphone-wecker-verschlaft-zeitumstellung/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iPhone 4 hat Probleme mit Bluetooth</title>
		<link>http://www.treibsand.com/2010/08/10/iphone-4-hat-probleme-mit-bluetooth/</link>
		<comments>http://www.treibsand.com/2010/08/10/iphone-4-hat-probleme-mit-bluetooth/#comments</comments>
		<pubDate>Tue, 10 Aug 2010 13:30:16 +0000</pubDate>
		<dc:creator>Toast</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Bluetooth]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://www.treibsand.com/?p=528</guid>
		<description><![CDATA[Ich habe mich richtig gefreut, als dieses Wochenende mein neues iPhone per DHL kam, zumal ich mich eigentlich noch darauf eingestellt hatte, dass die Lieferzeit 9 Wochen beträgt. Ich wurde nach 5 Tagen dann aber positiv überrascht. Momentan hört man ja ziemlich viel, dass das iPhone 4 starke Probleme mit der verbauten Antenne hat. Das [...]]]></description>
			<content:encoded><![CDATA[<p><img style="float: left;" title="what-is-bluetooth-technology-745447-200x200.png" src="http://www.treibsand.com/wp-content/uploads/2010/08/what-is-bluetooth-technology-745447-200x200.png" border="0" alt="Bluetooth" width="200" height="200" />Ich habe mich richtig gefreut, als dieses Wochenende mein neues iPhone per DHL kam, zumal ich mich eigentlich noch darauf eingestellt hatte, dass die Lieferzeit 9 Wochen beträgt. Ich wurde nach 5 Tagen dann aber positiv überrascht.</p>
<p>Momentan hört man ja ziemlich viel, dass das iPhone 4 starke Probleme mit der verbauten Antenne hat. Das kann ich überhaupt nicht nachvollziehen. Bei mir funktioniert der Empfang einwandfrei, auch wenn die entsprechende Stelle komplett von der Hand umschlossen ist.</p>
<p>Was mir allerdings recht schnell aufgefallen ist, ist dass mein Philips Stereo Bluetooth Headset nicht mehr funktioniert. Mit dem iPhone 3G hatte ich nie Probleme, auch mit iOS 4 nicht. Versuche ich allerdings das Neue mit dem Headset zu koppeln funktioniert es überhaupt nicht. Die Geräte können sich nicht finden. Wenn man danach bei Google sucht, findet man auch tatsächlich einige Leute, die genau das gleiche Problem haben.</p>
<p>Scheinbar ist die Bluetooth Implementierung in iOS4 mit dem iPhone 4 etwas wählerisch bzw. fehlerhaft geworden. So berichten mehrere Personen darüber, dass sich Headsets gar nicht koppeln lassen, die Audio Qualität sehr schlecht ist und die Bluetooth Verbindung wieder abbricht.</p>
<p>Hoffentlich gibt es bald ein iOS Update, mit welchem die Probleme behoben werden :-/</p>
]]></content:encoded>
			<wfw:commentRss>http://www.treibsand.com/2010/08/10/iphone-4-hat-probleme-mit-bluetooth/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Kleine C-Übung</title>
		<link>http://www.treibsand.com/2010/07/02/kleine-c-ubung/</link>
		<comments>http://www.treibsand.com/2010/07/02/kleine-c-ubung/#comments</comments>
		<pubDate>Fri, 02 Jul 2010 08:50:06 +0000</pubDate>
		<dc:creator>Toast</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[Fun]]></category>

		<guid isPermaLink="false">http://www.treibsand.com/?p=520</guid>
		<description><![CDATA[Heute hat mir ein Kollege einen kleinen C Quelltext geschickt und mich gebeten, das Ergebnis mal nachzuvollziehen, ohne dabei das Programm zu kompilieren. Ich muss sagen, beim ersten Anlauf hatte ich nicht alle Werte der Variablen richtig. Es gibt doch einige Fallstricke Aber versucht es mal selber! Was kommt raus? Und bitte nicht kompilieren&#8230; #include [...]]]></description>
			<content:encoded><![CDATA[<p>Heute hat mir ein Kollege einen kleinen C Quelltext geschickt und mich gebeten, das Ergebnis mal nachzuvollziehen, ohne dabei das Programm zu kompilieren. Ich muss sagen, beim ersten Anlauf hatte ich nicht alle Werte der Variablen richtig. Es gibt doch einige Fallstricke <img src='http://www.treibsand.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p><span id="more-520"></span></p>
<p>Aber versucht es mal selber! Was kommt raus? Und bitte <b>nicht</b> kompilieren&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include &lt;stdio.h&gt;</span>
&nbsp;
<span style="color: #993333;">int</span> func <span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> a<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> b<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #993333;">static</span> <span style="color: #993333;">int</span> c <span style="color: #339933;">=</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> a <span style="color: #339933;">+</span> b <span style="color: #339933;">*</span> <span style="color: #009900;">&#40;</span>c <span style="color: #339933;">*=</span> <span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">int</span> main <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #993333;">int</span> a <span style="color: #339933;">=</span> <span style="color: #0000dd;">2</span><span style="color: #339933;">,</span> b <span style="color: #339933;">=</span> <span style="color: #0000dd;">3</span><span style="color: #339933;">;</span>
	<span style="color: #993333;">int</span> c <span style="color: #339933;">=</span> func<span style="color: #009900;">&#40;</span>a<span style="color: #339933;">,</span> b<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	a <span style="color: #339933;">*=</span> a<span style="color: #339933;">++;</span>
	b <span style="color: #339933;">*=</span> <span style="color: #339933;">++</span>b<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%d %d %d %d<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> a<span style="color: #339933;">,</span> b<span style="color: #339933;">,</span> c<span style="color: #339933;">,</span> func<span style="color: #009900;">&#40;</span>a<span style="color: #339933;">,</span> b<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.treibsand.com/2010/07/02/kleine-c-ubung/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

