<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: Eddiewould's Code Snippets</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sun, 27 Jul 2008 00:28:03 GMT</pubDate>
    <description>DZone Snippets: Eddiewould's Code Snippets</description>
    <item>
      <title>Simulating a foreign key constraint in ActiveRecord (Ruby on Rails)</title>
      <link>http://snippets.dzone.com/posts/show/3400</link>
      <description>Say for example we have products and a business rule that every product must have a category. Before ActiveRecord we would have done this with a NOT NULL foreign key constraint at the database level. &lt;br /&gt;&lt;br /&gt;It wasn't entirely obvious (to me) how to achieve this in an ActiveRecord model - you need *both* of the following two lines:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;  validates_presence_of :category, :message =&gt; " must be specified" &lt;br /&gt;  validates_associated :category&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Hope this helps someone. </description>
      <pubDate>Thu, 01 Feb 2007 00:55:54 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3400</guid>
      <author>eddiewould (Eddie)</author>
    </item>
    <item>
      <title>Xorg.conf file for Acer C300 Notebook/Tablet (Dual head support with 1280x1024)</title>
      <link>http://snippets.dzone.com/posts/show/3245</link>
      <description>Supports 1280x1024 on a second screen as well as 1024x768 on main LCD. The following two lines are particularly important: &lt;br /&gt;       Option	  "DDC"		"0"&lt;br /&gt;       Option	  "VBERestore"  "0"&lt;br /&gt;Without them, the setup breaks unless you wait for X to start before plugging in the external monitor.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;Section "Device"&lt;br /&gt;       Identifier  "Videocard0"&lt;br /&gt;       Driver      "i810"&lt;br /&gt;       VendorName  "Videocard vendor"&lt;br /&gt;       BoardName   "Intel Corporation 82852/855GM Integrated Graphics Device"&lt;br /&gt;       BusID       "PCI:0:2:0"&lt;br /&gt;       Screen      0&lt;br /&gt;      Option      "MonitorLayout" "CRT,LFP"&lt;br /&gt;       Option      "AGPMode"      "0"&lt;br /&gt;       VideoRam    32768&lt;br /&gt;       Option	  "DDC"		"0"&lt;br /&gt;       Option	  "VBERestore"  "0"&lt;br /&gt;EndSection&lt;br /&gt;Section "Device"&lt;br /&gt;       Identifier  "Videocard1"&lt;br /&gt;       Driver      "i810"&lt;br /&gt;       VendorName  "Videocard vendor"&lt;br /&gt;       BoardName   "Intel Corporation 82852/855GM Integrated Graphics Device"&lt;br /&gt;       BusID       "PCI:0:2:0"&lt;br /&gt;       Screen      1&lt;br /&gt;       Option      "MonitorLayout" "CRT,LFP"&lt;br /&gt;       Option      "AGPMode"      "0"&lt;br /&gt;       VideoRam    32768&lt;br /&gt;       Option	  "DDC"		"0"&lt;br /&gt;       Option	  "VBERestore"  "0"&lt;br /&gt;EndSection&lt;br /&gt;Section "Monitor"&lt;br /&gt;       Identifier  "Laptop LCD"&lt;br /&gt;       Option      "DPMS"&lt;br /&gt;       HorizSync   30-81	&lt;br /&gt;       VertRefresh 56-75&lt;br /&gt;EndSection&lt;br /&gt;Section "Monitor"&lt;br /&gt;       Identifier  "Desktop CRT"&lt;br /&gt;       Option      "DPMS"&lt;br /&gt;       HorizSync   30-81&lt;br /&gt;       VertRefresh 56-75&lt;br /&gt;EndSection&lt;br /&gt;Section "Screen"&lt;br /&gt;         Identifier      "Screen0"&lt;br /&gt;         Device           "Videocard0"&lt;br /&gt;         Monitor           "Laptop LCD"&lt;br /&gt;         DefaultDepth      24&lt;br /&gt;         SubSection "Display"&lt;br /&gt;               Depth           24&lt;br /&gt;               Modes           "1024x768"&lt;br /&gt;         EndSubSection&lt;br /&gt;EndSection&lt;br /&gt;Section "Screen"&lt;br /&gt;         Identifier          "Screen1"&lt;br /&gt;         Device                "Videocard1"&lt;br /&gt;         Monitor               "Desktop CRT"&lt;br /&gt;         DefaultDepth      24&lt;br /&gt;         SubSection "Display"&lt;br /&gt;               Depth           24&lt;br /&gt;               Modes           "1280x1024"&lt;br /&gt;         EndSubSection&lt;br /&gt;EndSection&lt;br /&gt;Section "ServerLayout"&lt;br /&gt;       Identifier      "DefaultLayout"&lt;br /&gt;       Screen          0 "Screen0" 0 0&lt;br /&gt;       Screen          1 "Screen1" LeftOf "Screen0"&lt;br /&gt;       InputDevice	"Generic Keyboard"&lt;br /&gt;       InputDevice	"Configured Mouse"&lt;br /&gt;       InputDevice	"Synaptics Touchpad"	&lt;br /&gt;       Option          "Xinerama"&lt;br /&gt;       Option          "Clone"    "Off"&lt;br /&gt;EndSection&lt;br /&gt;&lt;br /&gt;Section "DRI"&lt;br /&gt;	Mode 0666&lt;br /&gt;EndSection&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 05 Jan 2007 11:37:06 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3245</guid>
      <author>eddiewould (Eddie)</author>
    </item>
    <item>
      <title>Create an regexp (Regular expression) from an array of Strings</title>
      <link>http://snippets.dzone.com/posts/show/3167</link>
      <description>// description of your code here&lt;br /&gt;Create a DNF regular expression from an array of strings even if they have special characters. &lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;Regexp.new(array.collect{|string| Regexp.escape(string)}.join("|"))&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 19 Dec 2006 12:36:07 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3167</guid>
      <author>eddiewould (Eddie)</author>
    </item>
  </channel>
</rss>
