<?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>Andrey Butov</title>
	<atom:link href="http://www.andreybutov.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.andreybutov.com</link>
	<description></description>
	<lastBuildDate>Sun, 06 May 2012 19:22:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Ethan Tyler Butov</title>
		<link>http://www.andreybutov.com/2012/05/06/ethan-tyler-butov/</link>
		<comments>http://www.andreybutov.com/2012/05/06/ethan-tyler-butov/#comments</comments>
		<pubDate>Sun, 06 May 2012 19:22:13 +0000</pubDate>
		<dc:creator>Andrey Butov</dc:creator>
				<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://www.andreybutov.com/?p=1327</guid>
		<description><![CDATA[Just a few hours old.]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-1328" title="Ethan Tyler Butov" src="http://www.andreybutov.com/wp-content/uploads/2012/05/ethan_a_few_hours_old.png" alt="" width="600" height="800" /></p>
<p><strong>Just a few hours old.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.andreybutov.com/2012/05/06/ethan-tyler-butov/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hello World &#8230;</title>
		<link>http://www.andreybutov.com/2012/05/05/hello-world/</link>
		<comments>http://www.andreybutov.com/2012/05/05/hello-world/#comments</comments>
		<pubDate>Sun, 06 May 2012 03:16:14 +0000</pubDate>
		<dc:creator>Andrey Butov</dc:creator>
				<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://www.andreybutov.com/?p=1322</guid>
		<description><![CDATA[Ethan Tyler Butov came into this world on Friday, May 4th at 5:17 PM. Mom and baby are doing great and resting. I haven&#8217;t slept in about 50 hours.]]></description>
			<content:encoded><![CDATA[<p>Ethan Tyler Butov came into this world on Friday, May 4th at 5:17 PM. Mom and baby are doing great and resting. I haven&#8217;t slept in about 50 hours.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andreybutov.com/2012/05/05/hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Antair Nightstand for Android and the Kindle Fire</title>
		<link>http://www.andreybutov.com/2012/02/19/antair-nightstand-for-android-tablets/</link>
		<comments>http://www.andreybutov.com/2012/02/19/antair-nightstand-for-android-tablets/#comments</comments>
		<pubDate>Sun, 19 Feb 2012 17:45:18 +0000</pubDate>
		<dc:creator>Andrey Butov</dc:creator>
				<category><![CDATA[Amazon Kindle Fire]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Android Development]]></category>
		<category><![CDATA[Antair]]></category>

		<guid isPermaLink="false">http://www.andreybutov.com/?p=1304</guid>
		<description><![CDATA[Antair Nightstand is now available for Android tablets, and for the Amazon Kindle Fire.   ]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.antair.com/nightstand">Antair Nightstand</a> is now available for <a href="https://market.android.com/details?id=air.com.antair.android.nightstand">Android tablets</a>, and for the <a title="Antair Nightstand on the Amazon Kindle Fire" href="http://www.amazon.com/Antair-Nightstand-Alarm-Clock/dp/B007C88VPO">Amazon Kindle Fire</a>.</p>
<p><a href="https://market.android.com/details?id=air.com.antair.android.nightstand"><img class="alignnone size-full wp-image-1307" style="border-image: initial; border-width: 1px; border-color: black; border-style: solid;" title="Antair Nightstand on Android" src="http://www.andreybutov.com/wp-content/uploads/2012/02/android_nightstand_500w.png" alt="" width="500" height="212" /></a></p>
<p><a href="https://market.android.com/details?id=air.com.antair.android.nightstand"><img class="alignnone size-full wp-image-1306" style="border: none;" title="Antair Nightstand on Android" src="http://www.andreybutov.com/wp-content/uploads/2012/02/android_market_button.png" alt="" width="140" height="48" /></a>  <a href="http://www.amazon.com/Antair-Nightstand-Alarm-Clock/dp/B007C88VPO"><img class="alignnone size-full wp-image-1319" style="border:none;" title="Antair Nightstand on the Amazon Kindle Fire" src="http://www.andreybutov.com/wp-content/uploads/2012/02/amazon_app_store_48.png" alt="" width="48" height="48" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.andreybutov.com/2012/02/19/antair-nightstand-for-android-tablets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Antair Nightstand for your iPad</title>
		<link>http://www.andreybutov.com/2012/02/11/antair-nightstand-for-your-ipad/</link>
		<comments>http://www.andreybutov.com/2012/02/11/antair-nightstand-for-your-ipad/#comments</comments>
		<pubDate>Sat, 11 Feb 2012 06:57:11 +0000</pubDate>
		<dc:creator>Andrey Butov</dc:creator>
				<category><![CDATA[Antair]]></category>
		<category><![CDATA[iOS]]></category>

		<guid isPermaLink="false">http://www.andreybutov.com/?p=1294</guid>
		<description><![CDATA[Antair Nightstand, our popular alarm clock app for the BlackBerry PlayBook, is now available for the iPad.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.antair.com/nightstand">Antair Nightstand</a>, our popular alarm clock app for the BlackBerry PlayBook, is now available<a href="http://itunes.apple.com/us/app/antair-nightstand/id499601826?ls=1&amp;mt=8"> for the iPad</a>.</p>
<p><a href="http://itunes.apple.com/us/app/antair-nightstand/id499601826?ls=1&amp;mt=8"><img class="alignnone size-full wp-image-1295" style="border: none;" title="Antair Nightstand" src="http://www.andreybutov.com/wp-content/uploads/2012/02/animated_theme_pack_1.png" alt="" width="500" height="375" /></a></p>
<p><a href="http://itunes.apple.com/us/app/antair-nightstand/id499601826?ls=1&amp;mt=8"><img class="alignnone size-full wp-image-1296" style="border: none;" title="Antair Nightstand on the App Store" src="http://www.andreybutov.com/wp-content/uploads/2012/02/iosappstore2.png" alt="" width="192" height="66" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.andreybutov.com/2012/02/11/antair-nightstand-for-your-ipad/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pregnancy Food Guide on Android</title>
		<link>http://www.andreybutov.com/2011/12/17/pregnancy-food-guide-on-android/</link>
		<comments>http://www.andreybutov.com/2011/12/17/pregnancy-food-guide-on-android/#comments</comments>
		<pubDate>Sat, 17 Dec 2011 19:53:06 +0000</pubDate>
		<dc:creator>Andrey Butov</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Antair]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://www.andreybutov.com/?p=1284</guid>
		<description><![CDATA[Pregnancy Food Guide has been available for the iPhone for a short while now, and as of today, it&#8217;s also available for your Android phone.]]></description>
			<content:encoded><![CDATA[<p><strong>Pregnancy Food Guide</strong> has been available <a href="http://itunes.apple.com/us/app/pregnancy-food-guide/id472845598?ls=1&amp;mt=8">for the iPhone</a> for a short while now, and as of today, it&#8217;s also available <a href="https://market.android.com/details?id=com.antair.android.pregnancyfoodguide">for your Android phone</a>.</p>
<p><a href="https://market.android.com/details?id=com.antair.android.pregnancyfoodguide"><img class="alignnone size-full wp-image-1287" title="Pregnancy Food Guide for Android" src="http://www.andreybutov.com/wp-content/uploads/2011/12/screenshot_200_356.png" alt="" width="200" height="356" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.andreybutov.com/2011/12/17/pregnancy-food-guide-on-android/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The What Now? Podcast</title>
		<link>http://www.andreybutov.com/2011/12/16/the-what-now-podcast/</link>
		<comments>http://www.andreybutov.com/2011/12/16/the-what-now-podcast/#comments</comments>
		<pubDate>Fri, 16 Dec 2011 21:27:52 +0000</pubDate>
		<dc:creator>Andrey Butov</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.andreybutov.com/?p=1279</guid>
		<description><![CDATA[A long time ago, Gavin Bowman and I worked together at Antair. Gavin is now the co-founder of Retro Dreamer, where he makes awesome mobile games &#8230; and I&#8217;m still stuck here. Anyway, check out our new podcast, What Now?, where we talk about making a living by peddling mobile apps and games. &#160;]]></description>
			<content:encoded><![CDATA[<p>A long time ago, <a href="http://twitter.com/#!/GavinBowman">Gavin Bowman</a> and I worked together at <a href="http://www.antair.com">Antair</a>.</p>
<p>Gavin is now the co-founder of <a href="http://www.retrodreamer.com">Retro Dreamer</a>, where he makes awesome mobile games &#8230; and I&#8217;m still stuck here. <img src='http://www.andreybutov.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Anyway, check out our new podcast, <a href="http://www.whatnowpodcast.com">What Now?</a>, where we talk about making a living by peddling mobile apps and games.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andreybutov.com/2011/12/16/the-what-now-podcast/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Our latest app for the iPhone</title>
		<link>http://www.andreybutov.com/2011/11/16/our-latest-app-for-the-iphone/</link>
		<comments>http://www.andreybutov.com/2011/11/16/our-latest-app-for-the-iphone/#comments</comments>
		<pubDate>Wed, 16 Nov 2011 15:29:11 +0000</pubDate>
		<dc:creator>Andrey Butov</dc:creator>
				<category><![CDATA[Antair]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://www.andreybutov.com/?p=1265</guid>
		<description><![CDATA[I&#8217;d like to introduce the Pregnancy Food Guide, Antair&#8217;s latest app for the iPhone. &#160; Know what you can eat and what you can&#8217;t when you&#8217;re expecting. When shopping for food or eating at a restaurant, this handy and informative guide will help you make safe decisions for you and your baby. The application features [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;d like to introduce the <a href="http://itunes.apple.com/us/app/pregnancy-food-guide/id472845598?ls=1&amp;mt=8">Pregnancy Food Guide</a>, Antair&#8217;s latest app for the iPhone.</p>
<p><a href="http://itunes.apple.com/us/app/pregnancy-food-guide/id472845598?ls=1&amp;mt=8"><img class="alignnone size-full wp-image-1266" title="screenshot3_320_480" src="http://www.andreybutov.com/wp-content/uploads/2011/11/screenshot3_320_480.png" alt="" width="320" height="480" /></a></p>
<p>&nbsp;</p>
<p>Know what you can eat and what you can&#8217;t when you&#8217;re expecting.</p>
<p>When shopping for food or eating at a restaurant, this handy and informative guide will help you make safe decisions for you and your baby.</p>
<p>The application features hundreds of common foods, drinks, and ingredients, along with information on whether the food is safe to consume during pregnancy, and any related benefits or dangers.</p>
<p><a href="http://itunes.apple.com/us/app/pregnancy-food-guide/id472845598?ls=1&amp;mt=8"><img class="alignnone size-full wp-image-1267" style="border: none;" title="app-store" src="http://www.andreybutov.com/wp-content/uploads/2011/11/app-store.png" alt="" width="200" height="65" /></a></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andreybutov.com/2011/11/16/our-latest-app-for-the-iphone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to set up a faster Android emulator</title>
		<link>http://www.andreybutov.com/2011/10/14/how-to-set-up-a-faster-android-emulator/</link>
		<comments>http://www.andreybutov.com/2011/10/14/how-to-set-up-a-faster-android-emulator/#comments</comments>
		<pubDate>Sat, 15 Oct 2011 02:02:10 +0000</pubDate>
		<dc:creator>Andrey Butov</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Android Development]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.andreybutov.com/?p=1204</guid>
		<description><![CDATA[For certain projects, you may find that the default Android emulator is far too slow for accurate testing. In this guide, I will show you how to set up a faster alternative. I will be using Windows, but the tools are platform-agnostic, so you shouldn&#8217;t have trouble setting up a faster Android emulator on a [...]]]></description>
			<content:encoded><![CDATA[<p>For certain projects, you may find that the default Android emulator is far too slow for accurate testing.</p>
<p>In this guide, I will show you how to set up a faster alternative. I will be using Windows, but the tools are platform-agnostic, so you shouldn&#8217;t have trouble setting up a faster Android emulator on a Mac or a Linux box. I will also show you how to configure the resolution of the new Android emulator so you can emulate specific Android devices, such as the Amazon Kindle Fire.</p>
<p>&nbsp;</p>
<p><img class="alignnone size-full wp-image-1218" title="VirtualBox" src="http://www.andreybutov.com/wp-content/uploads/2011/10/virtualbox.png" alt="" width="400" height="191" /></p>
<p>First, download and install <a href="https://www.virtualbox.org/">VirtualBox</a>. We&#8217;ll be running our faster Android emulator as a virtual machine. You can probably use VMWare, or Parallels, but VirtualBox is available free of charge, and works perfectly well for our purposes.</p>
<p>&nbsp;</p>
<p><img class="alignnone size-full wp-image-1220" title="Android Images" src="http://www.andreybutov.com/wp-content/uploads/2011/10/androidimages.png" alt="" width="400" height="270" /></p>
<p>Now, download the <a href="http://code.google.com/p/androbox/downloads/list">Android image</a>. For this guide, I will be using Android 2.3 (Gingerbread). For that release, the matching download is <strong>android-x86.2.3-4th-test-110620.iso</strong>.</p>
<p>&nbsp;</p>
<p><img class="alignnone size-full wp-image-1222" title="New Virtual Machine" src="http://www.andreybutov.com/wp-content/uploads/2011/10/newmachine.png" alt="" width="400" height="299" /></p>
<p>Start VirtualBox and create a new virtual machine.</p>
<p>&nbsp;</p>
<p><img class="alignnone size-full wp-image-1223" title="Setting up a new Virtual Machine" src="http://www.andreybutov.com/wp-content/uploads/2011/10/vmname.png" alt="" width="400" height="297" /></p>
<p>Enter a name for your new virtual machine. Select <strong>Linux</strong> for the operating system, and <strong>Other Linux</strong> for the version.</p>
<p>&nbsp;</p>
<p><img class="alignnone size-full wp-image-1225" title="Virtual Machine Memory" src="http://www.andreybutov.com/wp-content/uploads/2011/10/memory.png" alt="" width="400" height="300" /></p>
<p>I want my Android emulator to run with 1 GB of RAM. You can choose whatever amount of memory is best for your needs.</p>
<p>&nbsp;</p>
<p><img class="alignnone size-full wp-image-1227" title="New Hard Disk" src="http://www.andreybutov.com/wp-content/uploads/2011/10/harddisk1.png" alt="" width="400" height="298" /></p>
<p>For Virtual Hard Disk, check <strong>Start-up Disk</strong>, and choose to <strong>Create a new hard disk</strong>.</p>
<p>&nbsp;</p>
<p><img class="alignnone size-full wp-image-1229" title="Type of Virtual Disk" src="http://www.andreybutov.com/wp-content/uploads/2011/10/vdi.png" alt="" width="400" height="299" /></p>
<p>Select <strong>VDI (VirtualBox Disk Image)</strong> for the type of virtual disk.</p>
<p>&nbsp;</p>
<p><img class="alignnone size-full wp-image-1231" title="Dynamically Allocated Storage" src="http://www.andreybutov.com/wp-content/uploads/2011/10/vdi2.png" alt="" width="400" height="299" /></p>
<p>Choose <strong>Dynamically Allocated</strong> storage.</p>
<p>&nbsp;</p>
<p><img class="alignnone size-full wp-image-1232" title="Disk Size" src="http://www.andreybutov.com/wp-content/uploads/2011/10/disksize.png" alt="" width="400" height="298" /></p>
<p>For disk size, I tend to allocate 512 MB. Feel free to allocate more or less disk space for your new emulator.</p>
<p>&nbsp;</p>
<p><img class="alignnone size-full wp-image-1233" title="New Machine Created" src="http://www.andreybutov.com/wp-content/uploads/2011/10/newmachine2.png" alt="" width="400" height="287" /></p>
<p>Once this is done, continue with the last few dialog boxes to create the new Android virtual machine.</p>
<p>&nbsp;</p>
<p><img class="alignnone size-full wp-image-1235" title="Virtual Machine Audio" src="http://www.andreybutov.com/wp-content/uploads/2011/10/sound.png" alt="" width="400" height="352" /></p>
<p>Click on <strong>Audio</strong>, and change the Audio Controller from ICH AC97, which doesn&#8217;t work very well with this setup, to <strong>SoundBlaster 16</strong>.</p>
<p>&nbsp;</p>
<p><img class="alignnone size-full wp-image-1236" title="Virtual Machine Network Settings" src="http://www.andreybutov.com/wp-content/uploads/2011/10/network.png" alt="" width="400" height="352" /></p>
<p>Click on <strong>Network</strong>, and change the setting to <strong>Host-only Adapter</strong>. Now, this bit is specific to your particular network configuration. Some folks claim that setting this to <strong>NAT</strong> or <strong>Bridged Adapter</strong> gives best results. Use whichever works best for your rig. I will proceed with <strong>Host-only Adapter</strong>.</p>
<p>&nbsp;</p>
<p><img class="alignnone size-full wp-image-1238" title="New CD or DVD device." src="http://www.andreybutov.com/wp-content/uploads/2011/10/cd.png" alt="" width="400" height="352" /></p>
<p>Click on <strong>Storage</strong>. Under Storage Tree, click on the icon to add a new CD/DVD device. When prompted, click on Choose Disk, and select the Android .iso image you downloaded earlier.</p>
<p>&nbsp;</p>
<p><img class="alignnone size-full wp-image-1240" title="" src="http://www.andreybutov.com/wp-content/uploads/2011/10/installtodisk.png" alt="" width="400" height="337" /></p>
<p>Start the new virtual machine. When prompted, choose <strong>Install Android-X86 to harddisk</strong>.</p>
<p>&nbsp;</p>
<p><img class="alignnone size-full wp-image-1242" title="Create a new partition" src="http://www.andreybutov.com/wp-content/uploads/2011/10/createpartition.png" alt="" width="400" height="257" /></p>
<p>When prompted to choose a partition, select <strong>Create/Modify partitions</strong>. In the cfdisk partition manager screen that follows, choose <strong>New</strong>, then <strong>Primary</strong>, and keep the default partition size. Toggle <strong>Bootable</strong>, and then proceed to <strong>Write</strong>. After the partition is created, choose <strong>Quit</strong> to exit cfdisk. Select the newly created partition, and choose <strong>ext3</strong> for the filesystem format. Select <strong>Yes</strong> when prompted to install the boot loader GRUB, and <strong>Yes</strong> to make the /system directory read-write. Installation should take just a few seconds.</p>
<p>After installation, close the virtual machine and remove the Android .iso CD/DVD in the <strong>Storage Settings</strong> before starting the virtual machine again.</p>
<p>&nbsp;</p>
<p><img class="alignnone size-full wp-image-1243" title="New Android Emulator" src="http://www.andreybutov.com/wp-content/uploads/2011/10/newandroid.png" alt="" width="400" height="332" /></p>
<p>When you start the new Android virtual machine, you&#8217;ll notice that you cannot use your mouse inside the Android OS. To fix this, choose <strong>Machine</strong> from the VirtualBox menu, and then choose to <strong>Disable Mouse Integration</strong>. You will now be able to use the mouse inside the Android OS. Take note of the <strong>host key</strong> used by your installation of VirtualBox. Without this host key, you won&#8217;t be able to get your mouse back out of the Android OS. I believe that the default host key used by VirtualBox on Windows is the right <strong>Control</strong> key, but this may be different in your installation. Click inside the Android virtual machine to bring your mouse into that environment. Click on the host key to get the mouse back out.</p>
<p>&nbsp;</p>
<p><img class="alignnone size-full wp-image-1246" title="IP Address" src="http://www.andreybutov.com/wp-content/uploads/2011/10/ip.png" alt="" width="400" height="111" /></p>
<p>To test your application in the new Android emulator from Eclipse, you&#8217;ll need to know the IP address of the virtual machine. Click <strong>ALT-F1</strong> to bring up the VirtualBox console, and type <strong>netcfg</strong> to display the IP address assigned to it. Take note of the IP address and click <strong>ALT-F7</strong> to get rid of the console.</p>
<p>You can now connect the Android Debug Bridge (<strong>adb</strong>) to the new virtual machine Android emulator. Bring up a command prompt window, and type <strong>adb connect 192.168.56.102</strong>. Of course, you&#8217;ll use the IP address of your virtual machine, which may be different. If your system can&#8217;t find <strong>adb.exe</strong>, add it to your environment PATH. You&#8217;ll find adb.exe in your Android SDK installation directory.</p>
<p>Now you can set up a new Run Configuration in Eclipse to test your application in the new Android emulator. When setting up a new <strong>Run Configuration</strong> in Eclipse, click on the <strong>Target</strong> tab, and select a <strong>Manual</strong> deployment target.</p>
<p>&nbsp;</p>
<p><img class="alignnone size-full wp-image-1249" title="Choose a Device" src="http://www.andreybutov.com/wp-content/uploads/2011/10/choosedevice.png" alt="" width="400" height="290" /></p>
<p>Once this is done, when you choose to Run your application from Eclipse, you&#8217;ll be presented with a dialog from which you can select the Android device on which to run your application. Since you connected adb to your new Android virtual machine, you should see the IP address of the virtual machine as one of the available devices on which to test.</p>
<p>&nbsp;</p>
<p><strong>Custom Resolutions</strong></p>
<p>What if you need to run the Android virtual machine with a custom resolution?</p>
<p>I&#8217;m going to configure my new emulator to look like the <strong>Amazon Kindle Fire</strong>, which has a DPI of 169 with a resolution of 1024 x 600.</p>
<p>First, in your VirtualBox, right click on your new virtual machine, and choose <strong>Show in Explorer</strong>. This will show you the location of the <strong>.vbox</strong> configuration file for the new VM. We&#8217;re going to edit this file, but first, we&#8217;ll need to close VirtualBox, and close our virtual machine, if it&#8217;s running.</p>
<p>Edit the <strong>.vbox</strong> file; it&#8217;s just an XML configuration file.</p>
<p>Find the <strong>ExtraData</strong> section, and add a line to it declaring your custom resolution:</p>
<pre>&lt;ExtraData&gt;
      &lt;ExtraDataItem name="GUI/LastCloseAction" value="powerOff"/&gt;
      &lt;ExtraDataItem name="GUI/LastGuestSizeHint" value="800,600"/&gt;
      &lt;ExtraDataItem name="GUI/LastNormalWindowPosition" value="998,300,800,639"/&gt;
      &lt;ExtraDataItem name="CustomVideoMode1" value="1024x600x16"/&gt;
&lt;/ExtraData&gt;</pre>
<p>&nbsp;</p>
<p>I added the <strong>CustomVideoMode1</strong> line above.</p>
<p>Save and close the configuration file.</p>
<p>&nbsp;</p>
<p><img class="alignnone size-full wp-image-1258" title="GRUB" src="http://www.andreybutov.com/wp-content/uploads/2011/10/grub.png" alt="" width="400" height="337" /></p>
<p>Now, start your virtual machine, and when you see the GRUB boot loader screen, choose <strong>Debug Mode</strong>.</p>
<p>&nbsp;</p>
<p><img class="alignnone size-full wp-image-1259" title="GRUB menu." src="http://www.andreybutov.com/wp-content/uploads/2011/10/grubmenu.png" alt="" width="400" height="256" /></p>
<p>At the command prompt that follows, type the command <strong>vi /mnt/grub/menu.lst</strong> to edit the GRUB boot menu file.</p>
<p>You should probably be familiar with the <strong>vi</strong> editor for this part. If you aren&#8217;t, find a quick tutorial to familiarize yourself with the basics.</p>
<p>Duplicate one of the existing entries in the file to create a new one, then change its title to something more meaningful, change its DPI parameter to 169 (that&#8217;s what we want from our Amazon Kindle Fire emulator), and add the parameter <strong>vga=ask</strong> to the end of the line.</p>
<p>Save, close the file, and restart the virtual machine.</p>
<p>&nbsp;</p>
<p><img class="alignnone size-full wp-image-1261" title="New GRUB menu item" src="http://www.andreybutov.com/wp-content/uploads/2011/10/newresolution.png" alt="" width="400" height="337" /></p>
<p>You will see the new boot entry as one of the menu items on the GRUB loading screen.</p>
<p>&nbsp;</p>
<p><img class="alignnone size-full wp-image-1260" title="Available resolutions" src="http://www.andreybutov.com/wp-content/uploads/2011/10/vga.png" alt="" width="400" height="257" /></p>
<p>When you select the new boot entry, you&#8217;ll be given the option to hit <strong>ENTER</strong> to see the available resolutions (you entered <strong>vga=ask</strong> in the GRUB configuration file, remember?). Your new entry, <strong>1024x600x16</strong>, will be one of the items.</p>
<p>&nbsp;</p>
<p><img class="alignnone size-full wp-image-1262" title="Android running at 1024x600" src="http://www.andreybutov.com/wp-content/uploads/2011/10/runningcustom.png" alt="" width="400" height="259" /></p>
<p>And here&#8217;s our new Android emulator running at a resolution of 1024&#215;600 and a DPI of 169 &#8212; all ready for you to test your Amazon Kindle Fire applications.</p>
<p>&nbsp;</p>
<p><strong>That&#8217;s all!</strong></p>
<p>That should be all. I&#8217;m sure you&#8217;ll find that the Android emulator running as a virtual machine is far more responsive that the standard emulator. Happy testing!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andreybutov.com/2011/10/14/how-to-set-up-a-faster-android-emulator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Help! My BlackBerry JDE won&#8217;t start anymore.</title>
		<link>http://www.andreybutov.com/2011/08/26/help-my-blackberry-jde-wont-start-anymore/</link>
		<comments>http://www.andreybutov.com/2011/08/26/help-my-blackberry-jde-wont-start-anymore/#comments</comments>
		<pubDate>Sat, 27 Aug 2011 03:57:26 +0000</pubDate>
		<dc:creator>Andrey Butov</dc:creator>
				<category><![CDATA[Antair]]></category>
		<category><![CDATA[BlackBerry]]></category>
		<category><![CDATA[BlackBerry Development]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.andreybutov.com/?p=1177</guid>
		<description><![CDATA[You&#8217;ve been writing BlackBerry applications and building your code with the BlackBerry JDE for some time now. Then, one day, you launch the JDE and it fails to open! What gives? I assume you&#8217;ve covered the basics &#8211; your system has the Java runtime environment set up, with all the Java-related environment variables set up [...]]]></description>
			<content:encoded><![CDATA[<p><strong>You&#8217;ve been writing BlackBerry applications and building your code with the BlackBerry JDE for some time now. Then, one day, you launch the JDE and it fails to open!</strong></p>
<p>What gives?</p>
<p>I assume you&#8217;ve covered the basics &#8211; your system has the Java runtime environment set up, with all the Java-related environment variables set up properly and pointing to the right places.</p>
<p><strong>Are you running on a 64-bit system?</strong></p>
<p>BlackBerry tools don&#8217;t play nice with 64-bit systems. Tools don&#8217;t run properly, simulators don&#8217;t simulate accurately (sometimes not at all). If you are running the BlackBerry dev tools on a 64-bit version of Windows, and start seeing weird behavior, all other things aside, this could be the cause.</p>
<p>At <a href="http://www.antair.com">Antair</a>, we run all of our BlackBerry tools on 32-bit Windows XP (virtual) machines. Until RIM updates their tools to support 64-bit systems (ha!), I suggest you set up a 32-bit rig for your BlackBerry dev work.</p>
<p><strong>I&#8217;m already running on a 32-bit system. The JDE just fails to open!</strong></p>
<p>OK. Maybe it&#8217;s a memory or configuration issue.</p>
<p>Let&#8217;s take a look at the batch file that launches the IDE. If you&#8217;re working with JDE 4.5, you&#8217;ll find the launcher batch file in</p>
<p><em><strong>&#8220;C:\Program Files\Research In Motion\BlackBerry JDE 4.5.0\bin&#8221;</strong></em></p>
<p>Take a look at the <strong>ide.bat</strong> file. The batch file launches the JDE with something like:</p>

<div class="wp_syntax"><div class="code"><pre class="vim" style="font-family:monospace;">start javaw <span style="color: #000000;">-</span>Xmx256M <span style="color: #000000;">-</span>DRIM_RUNTIME=<span style="color: #000000;">..</span>\lib <span style="color: #000000;">-</span>DRIM_BIN=<span style="color: #000000;">..</span>\bin <span style="color: #000000;">-</span>jar IDE<span style="color: #000000;">.</span>jar</pre></div></div>

<p>Open up the command prompt, go to the directory containing the <strong>ide.bat</strong> file, and run the launch command manually to see if any errors are thrown out to the console:</p>

<div class="wp_syntax"><div class="code"><pre class="vim" style="font-family:monospace;">javaw <span style="color: #000000;">-</span>Xmx256M <span style="color: #000000;">-</span>DRIM_RUNTIME=<span style="color: #000000;">..</span>\lib <span style="color: #000000;">-</span>DRIM_BIN=<span style="color: #000000;">..</span>\bin <span style="color: #000000;">-</span>jar IDE<span style="color: #000000;">.</span>jar</pre></div></div>

<p><em><strong></strong></em>If you get a clear error message,  you can take steps to address whatever the process was complaining about. In certain instances, you may get an error indicating that there isn&#8217;t enough memory provided to the process to launch the IDE. It can happen. But hey, memory is cheap, so let&#8217;s give it some more:</p>

<div class="wp_syntax"><div class="code"><pre class="vim" style="font-family:monospace;">javaw <span style="color: #000000;">-</span>Xmx1024M <span style="color: #000000;">-</span>DRIM_RUNTIME=<span style="color: #000000;">..</span>\lib <span style="color: #000000;">-</span>DRIM_BIN=<span style="color: #000000;">..</span>\bin <span style="color: #000000;">-</span>jar IDE<span style="color: #000000;">.</span>jar</pre></div></div>

<p>See if that fixes things. We&#8217;ve had instances where allowing the process to grab more memory fixes the entire &#8220;JDE not starting&#8221; issue.</p>
<p><strong>OK. 256, 1024, 2048, it doesn&#8217;t matter. I don&#8217;t see any error messages on the console, and the JDE still won&#8217;t start.</strong></p>
<p>You installed a simulator recently didn&#8217;t you? Admit it. You&#8217;re testing an existing application to see if it will run on a new BlackBerry device, and you just downloaded and installed one of those brand new simulators that RIM provides. Right?</p>
<p>This breaks JDEs. I don&#8217;t know why, but installing standalone simulators with existing JDEs on the system, sometimes breaks some of those JDEs.</p>
<p>To fix it, go into the same bin directory that contained the <strong>ide.bat</strong> file we&#8217;ve been messing with. In there, you&#8217;ll find a <strong>&#8220;Settings.rc&#8221;</strong> file.</p>
<p>Delete it. Or move it, to be safe. Then start the JDE.</p>
<p>It&#8217;ll start as a &#8220;newly installed&#8221; JDE, with the <em>samples</em> project open, and no customizations that you spent all that time setting up &#8230; but it<strong> will </strong>start.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andreybutov.com/2011/08/26/help-my-blackberry-jde-wont-start-anymore/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How do I find unused functions in my PHP project?</title>
		<link>http://www.andreybutov.com/2011/08/20/how-do-i-find-unused-functions-in-my-php-project/</link>
		<comments>http://www.andreybutov.com/2011/08/20/how-do-i-find-unused-functions-in-my-php-project/#comments</comments>
		<pubDate>Sat, 20 Aug 2011 16:46:48 +0000</pubDate>
		<dc:creator>Andrey Butov</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.andreybutov.com/?p=1140</guid>
		<description><![CDATA[Find unused functions and methods in a set of PHP files. USAGE: find_unused_functions.php &#60;root_directory&#62; NOTE: This is a &#8216;quick-n-dirty&#8217; approach to the problem. This script only performs a lexical pass over the files, and does not respect situations where different modules define identically named functions or methods. If you use an IDE for your PHP [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Find unused functions and methods in a set of PHP files.</strong></p>
<p>USAGE: <strong>find_unused_functions.php &lt;root_directory&gt;</strong></p>
<p>NOTE: This is a &#8216;quick-n-dirty&#8217; approach to the problem. This script only performs a lexical pass over the files, and does not respect situations where different modules define identically named functions or methods. If you use an IDE for your PHP development, it may offer a more comprehensive solution.</p>
<p>Requires PHP 5</p>
<p style="margin-top: 30px;">
Direct download: <a style="text-decoration: none; font-weight: bold;" href="http://www.andreybutov.com/wp-content/uploads/2011/08/find_unused_functions.zip">find_unused_functions.zip</a>
</p>
<p style="margin-top: 30px:">
Code:
</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">#!/usr/bin/php -f
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// ============================================================================</span>
<span style="color: #666666; font-style: italic;">//</span>
<span style="color: #666666; font-style: italic;">// find_unused_functions.php</span>
<span style="color: #666666; font-style: italic;">//</span>
<span style="color: #666666; font-style: italic;">// Find unused functions in a set of PHP files.</span>
<span style="color: #666666; font-style: italic;">// version 1.3 - 08/20/2011</span>
<span style="color: #666666; font-style: italic;">//</span>
<span style="color: #666666; font-style: italic;">// ============================================================================</span>
<span style="color: #666666; font-style: italic;">//</span>
<span style="color: #666666; font-style: italic;">// Copyright (c) 2011, Andrey Butov. All Rights Reserved.</span>
<span style="color: #666666; font-style: italic;">// This script is provided as is, without warranty of any kind.</span>
<span style="color: #666666; font-style: italic;">//</span>
<span style="color: #666666; font-style: italic;">// http://www.andreybutov.com</span>
<span style="color: #666666; font-style: italic;">//</span>
<span style="color: #666666; font-style: italic;">// ============================================================================</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// This may take a bit of memory...</span>
<span style="color: #990000;">ini_set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'memory_limit'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'2048M'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$argv</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> 
<span style="color: #009900;">&#123;</span>
	usage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$root_dir</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$argv</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #990000;">is_dir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$root_dir</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #339933;">!</span><span style="color: #990000;">is_readable</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$root_dir</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;ERROR: '<span style="color: #006699; font-weight: bold;">$root_dir</span>' is not a readable directory.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	usage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$files</span> <span style="color: #339933;">=</span> php_files<span style="color: #009900;">&#40;</span><span style="color: #000088;">$root_dir</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$tokenized</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$files</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span> <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;No PHP files found.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">exit</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$defined_functions</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$files</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$file</span> <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$tokens</span> <span style="color: #339933;">=</span> tokenize<span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$tokens</span> <span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// We retain the tokenized versions of each file,</span>
		<span style="color: #666666; font-style: italic;">// because we'll be using the tokens later to search</span>
		<span style="color: #666666; font-style: italic;">// for function 'uses', and we don't want to </span>
		<span style="color: #666666; font-style: italic;">// re-tokenize the same files again.</span>
&nbsp;
		<span style="color: #000088;">$tokenized</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$tokens</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span> <span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$tokens</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span> <span style="color: #339933;">++</span><span style="color: #000088;">$i</span> <span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$current_token</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$tokens</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$next_token</span> <span style="color: #339933;">=</span> safe_arr<span style="color: #009900;">&#40;</span><span style="color: #000088;">$tokens</span><span style="color: #339933;">,</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$current_token</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$next_token</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$next_token</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> safe_arr<span style="color: #009900;">&#40;</span><span style="color: #000088;">$current_token</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> T_FUNCTION <span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#123;</span>
					<span style="color: #666666; font-style: italic;">// Find the 'function' token, then try to grab the </span>
					<span style="color: #666666; font-style: italic;">// token that is the name of the function being defined.</span>
					<span style="color: #666666; font-style: italic;">// </span>
					<span style="color: #666666; font-style: italic;">// For every defined function, retain the file and line</span>
					<span style="color: #666666; font-style: italic;">// location where that function is defined. Since different</span>
					<span style="color: #666666; font-style: italic;">// modules can define a functions with the same name,</span>
					<span style="color: #666666; font-style: italic;">// we retain multiple definition locations for each function name.</span>
&nbsp;
					<span style="color: #000088;">$function_name</span> <span style="color: #339933;">=</span> safe_arr<span style="color: #009900;">&#40;</span><span style="color: #000088;">$next_token</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #000088;">$line</span> <span style="color: #339933;">=</span> safe_arr<span style="color: #009900;">&#40;</span><span style="color: #000088;">$next_token</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
					<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$function_name</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$line</span> <span style="color: #009900;">&#41;</span>
					<span style="color: #009900;">&#123;</span>
						<span style="color: #000088;">$function_name</span> <span style="color: #339933;">=</span> <span style="color: #990000;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$function_name</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$function_name</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;&quot;</span> <span style="color: #009900;">&#41;</span>
						<span style="color: #009900;">&#123;</span>
							<span style="color: #000088;">$defined_functions</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$function_name</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'file'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$file</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'line'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$line</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						<span style="color: #009900;">&#125;</span>
					<span style="color: #009900;">&#125;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// We now have a collection of defined functions and</span>
<span style="color: #666666; font-style: italic;">// their definition locations. Go through the tokens again, </span>
<span style="color: #666666; font-style: italic;">// and find 'uses' of the function names. </span>
&nbsp;
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$tokenized</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$file</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$tokens</span> <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$tokens</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$token</span> <span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$token</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> safe_arr<span style="color: #009900;">&#40;</span><span style="color: #000088;">$token</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> T_STRING <span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$function_name</span> <span style="color: #339933;">=</span> safe_arr<span style="color: #009900;">&#40;</span><span style="color: #000088;">$token</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$function_line</span> <span style="color: #339933;">=</span> safe_arr<span style="color: #009900;">&#40;</span><span style="color: #000088;">$token</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;;</span>
&nbsp;
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$function_name</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$function_line</span> <span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$locations_of_defined_function</span> <span style="color: #339933;">=</span> safe_arr<span style="color: #009900;">&#40;</span><span style="color: #000088;">$defined_functions</span><span style="color: #339933;">,</span> <span style="color: #000088;">$function_name</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$locations_of_defined_function</span> <span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$found_function_definition</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
					<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$locations_of_defined_function</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$location_of_defined_function</span> <span style="color: #009900;">&#41;</span>
					<span style="color: #009900;">&#123;</span>
						<span style="color: #000088;">$function_defined_in_file</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$location_of_defined_function</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'file'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
						<span style="color: #000088;">$function_defined_on_line</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$location_of_defined_function</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'line'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
						<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$function_defined_in_file</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$file</span> <span style="color: #339933;">&amp;&amp;</span> 
							 <span style="color: #000088;">$function_defined_on_line</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$function_line</span> <span style="color: #009900;">&#41;</span>
						<span style="color: #009900;">&#123;</span>
							<span style="color: #000088;">$found_function_definition</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
							<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
						<span style="color: #009900;">&#125;</span>
					<span style="color: #009900;">&#125;</span>
&nbsp;
					<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #000088;">$found_function_definition</span> <span style="color: #009900;">&#41;</span>
					<span style="color: #009900;">&#123;</span>
						<span style="color: #666666; font-style: italic;">// We found usage of the function name in a context</span>
						<span style="color: #666666; font-style: italic;">// that is not the definition of that function. </span>
						<span style="color: #666666; font-style: italic;">// Consider the function as 'used'.</span>
&nbsp;
						<span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$defined_functions</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$function_name</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
print_report<span style="color: #009900;">&#40;</span><span style="color: #000088;">$defined_functions</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
<span style="color: #990000;">exit</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">// ============================================================================</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> php_files<span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span><span style="color: #009900;">&#41;</span> 
<span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// Get a listing of all the .php files contained within the $path</span>
	<span style="color: #666666; font-style: italic;">// directory and its subdirectories.</span>
&nbsp;
	<span style="color: #000088;">$matches</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$folders</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">rtrim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">DIRECTORY_SEPARATOR</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$folder</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_shift</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$folders</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> 
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$matches</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_merge</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$matches</span><span style="color: #339933;">,</span> <span style="color: #990000;">glob</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$folder</span><span style="color: #339933;">.</span><span style="color: #009900; font-weight: bold;">DIRECTORY_SEPARATOR</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;*.php&quot;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$moreFolders</span> <span style="color: #339933;">=</span> <span style="color: #990000;">glob</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$folder</span><span style="color: #339933;">.</span><span style="color: #009900; font-weight: bold;">DIRECTORY_SEPARATOR</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'*'</span><span style="color: #339933;">,</span> GLOB_ONLYDIR<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$folders</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_merge</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$folders</span><span style="color: #339933;">,</span> <span style="color: #000088;">$moreFolders</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$matches</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// ============================================================================</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> safe_arr<span style="color: #009900;">&#40;</span><span style="color: #000088;">$arr</span><span style="color: #339933;">,</span> <span style="color: #000088;">$i</span><span style="color: #339933;">,</span> <span style="color: #000088;">$default</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$arr</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #000088;">$arr</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$default</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// ============================================================================</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> tokenize<span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$file_contents</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #000088;">$file_contents</span> <span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000088;">$tokens</span> <span style="color: #339933;">=</span> <span style="color: #990000;">token_get_all</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file_contents</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$tokens</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$tokens</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> ? <span style="color: #000088;">$tokens</span> <span style="color: #339933;">:</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// ============================================================================</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> usage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$argv</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$argv</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #990000;">basename</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$argv</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;find_unused_functions.php&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;USAGE: <span style="color: #006699; font-weight: bold;">$file</span> &lt;root_directory&gt;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// ============================================================================</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> print_report<span style="color: #009900;">&#40;</span><span style="color: #000088;">$unused_functions</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$unused_functions</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span> <span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;No unused functions found.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000088;">$count</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$unused_functions</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$function</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$locations</span> <span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$locations</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$location</span> <span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;'<span style="color: #006699; font-weight: bold;">$function</span>' in <span style="color: #006699; font-weight: bold;">{$location['file']}</span> on line <span style="color: #006699; font-weight: bold;">{$location['line']}</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$count</span><span style="color: #339933;">++;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;=======================================<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Found <span style="color: #006699; font-weight: bold;">$count</span> unused function&quot;</span> <span style="color: #339933;">.</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$count</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">''</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">'s'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;.<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// ============================================================================</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* EOF */</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.andreybutov.com/2011/08/20/how-do-i-find-unused-functions-in-my-php-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

