<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title><![CDATA[Marc Nijdam]]></title>
  <link href="http://madninja.github.com/atom.xml" rel="self"/>
  <link href="http://madninja.github.com/"/>
  <updated>2011-12-23T09:26:26-08:00</updated>
  <id>http://madninja.github.com/</id>
  <author>
    <name><![CDATA[Marc Nijdam]]></name>
    
  </author>
  <generator uri="http://octopress.org/">Octopress</generator>

  
  <entry>
    <title type="html"><![CDATA[UIColor shortcuts revisited]]></title>
    <link href="http://madninja.github.com/blog/2011/12/23/uicolor-shortcuts-2/"/>
    <updated>2011-12-23T08:46:00-08:00</updated>
    <id>http://madninja.github.com/blog/2011/12/23/uicolor-shortcuts-2</id>
    <content type="html"><![CDATA[<p>Following up on a previous post on utilities for creating
<a href="http://developer.apple.com/library/IOS/#documentation/UIKit/Reference/%0AUIColor_Class/Reference/Reference.html">UIColor</a> objects. I&#8217;ve started work on a new
project where the designers prefer to work with web style colors in the typical CSS format <code>#c5c5c5</code>.</p>

<p>Needing to convert those to the floating point format I prefered in my previous post was laborious and didn&#8217;t allow for quick turn color changes with the designer.</p>

<p>Enter RGBX and RGBXA:</p>

<div><script src='https://gist.github.com/1514810.js?file='></script>
<noscript><pre><code>static __inline UIColor *RGBXA(NSUInteger rgb, CGFloat alpha)
{
    return [UIColor colorWithRed:((float)((rgb &amp; 0xFF0000) &gt;&gt; 16))/255.0
                           green:((float)((rgb &amp; 0xFF00) &gt;&gt; 8))/255.0
                            blue:((float)(rgb &amp; 0xFF))/255.0
                           alpha:alpha];
}

static __inline UIColor *RGBX(NSUInteger rgb) 
{
    return RGBXA(rgb,1.0);
}
</code></pre></noscript></div>


<p>Which allow for UIColors to be created by coying the hex values from the design documents doing:</p>

<pre><code>RGBX(0xc5c5c5);
RGBXA(0xc5c5c5, 0.8);
</code></pre>

<p>This reduced friction with in translating the visual design a lot for me. I hope it does for you to.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Ruby segfault]]></title>
    <link href="http://madninja.github.com/blog/2011/12/22/ruby-segfault/"/>
    <updated>2011-12-22T14:09:00-08:00</updated>
    <id>http://madninja.github.com/blog/2011/12/22/ruby-segfault</id>
    <content type="html"><![CDATA[<p>I didn&#8217;t know why I was having all these weird problems with ruby segfault-ing while doing rake tasks in
<a href="http://octopress.org">Octopress</a> until I ran across this incredibly helpful
<a href="https://gist.github.com/1104557">gist</a>. Thank you Brandon, site generation now works flawlessly.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Steve Jobs 1955–2011]]></title>
    <link href="http://madninja.github.com/blog/2011/10/05/steve-jobs-1955-2011/"/>
    <updated>2011-10-05T18:25:00-07:00</updated>
    <id>http://madninja.github.com/blog/2011/10/05/steve-jobs-1955-2011</id>
    <content type="html"><![CDATA[<p><a href="http://apple.com/stevejobs" title="Steve Jobs"><img src="http://madninja.github.com/images/steve-jobs-dies.png"></a></p>

<p>I don&#8217;t even know how to express myself here, except that I feel the need to honor the man. I&#8217;ve
been a developer, manager and technologist for almost 20 years. I never met Steve, nor was I that
much into Apple products until about 5 years ago, when dabbling with iOS turned into a passion for
mobile applications again.</p>

<p>I&#8217;ve since then come full circle. I&#8217;m proud to be a near full-time developer again, feel honored to
target and use products that were built, née <em>crafted</em> by a team of people that care deeply about
design and build and delivery excellence. All led by a visionary with a drive that I can only
aspire to live by.</p>

<p>Thanks for bringing me full circle Steve. Your legacy lives on in our every day lives as users, companies, leaders, and developers. You didn&#8217;t just &#8220;make a ding in the universe&#8221;, you made a ding in each and every one of our lives and made it better.</p>

<p>My sincerest condolences to Steve&#39;s family, friends and colleagues.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[CGGradientUtils]]></title>
    <link href="http://madninja.github.com/blog/2011/10/03/cggradientutils/"/>
    <updated>2011-10-03T08:31:00-07:00</updated>
    <id>http://madninja.github.com/blog/2011/10/03/cggradientutils</id>
    <content type="html"><![CDATA[<p>Just a quick gist to show what I do to create a <a href="http://developer.apple.com/library/ios/#documentation/GraphicsImaging/Reference/CGGradient/Reference/reference.html" title="CGGradient">CGGradient</a>. It&#8217;s really just a wrapper to do type-casting and create a color array.</p>

<div><script src='https://gist.github.com/1259398.js?file='></script>
<noscript><pre><code>CGGradientRef CGGradientCreateWithUIColors(CGColorSpaceRef space, NSArray *colors, const CGFloat locations[]) 
{
    NSMutableArray *cgColors = [NSMutableArray arrayWithCapacity:colors.count];
    [colors enumerateObjectsUsingBlock:^(UIColor *color, NSUInteger idx, BOOL *stop) {
        [cgColors addObject:(id)color.CGColor];
    }];
    return CGGradientCreateWithColors(space, (CFArrayRef)cgColors, locations);
}</code></pre></noscript></div>



]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[UIColor Shortcuts]]></title>
    <link href="http://madninja.github.com/blog/2011/09/26/uicolor-shortcuts/"/>
    <updated>2011-09-26T15:17:00-07:00</updated>
    <id>http://madninja.github.com/blog/2011/09/26/uicolor-shortcuts</id>
    <content type="html"><![CDATA[<p>Over the course of a number of projects I&#8217;ve been tinkering with how best to create the endless
amounts of
<a href="http://developer.apple.com/library/IOS/#documentation/UIKit/Reference/UIColor_Class/Reference/Reference.html">UIColor</a>
objects that need to be constructed. Most often the exact values of these come from visual designs
that encode values as indexed RGB(A) value, HSV or in the most common case, actual mockups of the
screen where I&#8217;m expected to just sample the color to get it close enough for the first few builds.</p>

<p>I initially used a category on UIColor added a couple of methods to provide integer 0-255 values
for indexed RGB values.</p>

<div><script src='https://gist.github.com/1243675.js?file='></script>
<noscript><pre><code>#import &lt;UIKit/UIColor.h&gt;

@interface UIColor (RgbExtensions)

+(UIColor *)rgbColorWithRed:(CGFloat)r green:(CGFloat)g blue:(CGFloat)b;
+(UIColor *)rgbaColorWithRed: (CGFloat)r green:(CGFloat)g blue:(CGFloat)b alpha:(CGFloat)a;

@end
</code></pre></noscript></div>


<p>I&#8217;ve since come to like a much simpler approach that (1) removes the verbosity of messages and (2)
the float conversions. This is achieved through a couple of RGB(A) macros that I drop into my
prefix file.</p>

<div><script src='https://gist.github.com/1243615.js?file='></script>
<noscript><pre><code>#ifdef __OBJC__
    #import &lt;UIKit/UIKit.h&gt;

    #define RGB(r,g,b) [UIColor colorWithRed:(r) green:(g) blue:(b) alpha:1]
    #define RGBA(r,g,b,a) [UIColor colorWithRed:(r) green:(g) blue:(b) alpha:(a)]
#endif</code></pre></noscript></div>


<p>So instead of using</p>

<pre><code>[UIColor colorWithRed:10 green:20 blue:30]
</code></pre>

<p>I&#8217;d use</p>

<pre><code>RGB(0.04,0.08,0.12)
</code></pre>

<p>While the former is more Objective-C style, the latter is way more efficient to read and after a
while (and a bit of designer education) it&#8217;s much easier to tweak the 0-1 float values to the
desired end result.</p>

<p>I use the excellent <a href="http://itunes.apple.com/us/app/classic-color-meter/id451640037?mt=12">Classic Color Meter</a> (AppStore link) to meter these values out of the mock-ups. Works great for me and hope it&#8217;s
useful for others.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Boot...]]></title>
    <link href="http://madninja.github.com/blog/2011/09/24/boot-dot-dot-dot/"/>
    <updated>2011-09-24T11:51:00-07:00</updated>
    <id>http://madninja.github.com/blog/2011/09/24/boot-dot-dot-dot</id>
    <content type="html"><![CDATA[<p>So here&#8217;s me bootstrapping <a href="http://octopress.org">Octopress</a> up to try and replace
<a href="http://imadjine.com">imadjine.com</a> with something that I&#8217;d actually consider maintaining and updating on a regular
basis. I&#8217;ll introduce myself more properly in next post, but wanted to at least shout out to
<a href="http://www.mindjunk.org/blog/2011/08/02/octopress-setup/">mindjunk</a>&#8217;s setup page. Without those helpful <a href="https://gist.github.com/1120457#file_octopress_setup.sh">gist bits</a> the
process wouldn&#8217;t have been nearly as easy. Thanks!</p>
]]></content>
  </entry>
  
</feed>

