<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Programming on Arcanelab Blog</title><link>https://blog.arcanelab.com/tags/programming/</link><description>Recent content in Programming on Arcanelab Blog</description><generator>Hugo</generator><language>en-US</language><copyright>Zoltán Majoros</copyright><lastBuildDate>Fri, 30 Dec 2011 06:44:00 +0100</lastBuildDate><atom:link href="https://blog.arcanelab.com/tags/programming/index.xml" rel="self" type="application/rss+xml"/><item><title>2D Drawing in OpenGL</title><link>https://blog.arcanelab.com/2011/12/2d-drawing-in-opengl/</link><pubDate>Fri, 30 Dec 2011 06:44:00 +0100</pubDate><guid>https://blog.arcanelab.com/2011/12/2d-drawing-in-opengl/</guid><description/></item><item><title>How to convert an integer to a hexadecimal string in C++ int number = 42; stringstream…</title><link>https://blog.arcanelab.com/2011/12/how-to-convert-an-integer-to-a-hexadecimal-string-in-c-int/</link><pubDate>Sat, 10 Dec 2011 06:58:00 +0100</pubDate><guid>https://blog.arcanelab.com/2011/12/how-to-convert-an-integer-to-a-hexadecimal-string-in-c-int/</guid><description>&lt;h1&gt;How to convert an integer to a hexadecimal string in C++&lt;/h1&gt;
&lt;pre&gt;int number = 42;&lt;br/&gt;stringstream ss;&lt;br/&gt;ss &amp;lt;&amp;lt; hex &amp;lt;&amp;lt; number;&lt;br/&gt;// now ss.str(), which is a &lt;em&gt;string&lt;/em&gt;, contains "2a"&lt;/pre&gt;</description></item><item><title>Getting the UDID of an iOS device [[UIDevice currentDevice] uniqueIdentifier]</title><link>https://blog.arcanelab.com/2011/01/getting-the-udid-of-an-ios-device-uidevice-currentdevice/</link><pubDate>Tue, 18 Jan 2011 19:48:00 +0100</pubDate><guid>https://blog.arcanelab.com/2011/01/getting-the-udid-of-an-ios-device-uidevice-currentdevice/</guid><description>&lt;h1&gt;Getting the UDID of an iOS device&lt;/h1&gt;
&lt;pre&gt;[[UIDevice currentDevice] uniqueIdentifier]&lt;/pre&gt;</description></item><item><title>Mac OS X Debugging Magic</title><link>https://blog.arcanelab.com/2010/10/mac-os-x-debugging-magic/</link><pubDate>Sat, 09 Oct 2010 13:59:00 +0200</pubDate><guid>https://blog.arcanelab.com/2010/10/mac-os-x-debugging-magic/</guid><description/></item><item><title>how to debug EXC_BAD_ACCESS on iPhone</title><link>https://blog.arcanelab.com/2010/10/how-to-debug-exc-bad-access-on-iphone/</link><pubDate>Sat, 09 Oct 2010 13:57:00 +0200</pubDate><guid>https://blog.arcanelab.com/2010/10/how-to-debug-exc-bad-access-on-iphone/</guid><description/></item><item><title>Great guide for memory-debugging in Instruments</title><link>https://blog.arcanelab.com/2010/09/great-guide-for-memory-debugging-in-instruments/</link><pubDate>Thu, 30 Sep 2010 23:34:00 +0200</pubDate><guid>https://blog.arcanelab.com/2010/09/great-guide-for-memory-debugging-in-instruments/</guid><description/></item><item><title>iroundf A few minutes ago I wrote a rounding function for myself in C.</title><link>https://blog.arcanelab.com/2010/09/iroundf-a-few-minutes-ago-i-wrote-a-rounding-function-for/</link><pubDate>Wed, 29 Sep 2010 04:00:00 +0200</pubDate><guid>https://blog.arcanelab.com/2010/09/iroundf-a-few-minutes-ago-i-wrote-a-rounding-function-for/</guid><description>&lt;h1&gt;iroundf&lt;/h1&gt;
&lt;p&gt;A few minutes ago I wrote a rounding function for myself in C. Probably not the best implementation, but it works all right. If you&amp;rsquo;re interested, check it out (I&amp;rsquo;ve put some sample values in the comments):&lt;/p&gt;
&lt;pre&gt;int iroundf(float value)&lt;br/&gt;{&lt;br/&gt;    if(value &amp;gt; 0.0)&lt;br/&gt;    {        &lt;br/&gt;        int unsigned cutvalue = (unsigned int)value; // 3.8234234 =&amp;gt; 3&lt;br/&gt;        float remain = value - cutvalue; // 3.8234234-3 = 0.8234234&lt;br/&gt;        &lt;br/&gt;        if(remain &amp;gt;= 0.5) // 0.8234234 &amp;gt;= 0.5 =&amp;gt; TRUE &lt;br/&gt;            return cutvalue + 1; // iroundf(3.8234234) =&amp;gt; 4&lt;br/&gt;        else&lt;br/&gt;            return cutvalue;&lt;br/&gt;    }&lt;br/&gt;    &lt;br/&gt;    if(value &amp;lt; 0.0)&lt;br/&gt;    {&lt;br/&gt;        int cutvalue = (int)value; // -1.34 =&amp;gt; -1 // -4.67 =&amp;gt; -4&lt;br/&gt;        float remain = value - cutvalue; // -1.34-(-1) = -0.34 // -4.64-(-4) = -0.64&lt;br/&gt;        &lt;br/&gt;        if(remain &amp;gt;= -0.5) // -0.31 &amp;gt;= -0.5 =&amp;gt; TRUE // -0.61 &amp;gt;= -0.5 =&amp;gt; FALSE&lt;br/&gt;            return cutvalue; // iroundf(-1.34) =&amp;gt; -1&lt;br/&gt;        else&lt;br/&gt;            return cutvalue - 1; // iroundf(-4.67) =&amp;gt; -5&lt;br/&gt;    }&lt;br/&gt;    &lt;br/&gt;    return 0;&lt;br/&gt;}&lt;br/&gt;&lt;br/&gt;&lt;/pre&gt;
&lt;p&gt;update: I just came across the following very short and elegant solution (talk about forests and trees&amp;hellip;)&lt;/p&gt;</description></item><item><title>A nice article on iPhone application internationalization</title><link>https://blog.arcanelab.com/2010/09/a-nice-article-on-iphone-application-internationalization/</link><pubDate>Sun, 26 Sep 2010 22:11:00 +0200</pubDate><guid>https://blog.arcanelab.com/2010/09/a-nice-article-on-iphone-application-internationalization/</guid><description/></item><item><title>Getting filepath to the Documents folder on iPhone To achieve the task written in the…</title><link>https://blog.arcanelab.com/2010/09/getting-filepath-to-the-documents-folder-on-iphone-to/</link><pubDate>Fri, 24 Sep 2010 18:07:00 +0200</pubDate><guid>https://blog.arcanelab.com/2010/09/getting-filepath-to-the-documents-folder-on-iphone-to/</guid><description>&lt;h1&gt;Getting filepath to the Documents folder on iPhone&lt;/h1&gt;
&lt;p&gt;To achieve the task written in the title of this post, you have to do the following:&lt;/p&gt;
&lt;pre&gt;NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
NSString *documentsPath = [paths objectAtIndex:0];&lt;/pre&gt;</description></item><item><title>Button resize causing text blur?</title><link>https://blog.arcanelab.com/2010/09/button-resize-causing-text-blur/</link><pubDate>Tue, 14 Sep 2010 00:44:00 +0200</pubDate><guid>https://blog.arcanelab.com/2010/09/button-resize-causing-text-blur/</guid><description>&lt;h1&gt;Button resize causing text blur?&lt;/h1&gt;
&lt;p&gt;Today I noticed a very, very strange behaviour (bug?) in Xcode. I am creating buttons for my iPhone application with a custom image background and a text on top of it. The Interface Builder attributes window looks like this:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Usually I change the font-family and size for my text, but when I do this, the button dimensions suddenly grow pretty big. So I just head over to the &lt;em&gt;Button Size&lt;/em&gt; tab and reset the dimension values to the originals, like so:&lt;/p&gt;</description></item><item><title>View overlapped by the title bar During the development of my latest iPhone project I…</title><link>https://blog.arcanelab.com/2010/09/view-overlapped-by-the-title-bar-during-the-development-of/</link><pubDate>Fri, 10 Sep 2010 20:04:00 +0200</pubDate><guid>https://blog.arcanelab.com/2010/09/view-overlapped-by-the-title-bar-during-the-development-of/</guid><description>&lt;h1&gt;View overlapped by the title bar&lt;/h1&gt;
&lt;p&gt;During the development of my latest iPhone project I faced a strange phenomenon: if I enable the title bar on a screen, the current view is placed to the coordinates (0,0), right beneath the title bar. Also, since the height of the view is not 100% (to leave space for the title bar), there&amp;rsquo;s an empty space left under the view.&lt;/p&gt;
&lt;p&gt;Here&amp;rsquo;s an example:&lt;/p&gt;</description></item><item><title>Quick Look source code preview &amp; syntax highlighting on Mac Without much rambling, a…</title><link>https://blog.arcanelab.com/2010/09/quick-look-source-code-preview-syntax-highlighting-on-mac/</link><pubDate>Tue, 07 Sep 2010 14:15:00 +0200</pubDate><guid>https://blog.arcanelab.com/2010/09/quick-look-source-code-preview-syntax-highlighting-on-mac/</guid><description>&lt;h1&gt;Quick Look source code preview &amp; syntax highlighting on Mac&lt;/h1&gt;
&lt;p&gt;Without much rambling, a solution for the problem presented in the title: &lt;a href="http://code.google.com/p/qlcolorcode/"&gt;http://code.google.com/p/qlcolorcode/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;To change the color style (theme), use the following command:&lt;/p&gt;
&lt;pre&gt;defaults write org.n8gray.QLColorCode hlTheme [theme name]&lt;/pre&gt;
&lt;p&gt;Where [theme name] can be:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;acid, bipolar, blacknblue, bright, contrast, darkblue, darkness, desert, easter, emacs, golden, greenlcd, ide-anjuta, ide-codewarrior, ide-devcpp, ide-eclipse, ide-kdev, ide-msvcpp, ide-xcode, kwrite, lucretia, matlab, moe, navy, nedit, neon, night, orion, pablo, peachpuff, print, rand01, seashell, slateGreen, the, typical, vampire, vim-dark, vim, whitengrey, zellner&lt;/em&gt;&lt;/p&gt;</description></item><item><title>C/C++ trick with logical operators Let me show a nice C/C++ trick I just found out:…</title><link>https://blog.arcanelab.com/2010/09/c-c-trick-with-logical-operators-let-me-show-a-nice-c-c/</link><pubDate>Sat, 04 Sep 2010 02:14:00 +0200</pubDate><guid>https://blog.arcanelab.com/2010/09/c-c-trick-with-logical-operators-let-me-show-a-nice-c-c/</guid><description>&lt;h1&gt;C/C++ trick with logical operators&lt;/h1&gt;
&lt;p&gt;Let me show a nice C/C++ trick I just found out:&lt;/p&gt;
&lt;p&gt;Instead of writing:&lt;/p&gt;
&lt;pre&gt;if (function1())&lt;br/&gt; function2();&lt;/pre&gt;
&lt;p&gt;you could write:&lt;/p&gt;
&lt;pre&gt;function1() &amp;amp;&amp;amp; function2();&lt;/pre&gt;
&lt;p&gt;because the right side of the &amp;amp;&amp;amp; operator is only evaluated (in this case: called), when function1() is true (returns a non-null value).&lt;/p&gt;
&lt;p&gt;Subsequently, instead of:&lt;/p&gt;
&lt;pre&gt;if (!function1()) // or if (function1()==0) etc.&lt;br/&gt; function2();&lt;/pre&gt;
&lt;p&gt;you could write:&lt;/p&gt;
&lt;pre&gt;function1() || function2();&lt;/pre&gt;
&lt;p&gt;Cool, eh?&lt;/p&gt;</description></item></channel></rss>