<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Shiki</title>
	
	<link>http://shikii.net/blog</link>
	<description>I'm so bad with words that I can't even make a cool tagline</description>
	<lastBuildDate>Wed, 28 Mar 2012 23:37:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/shikii/OfdV" /><feedburner:info uri="shikii/ofdv" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Offline maps in iOS using OpenStreetMap and Route-Me</title>
		<link>http://feedproxy.google.com/~r/shikii/OfdV/~3/6yuk_VQ1Ibg/</link>
		<comments>http://shikii.net/blog/offline-maps-in-ios-using-openstreetmap-and-route-me/#comments</comments>
		<pubDate>Sat, 24 Mar 2012 06:33:55 +0000</pubDate>
		<dc:creator>Shiki</dc:creator>
				<category><![CDATA[Mobile Development]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[ios]]></category>
		<category><![CDATA[map]]></category>
		<category><![CDATA[offline]]></category>
		<category><![CDATA[openstreetmap]]></category>
		<category><![CDATA[route-me]]></category>
		<category><![CDATA[sqlite]]></category>

		<guid isPermaLink="false">http://shikii.net/blog/?p=620</guid>
		<description><![CDATA[This tutorial is heavily based on Rupert&#8217;s article here. However, the steps in this article are very different on some points. There are some steps that I had to figure out using other sources. Generating OpenStreetMap tiles database We&#8217;re going to use downloadosmtiles.pl to download OSM tiles for a specific region. Download, compile, and install [...]]]></description>
			<content:encoded><![CDATA[<p>This tutorial is heavily based on Rupert&#8217;s article <a href="http://www.gisnotes.com/wordpress/2010/08/iphone-dev-note-21-route-me-offline-mapping-from-database/">here</a>. However, the steps in this article are very different on some points. There are some steps that I had to figure out using other sources.</p>

<h2>Generating OpenStreetMap tiles database</h2>

<p>We&#8217;re going to use <a href="http://search.cpan.org/~rotkraut/Geo-OSM-Tiles-0.04/downloadosmtiles.pl"><code>downloadosmtiles.pl</code></a> to download OSM tiles for a specific region.</p>

<ol>
<li><p>Download, compile, and install <a href="http://search.cpan.org/~rotkraut/Geo-OSM-Tiles-0.04/">GEO-OSM-Tiles 0.04</a>. In Terminal:</p>

<pre><code>wget http://search.cpan.org/CPAN/authors/id/R/RO/ROTKRAUT/Geo-OSM-Tiles-0.04.tar.gz
tar -xf Geo-OSM-Tiles-0.04.tar.gz
cd Geo-OSM-Tiles-0.04

perl Makefile.PL # make sure there are no errors/warnings
make
make test
make install # you might have to use sudo
</code></pre>

<p>If you get errors like this on <code>Makefile.PL</code>: &#8220;<code>Warning: prerequisite YAML 0 not found.</code>&#8220;, install the missing Perl libraries first before continuing.</p></li>
<li><p>Determine the region you want to download. You can use OSM: go to <a href="http://openstreetmap.org">http://openstreetmap.org</a> and select <strong>Export</strong> from the top menu. You should be able to see 4 fields specifying the selected region coordinates. Click on <strong>Manually select a different area</strong> to define your own region.</p>

<p><img src="http://shikii.net/blog/wp-content/uploads/2012/03/offlinemap-osm.jpg" alt="" title="" width="747" height="486" class="aligncenter size-full wp-image-621" /></p></li>
<li><p>Execute <code>downloadosmtiles.pl</code> with the coordinates and your desired zoom levels to download the tiles:</p>

<pre><code>downloadosmtiles.pl --lat=0.871:1.79 --long=103.342:104.3 --zoom=0:15 --destdir=/your/tiles/folder
</code></pre>

<p>When specifying values for <code>lat</code> and <code>long</code>, enter the lowest value first. Call <code>downloadosmtiles.pl help</code> to see more options.</p>

<p>The destination folder should now contain image files organized like this:</p>

<p><img src="http://shikii.net/blog/wp-content/uploads/2012/03/offlinemap-folder.jpg" alt="" title="" width="273" height="418" class="aligncenter size-full wp-image-622" /></p></li>
<li><p>Download and run <code>map2sqlite</code> to convert the tile set to a sqlite database. You can download the source <a href="https://github.com/InfiniteDroplets/iOS-OfflineMaps-Example/downloads">here</a> and compile it in XCode. Or you can download the compiled binary <a href="http://shikii.net/blog/downloads/map2sqlite-bin.zip">here</a>. We&#8217;ll use the compiled binary in this example.</p>

<pre><code>wget http://shikii.net/blog/downloads/map2sqlite-bin.zip
tar -xf map2sqlite-bin.zip

./map2sqlite -db /your/mymap.sqlite -mapdir /your/tiles/folder
</code></pre></li>
</ol>

<h2>Using the offline map in Route-Me</h2>

<p>For a quick example, we&#8217;ll use a sample project included in <a href="https://github.com/route-me/route-me">route-me</a>.</p>

<ol>
<li>Download and extract the latest route-me library from GitHub: <a href="https://github.com/route-me/route-me">https://github.com/route-me/route-me</a></li>
<li>Open the sample project at <code>samples/SimpleMap/SimpleMap.xcodeproj</code>. Select the <code>SimpleMap</code> scheme and test to make sure it runs before we do anything to it.</li>
<li><p>Add the map database you just created to the project&#8217;s resources. Make sure that it is also added to the <em>Copy Bundle Resources</em>.</p>

<p><img src="http://shikii.net/blog/wp-content/uploads/2012/03/offlinemap-xcode.jpg" alt="" title="" width="797" height="388" class="aligncenter size-full wp-image-623" /></p></li>
<li><p>In <code>MapViewViewController.m</code>, add an import for <code>RMDBMapSource.h</code>.</p></li>
<li><p>Add this to the bottom of <code>-viewDidLoad</code> of <code>MapViewViewController.m</code>:</p>

<pre><code>// Use the bundled database as our map source
RMDBMapSource *mapSrc = [[[RMDBMapSource alloc] initWithPath:@"mymap.sqlite"] autorelease];
[[[RMMapContents alloc] initWithView:mapView tilesource:mapSrc] autorelease];

// Constrain our map so the user can only browse through our exported map tiles
[mapView setConstraintsSW:CLLocationCoordinate2DMake(mapSrc.bottomRightOfCoverage.latitude, mapSrc.topLeftOfCoverage.longitude)
                       NE:CLLocationCoordinate2DMake(mapSrc.topLeftOfCoverage.latitude, mapSrc.bottomRightOfCoverage.longitude)];
// Move to the center of our exported map
[mapView moveToLatLong:mapSrc.centerOfCoverage];
</code></pre>

<p>The first 2 lines instruct the map view (<code>RMMapView</code>) to use the offline map as the map source. The <code>-setConstraintsSW:NE</code> call is not necessary but I think it&#8217;s a good idea to only show the map region that we have exported. The user will see empty gray spaces for regions that we don&#8217;t have map tiles for without the constraints.</p></li>
</ol>

<p>And we&#8217;re done!</p>

<p><img src="http://shikii.net/blog/wp-content/uploads/2012/03/offlinemap-output.jpg" alt="" title="" width="330" height="489" class="aligncenter size-full wp-image-624" /></p>
<img src="http://feeds.feedburner.com/~r/shikii/OfdV/~4/6yuk_VQ1Ibg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://shikii.net/blog/offline-maps-in-ios-using-openstreetmap-and-route-me/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		<feedburner:origLink>http://shikii.net/blog/offline-maps-in-ios-using-openstreetmap-and-route-me/</feedburner:origLink></item>
		<item>
		<title>Android Button background image pressed/highlighted and disabled states without using multiple images</title>
		<link>http://feedproxy.google.com/~r/shikii/OfdV/~3/fwMu7Y20NAE/</link>
		<comments>http://shikii.net/blog/android-button-background-image-pressedhighlighted-and-disabled-states-without-using-multiple-images/#comments</comments>
		<pubDate>Sat, 17 Mar 2012 14:01:22 +0000</pubDate>
		<dc:creator>Shiki</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Mobile Development]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[button]]></category>
		<category><![CDATA[disabled]]></category>
		<category><![CDATA[drawable]]></category>
		<category><![CDATA[focused]]></category>
		<category><![CDATA[highlighted]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[pressed]]></category>
		<category><![CDATA[states]]></category>

		<guid isPermaLink="false">http://shikii.net/blog/?p=613</guid>
		<description><![CDATA[In Android, if you provide custom background images for buttons, you will lose the pressed and disabled image effects. The common way to fix that is to provide additional images for those states. I&#8217;m lazy and I find this inconvenient especially during the prototyping phase of app development. I&#8217;ve always liked the way iOS automatically [...]]]></description>
			<content:encoded><![CDATA[<p>In Android, if you provide custom background images for buttons, you will lose the pressed and disabled image effects. The common way to fix that is to provide additional images for those states. I&#8217;m lazy and I find this inconvenient especially during the prototyping phase of app development.</p>

<p>I&#8217;ve always liked the way iOS automatically handles pressed and disabled states for custom button backgrounds so I made a <code>Button</code> subclass that automatically darkens the background image when the button is pressed, and makes the background transparent when it is disabled. This is done by using a custom <a href="http://developer.android.com/reference/android/graphics/drawable/LayerDrawable.html"><code>LayerDrawable</code></a> for the button that contains the original background <code>Drawable</code>. The <code>LayerDrawable</code> has to be <a href="http://developer.android.com/reference/android/graphics/drawable/LayerDrawable.html#isStateful()">stateful</a> and should change the background properties depending on the current state in <a href="http://developer.android.com/reference/android/graphics/drawable/LayerDrawable.html#onStateChange(int[])"><code>onStateChange()</code></a>. The full source explains it better:</p>

<pre><code>package net.shikii.widgets;

import android.content.Context;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.LightingColorFilter;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.util.AttributeSet;
import android.widget.Button;

/**
 * Applies a pressed state color filter or disabled state alpha for the button's background
 * drawable.
 *
 * @author shiki
 */
public class SAutoBgButton extends Button {

  public SAutoBgButton(Context context) {
    super(context);
  }

  public SAutoBgButton(Context context, AttributeSet attrs) {
    super(context, attrs);
  }

  public SAutoBgButton(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
  }

  @Override
  public void setBackgroundDrawable(Drawable d) {
    // Replace the original background drawable (e.g. image) with a LayerDrawable that
    // contains the original drawable.
    SAutoBgButtonBackgroundDrawable layer = new SAutoBgButtonBackgroundDrawable(d);
    super.setBackgroundDrawable(layer);
  }

  /**
   * The stateful LayerDrawable used by this button.
   */
  protected class SAutoBgButtonBackgroundDrawable extends LayerDrawable {

    // The color filter to apply when the button is pressed
    protected ColorFilter _pressedFilter = new LightingColorFilter(Color.LTGRAY, 1);
    // Alpha value when the button is disabled
    protected int _disabledAlpha = 100;

    public SAutoBgButtonBackgroundDrawable(Drawable d) {
      super(new Drawable[] { d });
    }

    @Override
    protected boolean onStateChange(int[] states) {
      boolean enabled = false;
      boolean pressed = false;

      for (int state : states) {
        if (state == android.R.attr.state_enabled)
          enabled = true;
        else if (state == android.R.attr.state_pressed)
          pressed = true;
      }

      mutate();
      if (enabled &amp;&amp; pressed) {
        setColorFilter(_pressedFilter);
      } else if (!enabled) {
        setColorFilter(null);
        setAlpha(_disabledAlpha);
      } else {
        setColorFilter(null);
      }

      invalidateSelf();

      return super.onStateChange(states);
    }

    @Override
    public boolean isStateful() {
      return true;
    }
  }

}
</code></pre>

<p>To use this, just replace your original button declarations like this:</p>

<pre><code>&lt;Button
  android:layout_width="wrap_content" android:layout_height="wrap_content"
  android:background="@drawable/button_blue_bg"
  android:text="Button with background image" /&gt;
</code></pre>

<p>To this:</p>

<pre><code>&lt;net.shikii.widgets.SAutoBgButton
  android:layout_width="wrap_content" android:layout_height="wrap_content"
  android:background="@drawable/button_blue_bg"
  android:text="Button with background image" /&gt;
</code></pre>

<p>Here&#8217;s a sample output using this custom button:</p>

<p style="text-align: center;">
<img src="http://shikii.net/blog/wp-content/uploads/2012/03/android-autobgbutton-screen.jpg" alt="" title="android-autobgbutton-screen" width="348" height="506" class="aligncenter size-full wp-image-614" />
</p>

<p>The code is also available on <a href="https://github.com/shiki/android-autobgbutton">GitHub</a>.</p>
<img src="http://feeds.feedburner.com/~r/shikii/OfdV/~4/fwMu7Y20NAE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://shikii.net/blog/android-button-background-image-pressedhighlighted-and-disabled-states-without-using-multiple-images/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://shikii.net/blog/android-button-background-image-pressedhighlighted-and-disabled-states-without-using-multiple-images/</feedburner:origLink></item>
		<item>
		<title>Removing extra separator lines for empty rows in UITableView</title>
		<link>http://feedproxy.google.com/~r/shikii/OfdV/~3/1JYYumgTvr8/</link>
		<comments>http://shikii.net/blog/removing-extra-separator-lines-for-empty-rows-in-uitableview/#comments</comments>
		<pubDate>Sun, 11 Mar 2012 03:22:35 +0000</pubDate>
		<dc:creator>Shiki</dc:creator>
				<category><![CDATA[Mobile Development]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[ios]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[uitableview]]></category>

		<guid isPermaLink="false">http://shikii.net/blog/?p=599</guid>
		<description><![CDATA[I discovered this by accident. It&#8217;s probably been there for a long time but I just noticed it now. Normally, if you have very few rows in your table, it would look like this: Notice that I only have 2 rows. The other empty ones still have empty separator lines. Sometimes that&#8217;s not what you [...]]]></description>
			<content:encoded><![CDATA[<p>I discovered this by accident. It&#8217;s probably been there for a long time but I just noticed it now. Normally, if you have very few rows in your table, it would look like this:</p>

<p style="text-align: center;">
<img src="http://shikii.net/blog/wp-content/uploads/2012/03/emptyrows-before.jpg" alt="" title="Default row lines" width="320" height="480" class="aligncenter size-full wp-image-600" style="border: solid 1px #999;" />
</p>

<p>Notice that I only have 2 rows. The other empty ones still have empty separator lines. Sometimes that&#8217;s not what you want, especially if you have custom row designs. To remove those lines, you just have to supply a value for <code>tableFooterView</code>. An empty <code>UIView</code> will work fine:</p>

<pre><code>- (void) viewDidLoad
{
  [super viewDidLoad];

  self.tableView.tableFooterView = [[[UIView alloc] init] autorelease];
}
</code></pre>

<p>The table should now look like this:</p>

<p style="text-align: center;">
<img src="http://shikii.net/blog/wp-content/uploads/2012/03/emptyrows-after.jpg" alt="" title="No empty row lines" width="320" height="480" class="aligncenter size-full wp-image-603" style="border: solid 1px #999;" />
</p>
<img src="http://feeds.feedburner.com/~r/shikii/OfdV/~4/1JYYumgTvr8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://shikii.net/blog/removing-extra-separator-lines-for-empty-rows-in-uitableview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://shikii.net/blog/removing-extra-separator-lines-for-empty-rows-in-uitableview/</feedburner:origLink></item>
		<item>
		<title>FirePHP on Nginx: 502 Bad Gateway</title>
		<link>http://feedproxy.google.com/~r/shikii/OfdV/~3/W32atVJu-yM/</link>
		<comments>http://shikii.net/blog/firephp-on-nginx-502-bad-gateway/#comments</comments>
		<pubDate>Wed, 21 Sep 2011 11:41:09 +0000</pubDate>
		<dc:creator>Shiki</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[fastcgi]]></category>
		<category><![CDATA[firephp]]></category>
		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://shikii.net/blog/?p=589</guid>
		<description><![CDATA[We have switched from Apache to Nginx a month ago. PHP is running on FastCGI using PHP-FPM. I have just recently tried to debug our app using FirePHP and got a 502 Bad Gateway response from Nginx. It looks like Nginx by default limits the header output. This is the error in Nginx&#8217;s error log: [...]]]></description>
			<content:encoded><![CDATA[<p>We have switched from Apache to Nginx a month ago. PHP is running on FastCGI using <a href="http://en.wikipedia.org/wiki/PHP-FPM">PHP-FPM</a>. I have just recently tried to debug our app using FirePHP and got a 502 Bad Gateway response from Nginx. It looks like Nginx by default limits the header output. This is the error in Nginx&#8217;s error log:</p>

<pre><code>2011/09/21 09:36:16 [error] 816#0: *5 upstream sent too big header while reading response header from upstream, 
  client: 192.168.56.1, server: v.piclyf.com, request: "GET /pics HTTP/1.1", 
  upstream: "fastcgi://127.0.0.1:9000", host: "v.piclyf.com", referrer: "http://v.piclyf.com/dashboard"
</code></pre>

<p>The fix that I found is to increase the values of <a href="http://wiki.nginx.org/HttpFcgiModule#fastcgi_buffer_size"><code>fastcgi_buffer_size</code></a> and <a href="http://wiki.nginx.org/HttpFcgiModule#fastcgi_buffers"><code>fastcgi_buffers</code></a>. Add these 2 directives to your PHP FastCGI config in Nginx (i.e. <code>/etc/nginx/sites-available/default</code>):</p>

<pre><code>location ~ \.php$ {
  root /your/site/root;
  fastcgi_index index.php;
  include fastcgi_params;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  fastcgi_pass 127.0.0.1:9000;

  # set these two:
  fastcgi_buffer_size 16k;
  fastcgi_buffers 4 16k;
}
</code></pre>
<img src="http://feeds.feedburner.com/~r/shikii/OfdV/~4/W32atVJu-yM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://shikii.net/blog/firephp-on-nginx-502-bad-gateway/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://shikii.net/blog/firephp-on-nginx-502-bad-gateway/</feedburner:origLink></item>
		<item>
		<title>Using an object’s id as a key in NSDictionary</title>
		<link>http://feedproxy.google.com/~r/shikii/OfdV/~3/PCzDFPyy1QI/</link>
		<comments>http://shikii.net/blog/using-an-objects-id-as-a-key-in-nsdictionary/#comments</comments>
		<pubDate>Wed, 10 Aug 2011 08:19:32 +0000</pubDate>
		<dc:creator>Shiki</dc:creator>
				<category><![CDATA[Mobile Development]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[nsdictionary]]></category>

		<guid isPermaLink="false">http://shikii.net/blog/?p=580</guid>
		<description><![CDATA[I was working on a utility class and was playing with the idea of using the id of an object (e.g. NSObject) as a key in NSDictionary. Setting it directly doesn&#8217;t work though: NSObject *obj = [[[NSObject alloc] init] autorelease]; // we'll use this as the key NSMutableDictionary *dict = [[[NSMutableDictionary alloc] init] autorelease]; [dict [...]]]></description>
			<content:encoded><![CDATA[<p>I was working on a utility class and was playing with the idea of using the <code>id</code> of an object (e.g. <code>NSObject</code>) as a key in <code>NSDictionary</code>. Setting it directly doesn&#8217;t work though:</p>

<pre><code>NSObject *obj = [[[NSObject alloc] init] autorelease]; // we'll use this as the key

NSMutableDictionary *dict = [[[NSMutableDictionary alloc] init] autorelease];
[dict setObject:@"a value" forKey:obj]; // won't work
</code></pre>

<p>The above will lead to an exception like this:</p>

<pre><code>NSInvalidArgumentException, reason: '-[NSObject copyWithZone:]: unrecognized selector 
sent to instance 0x7ca6160'
</code></pre>

<p>The solution I arrived at was to use the string representation of the object. Simply casting the object to <code>NSString</code> will not work though:</p>

<pre><code>[dict setObject:@"a value" forKey:(NSString *)obj]; // same exception
</code></pre>

<p>Using a new <code>NSString</code> instance will work however:</p>

<pre><code>NSString *key = [NSString stringWithFormat:@"%@", (NSString *)obj]; // use a new NSString
[dict setObject:@"a value" forKey:key]; // works!
</code></pre>

<h4>Update</h4>

<p><a href="http://forrst.com/people/curthard89">curthard89</a> from <a href="http://forrst.com/posts/Using_an_objects_id_as_a_key_in_NSDictionary-N9s">Forrst</a> pointed out that it would be better to use <code>[NSObject hash]</code> instead of typecasting to string. The reason is <code>NSDictionary</code> and <code>NSArray</code> string representations can get really long and would be inefficient. I&#8217;m now using this technique:</p>

<pre><code>NSNumber *key = [NSNumber numberWithUnsignedInt:[obj hash]];
[dict setObject:@"a value" forKey:key];
</code></pre>
<img src="http://feeds.feedburner.com/~r/shikii/OfdV/~4/PCzDFPyy1QI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://shikii.net/blog/using-an-objects-id-as-a-key-in-nsdictionary/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://shikii.net/blog/using-an-objects-id-as-a-key-in-nsdictionary/</feedburner:origLink></item>
		<item>
		<title>A solution to Boot Camp partition error: “Files cannot be moved”</title>
		<link>http://feedproxy.google.com/~r/shikii/OfdV/~3/_EC0eJcCTUM/</link>
		<comments>http://shikii.net/blog/a-solution-to-boot-camp-partition-error-files-cannot-be-moved/#comments</comments>
		<pubDate>Mon, 13 Jun 2011 03:42:50 +0000</pubDate>
		<dc:creator>Shiki</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[boot-camp]]></category>
		<category><![CDATA[mac-os-x]]></category>
		<category><![CDATA[windows-7]]></category>

		<guid isPermaLink="false">http://shikii.net/blog/?p=572</guid>
		<description><![CDATA[So I was able to partition a Macbook Pro 2010 (Snow Leopard) using Boot Camp in order to install Windows 7. I just want to point out this possible solution when you get this error when trying to create a partition: Your Disk Cannot Be Partitioned Because Some Files Cannot Be Moved Back up the [...]]]></description>
			<content:encoded><![CDATA[<p>So I was able to partition a Macbook Pro 2010 (Snow Leopard) using Boot Camp in order to install Windows 7. I just want to point out this <strong>possible</strong> solution when you get this error when trying to create a partition:</p>

<blockquote>
  <p>Your Disk Cannot Be Partitioned Because Some Files Cannot Be Moved
  Back up the disk and use Disk Utility to format the disk as a single Mac OS Extended (Journaled) volume. Restore your information to the disk and try using Boot Camp Assistant again.</p>
</blockquote>

<p>Note that I said this is a <strong>possible</strong> solution. That means that this may not work for you. Most of the solutions I found on the Internet point to using defrag tools like <a href="http://www.coriolis-systems.com/iDefrag.php">iDefrag</a>. I didn&#8217;t want to go that way cause I really don&#8217;t have the money to buy those tools.</p>

<p>Here&#8217;s what I did to fix this error:</p>

<ol>
<li>Clean up the hard drive. Move large files to an external backup disk. There are tools like <a href="http://www.omnigroup.com/products/omnidisksweeper/">OmniDiskSweeper</a> to that can help in finding large files.</li>
<li>Reboot and boot up using your Mac OS X Install DVD. (Press <code>C</code> when after the startup sound to boot using the DVD)</li>
<li>Choose Utilities > Disk Utility in the menu and <strong>Repair</strong> the hard drive.</li>
<li>Restart and try partitioning using Boot Camp again.</li>
</ol>

<p>I&#8217;m not ultimately sure if Step 1 is really required but I don&#8217;t have time to test it again.</p>
<img src="http://feeds.feedburner.com/~r/shikii/OfdV/~4/_EC0eJcCTUM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://shikii.net/blog/a-solution-to-boot-camp-partition-error-files-cannot-be-moved/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<feedburner:origLink>http://shikii.net/blog/a-solution-to-boot-camp-partition-error-files-cannot-be-moved/</feedburner:origLink></item>
		<item>
		<title>Adding allowed open_basedir paths in a MediaTemple DV</title>
		<link>http://feedproxy.google.com/~r/shikii/OfdV/~3/-Q3dd2gtclU/</link>
		<comments>http://shikii.net/blog/adding-allowed-open_basedir-paths-in-a-mediatemple-dv/#comments</comments>
		<pubDate>Tue, 17 May 2011 04:50:34 +0000</pubDate>
		<dc:creator>Shiki</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[mediatemple]]></category>

		<guid isPermaLink="false">http://shikii.net/blog/?p=560</guid>
		<description><![CDATA[This is a quick fix for PHP errors like these on a Media Temple DV: Warning: include_once() [function.include-once]: open_basedir restriction in effect. I got this a few days ago when trying to setup an app. There are instructions in Media Temple&#8217;s site on how to fix this but this set of steps is what worked [...]]]></description>
			<content:encoded><![CDATA[<p>This is a quick fix for PHP errors like these on a Media Temple DV:</p>

<pre><code>Warning: include_once() [function.include-once]: open_basedir restriction in effect. 
</code></pre>

<p>I got this a few days ago when trying to setup an app. There are <a href="http://kb.mediatemple.net/questions/514/Setting+the+path+for+open_basedir#dv_40">instructions</a> in Media Temple&#8217;s site on how to fix this but this set of steps is what worked for me.</p>

<ol>
<li>Edit or create a <code>vhost.conf</code> file inside this folder: <code>/var/www/vhosts/YOURDOMAIN.COM/conf/</code>. Replace <code>YOURDOMAIN.COM</code> with the domain you wish to configure.</li>
<li><p>Add this in <code>vhost.conf</code>:</p>

<pre><code>&lt;Directory /var/www/vhosts/YOURDOMAIN.COM/httpdocs&gt;
  &lt;IfModule sapi_apache2.c&gt;
    php_admin_value open_basedir "/var/www/vhosts/YOURDOMAIN.COM/httpdocs:/tmp:/ADDITIONAL/PATH"
  &lt;/IfModule&gt;
  &lt;IfModule mod_php5.c&gt;
    php_admin_value open_basedir "/var/www/vhosts/YOURDOMAIN.COM/httpdocs:/tmp:/ADDITIONAL/PATH"
  &lt;/IfModule&gt;
&lt;/Directory&gt;
</code></pre>

<p>Replace <code>/ADDITIONAL/PATH</code> with a path you want added to the <code>open_basedir</code> whitelist. You can add more, just separate them with colons (<code>:</code>).</p></li>
<li><p>Reconfigure the webserver so <code>vhost.conf</code> will be applied.</p>

<pre><code>/usr/local/psa/admin/sbin/httpdmng --reconfigure-domain YOURDOMAIN.COM
</code></pre></li>
<li><p>Restart Apache</p>

<pre><code>/etc/init.d/httpd restart
</code></pre></li>
<li><p>Done! Check the value of <code>open_basedir</code> in <a href="http://php.net/manual/en/function.phpinfo.php"><code>phpinfo()</code></a> to see if it worked.</p></li>
</ol>
<img src="http://feeds.feedburner.com/~r/shikii/OfdV/~4/-Q3dd2gtclU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://shikii.net/blog/adding-allowed-open_basedir-paths-in-a-mediatemple-dv/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<feedburner:origLink>http://shikii.net/blog/adding-allowed-open_basedir-paths-in-a-mediatemple-dv/</feedburner:origLink></item>
		<item>
		<title>Getting a list of a Facebook user’s friends with their email addresses</title>
		<link>http://feedproxy.google.com/~r/shikii/OfdV/~3/iCz27sa0o78/</link>
		<comments>http://shikii.net/blog/getting-a-list-of-a-facebook-users-friends-with-their-email-addresses/#comments</comments>
		<pubDate>Sun, 15 May 2011 12:37:23 +0000</pubDate>
		<dc:creator>Shiki</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[fql]]></category>

		<guid isPermaLink="false">http://shikii.net/blog/?p=533</guid>
		<description><![CDATA[This article assumes that you are familiar with the Facebook SDK Core Concepts and know how to request a user&#8217;s access token. This also uses the Facebook PHP SDK. Getting the list of friends You can get the friends of a Facebook user using this FQL query: SELECT uid FROM user WHERE uid IN (SELECT [...]]]></description>
			<content:encoded><![CDATA[<p>This article assumes that you are familiar with the <a href="http://developers.facebook.com/docs/coreconcepts/">Facebook SDK Core Concepts</a> and know how to request a user&#8217;s access token. This also uses the <a href="https://github.com/facebook/php-sdk/">Facebook PHP SDK</a>.</p>

<h2>Getting the list of friends</h2>

<p>You can get the friends of a Facebook user using this FQL query:</p>

<pre><code>SELECT uid FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = $userId)
</code></pre>

<p>This request requires the access token of the user whose friends you want to access. Here&#8217;s an example using the Facebook SDK for PHP:</p>

<pre><code>$client = new Facebook(array('appId'  =&gt; 'YOUR_APP_ID', 'secret' =&gt; 'YOUR_APP_SECRET'));

$userId = 123;
$fql = "SELECT uid, first_name, last_name FROM user "
     . "WHERE uid in (SELECT uid2 FROM friend where uid1 = $userId)";
$friends = $client-&gt;api(array(
  'method'       =&gt; 'fql.query',
  'access_token' =&gt; 'USER_ACCESS_TOKEN',
  'query'        =&gt; $fql,
));

// we now have an array containing the friends of the user
print_r($friends); 
</code></pre>

<p>You can look at the <a href="http://developers.facebook.com/docs/reference/fql/user/"><code>user</code> table reference</a> for other fields besides <code>first_name</code> and <code>last_name</code>. Note that there are some fields such as <strong><code>email</code></strong> that require <a href="http://developers.facebook.com/docs/authentication/permissions/">user specific permissions</a>. If the user/friend has not given your app <strong>email permissions</strong>, chances are you won&#8217;t be able to get the email address. For instances like these, you can opt to filter just the friends who have given your app permissions. This can be done using the <code>is_app_user</code> field:</p>

<pre><code>SELECT uid, first_name, last_name FROM user 
  WHERE is_app_user = 1 AND uid IN (SELECT uid2 FROM friend WHERE uid1 = $userId)
</code></pre>

<h2>The case with email addresses</h2>

<p>From my tests, it looks like it&#8217;s more reliable to get the email addresses of friends if you <strong>don&#8217;t</strong> put in any user access token when calling <code>$client-&gt;api()</code>. Here&#8217;s a complete example of getting a list of friends and getting all their email addresses:</p>

<pre><code>$appId     = 'YOUR_APP_ID';
$appSecret = 'YOUR_APP_SECRET';

$userId          = 'A_FACEBOOK_USER_ID';
$userAccessToken = 'THE_FACEBOOK_USER_ACCESS_TOKEN';

$client = new Facebook(array('appId' =&gt; $appId, 'secret' =&gt; $appSecret));

// get all friends who has given our app permissions to access their data
$fql = "SELECT uid, first_name, last_name, email FROM user "
     . "WHERE is_app_user = 1 AND uid IN (SELECT uid2 FROM friend WHERE uid1 = $userId)";
$friends = $client-&gt;api(array(
  'method'       =&gt; 'fql.query',
  'access_token' =&gt; $userAccessToken,
  'query'        =&gt; $fql,
));

// make an array of all friend ids
$friendIds = array();
foreach ($friends as $friend) {
  $friendIds[] = $friend['uid'];
}

// get info of all the friends without using any access token
$friendIds = implode(',', $friendIds);
$fql = "SELECT uid, first_name, last_name, email FROM user WHERE uid IN ($friendIds)";
$friends = $client-&gt;api(array(
  'method' =&gt; 'fql.query',
  'query'  =&gt; $fql,
  // don't use an access token
));

// we should now have a list of friend infos with their email addresses
print_r($friends);
</code></pre>
<img src="http://feeds.feedburner.com/~r/shikii/OfdV/~4/iCz27sa0o78" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://shikii.net/blog/getting-a-list-of-a-facebook-users-friends-with-their-email-addresses/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		<feedburner:origLink>http://shikii.net/blog/getting-a-list-of-a-facebook-users-friends-with-their-email-addresses/</feedburner:origLink></item>
		<item>
		<title>Installing GraphicsMagick and Gmagick PHP extension on CentOS 5.6</title>
		<link>http://feedproxy.google.com/~r/shikii/OfdV/~3/jBkorsbzieo/</link>
		<comments>http://shikii.net/blog/installing-graphicsmagick-and-gmagick-php-extension-on-centos-5-6/#comments</comments>
		<pubDate>Thu, 12 May 2011 02:25:46 +0000</pubDate>
		<dc:creator>Shiki</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[gmagick]]></category>
		<category><![CDATA[graphicsmagick]]></category>
		<category><![CDATA[mediatemple]]></category>

		<guid isPermaLink="false">http://shikii.net/blog/?p=483</guid>
		<description><![CDATA[This was tested on CentOS 5.6 on a fresh MediaTemple (dv) setup. I figure it should be the same for any CentOS install. This set of instructions is a result of hours spent on installation troubleshooting; google searches; and trial and errors. Hopefully this can help other people. Install dependencies These are needed to enable [...]]]></description>
			<content:encoded><![CDATA[<p>This was tested on CentOS 5.6 on a fresh <a href="http://mediatemple.net/webhosting/dv/">MediaTemple (dv)</a> setup. I figure it should be the same for any CentOS install. This set of instructions is a result of hours spent on installation troubleshooting; google searches; and trial and errors. Hopefully this can help other people.</p>

<h3>Install dependencies</h3>

<p>These are needed to enable <a href="http://www.graphicsmagick.org/README.html#add-on-libraries-programs">GraphicsMagick add-ons</a>. In here, I only included what I think are commonly required. But feel free to include other libraries that you need.</p>

<pre><code>yum install -y gcc libpng libjpeg libpng-devel libjpeg-devel ghostscript
yum install -y libtiff libtiff-devel freetype freetype-devel
</code></pre>

<h3>Download and install GraphicsMagick</h3>

<p>We will need to download and compile GraphicsMagick ourselves. It looks like it is not available in <code>yum</code> yet. MediaTemple users are advised to <a href="http://wiki.mediatemple.net/w/(dv):Noexec_and_/tmp_troubleshooting#Chrooted_.2Ftmp_directory">use <code>chroot</code></a> to prevent <code>noexec</code> and <code>/tmp</code> related errors. Execute these on the console:</p>

<pre><code># work on a temporary dir of your preference
cd /root/tmp

# download source tarball. See here for other versions: ftp://ftp.graphicsmagick.org/pub/GraphicsMagick/
wget ftp://ftp.graphicsmagick.org/pub/GraphicsMagick/1.3/GraphicsMagick-1.3.9.tar.gz

# extract and open the extracted folder
tar -xvf GraphicsMagick-1.3.9.tar.gz
cd GraphicsMagick-1.3.9

./configure --enable-shared
</code></pre>

<p>Using <code>--enable-shared</code> above has helped prevent errors like this when installing gmagick through pecl:</p>

<blockquote>
<pre><code>Build Error: /usr/bin/ld: /usr/local/lib/libGraphicsMagickWand.a(drawing_wand.o):
relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object;
recompile with -fPIC
</code></pre>
</blockquote>

<p>After <code>./configure</code> is done, make sure that the <strong>Configured value</strong> of the add-ons you need are set to <code>Yes</code>. Also make sure that <code>enable-shared</code> is set to <code>Yes</code>. You can see this at the end part of <code>configure</code>&#8216;s output. It should look like this:</p>

<blockquote>
<pre><code>Option            Configure option                Configured value
------------------------------------------------------------------
Shared libraries  --enable-shared=yes             yes
Static libraries  --enable-static=yes             yes
GNU ld            --with-gnu-ld=yes               yes
Quantum depth     --with-quantum-depth=8          8

Delegate Configuration:
BZLIB             --with-bzlib=yes                no
DPS               --with-dps=yes                  no
FlashPIX          --with-fpx=no                   no
FreeType 2.0      --with-ttf=yes                  yes
Ghostscript       None                            gs (8.70)
Ghostscript fonts --with-gs-font-dir=default      /usr/share/fonts/default/Type1/
Ghostscript lib   --with-gslib=no                 no
JBIG              --with-jbig=yes                 no
JPEG v1           --with-jpeg=yes                 yes
JPEG-2000         --with-jp2=yes                  no
LCMS              --with-lcms=yes                 no
Magick++          --with-magick-plus-plus=yes     yes
PERL              --with-perl=no                  no
PNG               --with-png=yes                  yes
TIFF              --with-tiff=yes                 yes
TRIO              --with-trio=yes                 no
Windows fonts     --with-windows-font-dir=        none
WMF               --with-wmf=yes                  no
X11               --with-x=                       no
XML               --with-xml=yes                  no
ZLIB              --with-zlib=yes                 yes
</code></pre>
</blockquote>

<p>Next, compile and install:</p>

<pre><code>make
make install 
</code></pre>

<p>You can then test if GraphicsMagick has been successfully installed by executing commands like:</p>

<pre><code>gm version
</code></pre>

<h3>Install Gmagick PHP extension</h3>

<p>We&#8217;ll install gmagick using PECL. MediaTemple users are still advised to use <code>chroot</code>.</p>

<pre><code>pecl install gmagick 
</code></pre>

<p>If you get an error about gmagick not having a stable version, you can specify the version instead:</p>

<pre><code>pecl install gmagick-1.0.8b2
</code></pre>

<p>Next, add <code>extension=gmagick.so</code> to <code>php.ini</code> and restart Apache if necessary. This is outside the scope of this article though. Please Google it if you don&#8217;t know how.</p>

<p>And we&#8217;re done!</p>

<p>P.S. If you&#8217;re having trouble, it might help to look/search for solutions using &#8220;ImageMagick&#8221; instead. There are fewer resources for GraphicsMagick compared to ImageMagick. I found some articles for ImageMagick that can be used for GraphicsMagick too.</p>
<img src="http://feeds.feedburner.com/~r/shikii/OfdV/~4/jBkorsbzieo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://shikii.net/blog/installing-graphicsmagick-and-gmagick-php-extension-on-centos-5-6/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<feedburner:origLink>http://shikii.net/blog/installing-graphicsmagick-and-gmagick-php-extension-on-centos-5-6/</feedburner:origLink></item>
		<item>
		<title>Autoloading namespaced libraries in Yii Framework</title>
		<link>http://feedproxy.google.com/~r/shikii/OfdV/~3/po7Ztyhyo4Y/</link>
		<comments>http://shikii.net/blog/autoloading-namespaced-libraries-in-yii-framework/#comments</comments>
		<pubDate>Sun, 01 May 2011 14:05:36 +0000</pubDate>
		<dc:creator>Shiki</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[yii]]></category>

		<guid isPermaLink="false">http://shikii.net/blog/?p=479</guid>
		<description><![CDATA[To integrate libraries using namespaces into a Yii Framework project, you can simply use Yii::setPathOfAlias to have the classes autoloaded by Yii when needed. Just specify the root namespace as the alias and the physical location of that root alias as the path. Using Predis as an example, if we put the code in: /vendors/predis/lib/Predis [...]]]></description>
			<content:encoded><![CDATA[<p>To integrate libraries using namespaces into a Yii Framework project, you can simply use <a href="http://www.yiiframework.com/doc/api/1.1/YiiBase#setPathOfAlias-detail"><code>Yii::setPathOfAlias</code></a> to have the classes autoloaded by Yii when needed. Just specify the <strong>root</strong> namespace as the alias and the physical location of that root alias as the path.</p>

<p>Using <a href="https://github.com/nrk/predis">Predis</a> as an example, if we put the code in:</p>

<pre><code>/vendors/predis/lib/Predis
</code></pre>

<p>We&#8217;ll add it to Yii as an alias named <code>Predis</code> so classes under it can be autoloaded:</p>

<pre><code>Yii::setPathOfAlias('Predis', '/vendors/predis/lib/Predis');
</code></pre>

<p>Now when we call <code>new Predis\Client()</code>, Yii will look for a file named <code>Client.php</code> in <code>/vendors/predis/lib/Predis</code>. The same holds true for other classes under subfolders (e.g. <code>Predis\Commands\Append</code>).</p>
<img src="http://feeds.feedburner.com/~r/shikii/OfdV/~4/po7Ztyhyo4Y" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://shikii.net/blog/autoloading-namespaced-libraries-in-yii-framework/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://shikii.net/blog/autoloading-namespaced-libraries-in-yii-framework/</feedburner:origLink></item>
	</channel>
</rss>

