<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: tiger code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sat, 17 May 2008 09:19:58 GMT</pubDate>
    <description>DZone Snippets: tiger code</description>
    <item>
      <title>Handy Iterable for a range of Integers</title>
      <link>http://snippets.dzone.com/posts/show/3792</link>
      <description>Looping a specific number of times produces code a bit too verbose in Java.  The JDK5 enhanced for statement is a handy improvement, but you still have to fall back to the traditional for statement if you want to repeat a loop, say, 10 times.&lt;br /&gt;&lt;br /&gt;Not with this implementation of Iterable.  You can use it like this:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;for (int i : new Range(100))&lt;br /&gt;    System.out.printf("I have said this %d times. Read dzone.com!%n", i);&lt;br /&gt;&lt;br /&gt;class Range implements Iterable&lt;Integer&gt; {&lt;br /&gt;    &lt;br /&gt;    private final Integer stop;&lt;br /&gt;    &lt;br /&gt;    public Range(int stop) {&lt;br /&gt;        this.stop = stop;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public Iterator&lt;Integer&gt; iterator() {&lt;br /&gt;        return new Iterator&lt;Integer&gt;() {&lt;br /&gt;            &lt;br /&gt;            private Integer counter = 0;&lt;br /&gt;&lt;br /&gt;            public boolean hasNext() {&lt;br /&gt;                return (counter != stop);&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            public Integer next() {&lt;br /&gt;                if (counter == stop)&lt;br /&gt;                    throw new NoSuchElementException();&lt;br /&gt;                return ++counter;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            public void remove() {&lt;br /&gt;            }};&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 10 Apr 2007 14:39:26 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3792</guid>
      <author>asgeirn (Asgeir S. Nilsen)</author>
    </item>
    <item>
      <title>How to create a RAM disk on OS X</title>
      <link>http://snippets.dzone.com/posts/show/1808</link>
      <description>32768 = size in sectors (16MB in this case, a sector is 512 bytes)&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;$ hdid -nomount ram://32768&lt;br /&gt;/dev/disk1&lt;br /&gt;$ newfs_hfs /dev/disk1&lt;br /&gt;$ mkdir /tmp/ramdisk1&lt;br /&gt;$ mount -t hfs /dev/disk1 /tmp/ramdisk1&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;To unmount:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;hdiutil detach /dev/disk1&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 30 Mar 2006 21:25:22 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1808</guid>
      <author>peter (Peter Cooperx)</author>
    </item>
    <item>
      <title>Clear DNS lookup / IP address cache on OS X Tiger</title>
      <link>http://snippets.dzone.com/posts/show/598</link>
      <description>&lt;code&gt;lookupd -flushcache&lt;/code&gt;</description>
      <pubDate>Thu, 25 Aug 2005 06:37:15 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/598</guid>
      <author>peter (Peter Cooperx)</author>
    </item>
    <item>
      <title>Change OS X's default screenshot image format</title>
      <link>http://snippets.dzone.com/posts/show/471</link>
      <description>At the prompt, type this:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;defaults write com.apple.screencapture type image_format&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Replace "image_format" with a file format name, like pdf, png, tiff, etc. Then to take screenshots, Cmd+Shift+4, then drag around the area you want to capture.</description>
      <pubDate>Fri, 08 Jul 2005 23:59:18 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/471</guid>
      <author>peter (Peter Cooperx)</author>
    </item>
    <item>
      <title>MySQL Launchd item for Mac OS X Tiger</title>
      <link>http://snippets.dzone.com/posts/show/369</link>
      <description>(Originally posted at &lt;a href="http://blog.unquiet.net/archives/2005/05/19/launchd-item-for-mysql/"&gt;Unquiet&lt;/a&gt;)&lt;br /&gt;&lt;br /&gt;I had to reinstall Mysql because it wasn&#226;&#8364;&#8482;t one of the things I backed up before erasing my hard drive. Since I&#226;&#8364;&#8482;m now running Mac OS X 10.4 &#226;&#8364;&#339;Tiger&#226;&#8364;?, I decided to set it up to start when the system boots, but the system for creating startup items has changed slightly. So I saved the following xml in &lt;strong&gt;/Library/LaunchDaemons/com.mysql.Mysql.plist&lt;/strong&gt;:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;br /&gt;    &lt;!DOCTYPE plist PUBLIC &lt;br /&gt;         "-//Apple Computer//DTD PLIST 1.0//EN" "&lt;br /&gt;        http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;&lt;br /&gt;    &lt;plist version="1.0"&gt;&lt;br /&gt;    &lt;dict&gt;&lt;br /&gt;        &lt;key&gt;Label&lt;/key&gt;&lt;br /&gt;        &lt;string&gt;com.mysql.Mysql&lt;/string&gt;&lt;br /&gt;        &lt;key&gt;OnDemand&lt;/key&gt;&lt;br /&gt;        &lt;false/&gt;&lt;br /&gt;        &lt;key&gt;ProgramArguments&lt;/key&gt;&lt;br /&gt;        &lt;array&gt;&lt;br /&gt;                &lt;string&gt;/usr/local/mysql/bin/mysqld_safe&lt;/string&gt;&lt;br /&gt;        &lt;/array&gt;&lt;br /&gt;        &lt;key&gt;ServiceDescription&lt;/key&gt;&lt;br /&gt;        &lt;string&gt;Mysql 4.1 Database Server&lt;/string&gt;&lt;br /&gt;        &lt;key&gt;UserName&lt;/key&gt;&lt;br /&gt;        &lt;string&gt;mysql&lt;/string&gt;&lt;br /&gt;        &lt;key&gt;WorkingDirectory&lt;/key&gt;&lt;br /&gt;        &lt;string&gt;/usr/local/mysql&lt;/string&gt;&lt;br /&gt;    &lt;/dict&gt;&lt;br /&gt;    &lt;/plist&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Note that I'm using the official OSX distribution of MySQL... but with a few changes to match your database location, you can get this to work with other installs (fink, darwinports, etc).</description>
      <pubDate>Tue, 07 Jun 2005 16:14:06 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/369</guid>
      <author>jstetser (Jake Stetser)</author>
    </item>
  </channel>
</rss>
