
<?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>Accella Website &#187; Jacob Haskins</title>
	<atom:link href="http://www.accella.net/author/jhaskins/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.accella.net</link>
	<description>Website &#38; Mobile Application Design &#38; Development</description>
	<lastBuildDate>Mon, 06 Feb 2012 20:39:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Enhancing the Mobile User Experience With Speed</title>
		<link>http://www.accella.net/enhancing-the-mobile-user-experience-with-speed/</link>
		<comments>http://www.accella.net/enhancing-the-mobile-user-experience-with-speed/#comments</comments>
		<pubDate>Thu, 28 Jul 2011 19:50:41 +0000</pubDate>
		<dc:creator>Jacob Haskins</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[Mobile Development]]></category>

		<guid isPermaLink="false">http://www.accella.net/?p=2983</guid>
		<description><![CDATA[There are many factors to take into account when thinking about how to enhance the user experience for a mobile application or a mobile based web site. It’s important to keep in mind that a mobile device will provide an entirely different user experience compared to a desktop computer. Hardware limitations, screen sizes, input methods, [...]]]></description>
			<content:encoded><![CDATA[<p>There are many factors to take into account when thinking about how to enhance the user experience for a mobile application or a mobile based web site. It’s important to keep in mind that a mobile device will provide an entirely different user experience compared to a desktop computer. Hardware limitations, screen sizes, input methods, connection speeds, user environment and more must carefully be examined to determine what strategies to use to provide a good user experience. A good idea implemented with a poor user experience will invite negative feedback and could potentially cause the project to become a failure. While there are many areas that we can improve to enhance the mobile user experience, let’s focus in on speed.</p>
<p>Speed can be a major determining factor in whether you provide a good or bad user experience. High speed internet, constantly improved desktop hardware and our increasingly busy schedule has led many to develop a great deal of impatience with technology.</p>
<p style="text-align: center"><em>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
To illustrate user impatience, please wait 60 seconds before proceeding to the next paragraph.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</em></p>
<p>When forced to wait an extensive period of time, many think ‘My computer at home doesn’t make me wait this long, so why should my phone?!’. They then look for a speedier alternative. Two general strategies for enhancing the user experience in this regard involves real speed and perceived speed.</p>
<p><strong>Real speed</strong> is just what it sounds like. It is the actual time it takes to interact with the app, download data or process data. This speed can vary greatly depending on how things are developed. One way to improve here is by optimizing data. Images, for example, should always be optimized for a mobile device to reduce file size. Returning data from an external database? Don’t dump the entire database. Reduce the size of the data by only sending what is needed.</p>
<p>Many try to cut corners because something is already prepared for a desktop environment. So instead of tailoring things for the mobile device, they try to save some development cost by utilizing what they already have. However, this approach can end up providing the users with a slow user experience.</p>
<p><strong>Perceived speed</strong> is how fast the user thinks things are going. We might optimize our data to the largest degree possible. However, at times the user might still feel like things are going slowly. There are a few things we can do to make the user think that things are moving along a bit faster than they really are.</p>
<p>First of all, always display a progress indicator or spinner. This lets the user know that the app isn’t just hanging while the data is downloading or processing. If possible, include more details like ‘Downloading files 9 of 14’, or something similar.</p>
<p>Another strategy is to let the app show the data that is available while the rest is downloading or processing. For example, imagine an app that downloads several rows of data. Each row contains an image downloaded from an external server. Rather than wait for all the images to fully download before presenting the data to the user, show the data that is available and download the images asynchronously.</p>
<p>Finally, a third strategy is loading data that the user will request before they actually request it (think <a title="Google Announces Instant Pages" href="http://googlewebmastercentral.blogspot.com/2011/06/announcing-instant-pages.html" target="_blank">Instant Pages</a>). An example of when we might use this is in an image gallery. The user is only viewing one image at a time. However, we know what images are before and after what they are viewing. So we begin the download process of those images without the user even realizing it.</p>
<p>These strategies above do not increase the real speed of our application. It still takes the same amount of time to download the data, to process it and to display it for the user. What we are changing is how the user perceives the data flow.</p>
<p>By utilizing these and other strategies, we can give our mobile app a much more pleasing user experience. In conclusion, don’t be <em>slow</em> to adopt these approaches.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.accella.net/enhancing-the-mobile-user-experience-with-speed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Objective C &#8211; Multiple Pages in a UIScrollView</title>
		<link>http://www.accella.net/objective-c-multiple-pages-in-a-uiscrollview/</link>
		<comments>http://www.accella.net/objective-c-multiple-pages-in-a-uiscrollview/#comments</comments>
		<pubDate>Wed, 29 Jun 2011 16:45:39 +0000</pubDate>
		<dc:creator>Jacob Haskins</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[Mobile Development]]></category>

		<guid isPermaLink="false">http://www.accella.net/?p=2744</guid>
		<description><![CDATA[Enabling paging in a UIScrollView will allow you to have a nice &#8216;snap-to&#8217; effect. It&#8217;s exactly what you see when using the Photo app. I recently wanted to utilize this effect while displaying multiple pages on the screen but ran into a few issues. Problems and solutions below. Also, you can picture any &#8216;pages&#8217; that [...]]]></description>
			<content:encoded><![CDATA[<div>
<p>Enabling paging in a UIScrollView will allow you to have a nice &#8216;snap-to&#8217; effect. It&#8217;s exactly what you see when using the Photo app. I recently wanted to utilize this effect while displaying multiple pages on the screen but ran into a few issues. Problems and solutions below. Also, you can picture any &#8216;pages&#8217; that I make reference to will just display an image as content.</p>
<p><strong>Problem 1 &#8211; Swipe Not Detected</strong></p>
<p>Consider this: You have a page in the center of the screen. To the left you see half of another page and to the right you see half of another page. Setting this up should be easy. Uncheck &#8216;Clip Subviews&#8217;, check &#8216;Paging Enabled&#8217; and set the frame to be the size of each page. Great, it all works! Except you can only swipe if touch begins in the center page. So if I start my swiping in one of the pages that is partly showing on the right or left then nothing would happen. While some would accept this as a mild annoyance and move on, not the <del>perfectionists</del> professionals at Accella!</p>
<p><strong>Solution 1 &#8211; Swipe Detected</strong></p>
<p>The solution to this problem involves placing the UIScrollView inside a UIView and overriding the hitTest method of the UIView to pass along the touch to the child UIScrollView. So start by subclassing the UIView, add a reference to the UIScrollView inside UIView and finally add the following code to your UIView subclass:</p>
<pre>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="sy0">-</span> <span class="br0">&#40;</span>UIView <span class="sy0">*</span><span class="br0">&#41;</span> hitTest<span class="sy0">:</span><span class="br0">&#40;</span>CGPoint<span class="br0">&#41;</span> point withEvent<span class="sy0">:</span><span class="br0">&#40;</span>UIEvent <span class="sy0">*</span><span class="br0">&#41;</span>event <span class="br0">&#123;</span>
  <span class="kw1">if</span> <span class="br0">&#40;</span><span class="br0">&#91;</span>self pointInside<span class="sy0">:</span>point withEvent<span class="sy0">:</span>event<span class="br0">&#93;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
    <span class="kw1">return</span> scrollView;
  <span class="br0">&#125;</span>
  <span class="kw1">return</span> <span class="kw2">nil</span>;
<span class="br0">&#125;</span></div>
</div>
</pre>
<p><strong>Problem 2 &#8211; I want more than three pages on the screen</strong></p>
<p>I actually needed to display 7 small images on the screen at one time. It was a horizontal bar that was the full width of the screen and held about 50 pages. Things were working in that I could swipe anywhere in that bar and I did get my nice &#8216;snap-to&#8217; effect from the paging. However, things were a little too rigid. I got the &#8216;snap-to&#8217; effect but had no momentum with my swipe. Swiping would instantly stop at the nearest page when I lifted my finger.</p>
<p><strong>Solution 2 &#8211; I guess I don&#8217;t want paging after all</strong></p>
<p>I determined that paging isn&#8217;t really what I was trying to achieve. What I really wanted was to have normal swiping, but have the UIScrollView &#8216;snap-to&#8217; the center of the nearest page once it stopped. So it was a combination of &#8216;snap-to&#8217; and momentum. To achieve this I entirely removed my previous solution and turned off paging. At this point I had just a free scrolling UIScrollView.</p>
<p>What I then did was monitored the UIScrollView to determine when it started to slow down. If it slowed down to a certain point then I knew it was about to stop. At that point we just set the content offset and set animation to &#8216;YES&#8217;. This provides a seamless animation for the whole process. I also need to have the &#8216;snap-to&#8217; effect when just dragging, but not necessarily swiping.</p>
<pre>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co1">#pragma mark - UIScrollViewDelegate</span>

<span class="co2">// Note the width of my pages is set to 52px</span>

<span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>scrollViewDidEndDragging<span class="sy0">:</span><span class="br0">&#40;</span>UIScrollView <span class="sy0">*</span><span class="br0">&#41;</span>scrollView willDecelerate<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">BOOL</span><span class="br0">&#41;</span>decelerate <span class="br0">&#123;</span>
&nbsp; &nbsp; monitorVelocity <span class="sy0">=</span> decelerate;
&nbsp; &nbsp; currentTime <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSDate_Class/"><span class="kw5">NSDate</span></a> date<span class="br0">&#93;</span> timeIntervalSince1970<span class="br0">&#93;</span>;
&nbsp; &nbsp; prevTime <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSDate_Class/"><span class="kw5">NSDate</span></a> date<span class="br0">&#93;</span> timeIntervalSince1970<span class="br0">&#93;</span>;
&nbsp; &nbsp; currentPosition <span class="sy0">=</span> pickerScrollView.contentOffset.x;
&nbsp; &nbsp; prevPosition <span class="sy0">=</span> pickerScrollView.contentOffset.x;
&nbsp; &nbsp; 
&nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span><span class="sy0">!</span>decelerate<span class="br0">&#41;</span> <span class="br0">&#123;</span>
&nbsp; &nbsp; &nbsp; &nbsp; CGFloat offset <span class="sy0">=</span> round<span class="br0">&#40;</span>currentPosition<span class="sy0">/</span>52<span class="br0">&#41;</span><span class="sy0">*</span><span class="nu0">52</span>;
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co2">// only snap-to if offset is within content bounds to prevent interference with the scrollviews bounce property</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>currentPosition <span class="sy0">&amp;</span>gt; 0 <span class="sy0">&amp;</span>amp;<span class="sy0">&amp;</span>amp; offset <span class="sy0">&amp;</span>lt; pickerScrollView.contentSize.width <span class="sy0">&amp;</span>amp;<span class="sy0">&amp;</span>amp; currentPosition <span class="sy0">&amp;</span>lt; pickerScrollView.contentSize.width<span class="sy0">-</span>52<span class="br0">&#41;</span> <span class="br0">&#123;</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>pickerScrollView setContentOffset<span class="sy0">:</span>CGPointMake<span class="br0">&#40;</span>offset,0<span class="br0">&#41;</span> animated<span class="sy0">:</span><span class="kw2">YES</span><span class="br0">&#93;</span>;
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span>
&nbsp; &nbsp; <span class="br0">&#125;</span>
<span class="br0">&#125;</span>

<span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>scrollViewDidScroll<span class="sy0">:</span><span class="br0">&#40;</span>UIScrollView <span class="sy0">*</span><span class="br0">&#41;</span>scrollView <span class="br0">&#123;</span>
&nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>monitorVelocity<span class="br0">&#41;</span> <span class="br0">&#123;</span>
&nbsp; &nbsp; &nbsp; &nbsp; currentTime <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSDate_Class/"><span class="kw5">NSDate</span></a> date<span class="br0">&#93;</span> timeIntervalSince1970<span class="br0">&#93;</span>;
&nbsp; &nbsp; &nbsp; &nbsp; currentPosition <span class="sy0">=</span> pickerScrollView.contentOffset.x;
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">float</span> velocity <span class="sy0">=</span> <a href="http://www.opengroup.org/onlinepubs/009695399/functions/abs.html"><span class="kw3">abs</span></a><span class="br0">&#40;</span><span class="br0">&#40;</span>currentPosition <span class="sy0">-</span> prevPosition<span class="br0">&#41;</span> <span class="sy0">/</span> <span class="br0">&#40;</span>currentTime <span class="sy0">-</span> prevTime<span class="br0">&#41;</span><span class="br0">&#41;</span>;
&nbsp; &nbsp; &nbsp; &nbsp; prevTime <span class="sy0">=</span> currentTime;
&nbsp; &nbsp; &nbsp; &nbsp; prevPosition <span class="sy0">=</span> currentPosition;
&nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>velocity &nbsp;10<span class="br0">&#41;</span> <span class="br0">&#123;</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; monitorVelocity <span class="sy0">=</span> <span class="kw2">NO</span>;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CGFloat offset <span class="sy0">=</span> round<span class="br0">&#40;</span>currentPosition<span class="sy0">/</span>52<span class="br0">&#41;</span><span class="sy0">*</span><span class="nu0">52</span>;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co2">// only snap-to if offset is within content bounds to prevent interference with the scrollviews bounce property</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>currentPosition <span class="sy0">&amp;</span>gt; 0 <span class="sy0">&amp;</span>amp;<span class="sy0">&amp;</span>amp; offset <span class="sy0">&amp;</span>lt; pickerScrollView.contentSize.width <span class="sy0">&amp;</span>amp;<span class="sy0">&amp;</span>amp; currentPosition <span class="sy0">&amp;</span>lt; pickerScrollView.contentSize.width<span class="sy0">-</span>52<span class="br0">&#41;</span> <span class="br0">&#123;</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>pickerScrollView setContentOffset<span class="sy0">:</span>CGPointMake<span class="br0">&#40;</span>offset,0<span class="br0">&#41;</span> animated<span class="sy0">:</span><span class="kw2">YES</span><span class="br0">&#93;</span>;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span>
&nbsp; &nbsp; <span class="br0">&#125;</span>
<span class="br0">&#125;</span></div>
</div>
</pre>
</div>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.accella.net/objective-c-multiple-pages-in-a-uiscrollview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to build a Blackberry App in 4 weeks</title>
		<link>http://www.accella.net/how-to-build-a-blackberry-app-in-4-weeks/</link>
		<comments>http://www.accella.net/how-to-build-a-blackberry-app-in-4-weeks/#comments</comments>
		<pubDate>Thu, 10 Mar 2011 15:43:35 +0000</pubDate>
		<dc:creator>Jacob Haskins</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[Mobile Development]]></category>

		<guid isPermaLink="false">http://www.accella.net/?p=1907</guid>
		<description><![CDATA[Building your first Blackberry app could be roughly compared to surgery&#8230; that you perform on yourself&#8230; without anesthesia. Yes, it is an excruciatingly painful and scary experience that you might not survive. However, having successfully completed my first Blackberry app, I am here to share with you a few things I learned along the way [...]]]></description>
			<content:encoded><![CDATA[<p>Building your first Blackberry app could be roughly compared to surgery&#8230; that you perform on yourself&#8230; without anesthesia. Yes, it is an excruciatingly painful and scary experience that you might not survive. However, having successfully completed my first Blackberry app, I am here to share with you a few things I learned along the way in this rough journal of my journey.</p>
<p><strong>Week 1 &#8211; Excitement</strong></p>
<p>Going into my project I had an abundance of excitement. Stepping into this unknown territory was a huge adrenaline rush. I had never built a Blackberry app, had no Java experience and had not even used a Blackberry before. This would definitely be a challenge for me. Having a positive attitude is important for any project that you work on. A positive outlook will help you not give up when faced with problems. During the first week I didn&#8217;t really learn anything or make very much progress in the app development, but was still happy and optimistic about the project.</p>
<p><strong>Week 2 &#8211; Despair</strong></p>
<p>By week two I fully realized that blackberry development was nothing like I expected. Sure, I had the api documentation, but the developer community was very small, quite unlike the iPhone or Actionscript developer community. The api has many limitations. The way the UI is built is confusing and still irritates me. Overall I felt like I was building an app using a language that was old and dead. I began to make a little progress. However, I didn&#8217;t fully grasp how things worked.</p>
<p><strong>Week 3 &#8211; Understanding</strong></p>
<p>Progress started to flow much more rapidly in week three. I was finally beginning to understand a bit more about blackberry development. One of the most difficult things for me was figuring out how to develop the UI. My thinking here had previously been create an object, set its properties, give it some styling rules and finally position it. Doing this for the blackberry kind of makes me think of html tables. Layout of UI objects is done by using Managers. You can use HorizontalFieldManager (aka &lt;tr&gt;), VerticalFieldManager (aka &lt;td&gt;) or create your own Manager. Here my thinking had to shift from using a screen position for objects, to using a layout for objects. For many things, you could not just change the color of something or some other small change just by modifying a property of the object. Instead, you need to subclass the object or override some of the object methods. So overall, getting the app to look the way I wanted was much more involved and tedious than other languages that I&#8217;ve worked with. The sample apps provided by RIM, and a few of the apps that I seen on the device are just plain ugly. I guess the reason for that is it takes a lot of patience and effort to make something that looks decent.</p>
<p><strong>Week 4 &#8211; Finishing Touche</strong>s</p>
<p>The app was coming together. It was functioning properly, it looked good and all that remained was a few loose ends to finish the project. I needed to make a few design changes, implement some screen management and do some final tests on a device. After that was done I remembered that I&#8217;m developing for several devices and OS versions. I probably should have thought of that sooner. Thankfully, there were no major problems that I saw and was able to release the app on time.</p>
<p><strong>Conclusion</strong></p>
<p>I think I was able to take away several things from this project. First and most important: I personally hate Blackberry devices, despise their api and I hope soon Android and Apple will crush them into oblivion with their far superior and powerful devices and operating systems. However, as long as they are around and there is a demand for apps, I will continue to drag myself through the minefield that is Blackberry development. Secondly, this project helped me strengthen my adaptive programming muscles, which is always a good thing.</p>
<p>Lastly I want to offer a bit of encouragement to you. Are you working on developing your first blackberry app but on the brink of giving up because it&#8217;s just too much of a daunting task for one person? Are you needing an app built but finding it difficult to find a competent team of professionals? If you answered &#8216;yes&#8217; to either of those questions then I would like to encourage you to contact <a title="team Accella" href="http://www.accella.net/meet-the-team/">the best mobile development team in the entire world</a> at Accella.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.accella.net/how-to-build-a-blackberry-app-in-4-weeks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing the Blackberry JDE on 64-bit Windows</title>
		<link>http://www.accella.net/installing-the-blackberry-jde-on-64-bit-windows/</link>
		<comments>http://www.accella.net/installing-the-blackberry-jde-on-64-bit-windows/#comments</comments>
		<pubDate>Mon, 07 Feb 2011 20:30:30 +0000</pubDate>
		<dc:creator>Jacob Haskins</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[Mobile Development]]></category>

		<guid isPermaLink="false">http://www.accella.net/?p=1673</guid>
		<description><![CDATA[When installing the blackberry JDE on 64-bit Windows, expect to run into several problems.  There are two big problems that I encountered when trying to get setup. Problem 1 &#8211; Cannot find javaw After running through the installation and trying to start the JDE, I received an error message saying &#8216;cannot find javaw&#8217;. That was [...]]]></description>
			<content:encoded><![CDATA[<p>When installing the blackberry JDE on 64-bit Windows, expect to run into several problems.  There are two big problems that I encountered when trying to get setup.</p>
<p><strong>Problem 1 &#8211; Cannot find javaw</strong></p>
<p>After running through the installation and trying to start the JDE, I received an error message saying &#8216;cannot find javaw&#8217;. That was odd to me because I was sure I had JDK installed. The problem was that the Blackberry JDE is not compatible with the 64-bit version of JDK, which is what I had. However, after downloading the 32-bit version of JDK, I found a second problem.</p>
<p><strong>Problem 2 &#8211; Cannot find RIMIDEWin32Util.dll</strong></p>
<p>Now I was confused. I was certain I had everything installed properly, but I was still receiving errors. A few forum posts suggested setting path and javahome to their full locations. Open up the following file:</p>
<p>C:\Program Files (x86)\Research In Motion\BlackBerry JDE 6.0.0\bin\ide.bat</p>
<p>Once opened we are going to add 2 lines to the beginning of the file. Change the file from this:</p>
<p>start javaw -Xmx1024M -DRIM_RUNTIME=..\lib -DRIM_BIN=..\bin -jar IDE.jar</p>
<p>to this:</p>
<p>SET PATH=C:\Program Files (x86)\Java\jdk1.6.0_22\bin;%PATH%<br />
SET JAVAHOME=C:\Program Files (x86)\Java\jdk1.6.0_22<br />
start javaw -Xmx1024M -DRIM_RUNTIME=..\lib -DRIM_BIN=..\bin -jar IDE.jar</p>
<p>Save, close and try to start the JDE. This time you should be error free.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.accella.net/installing-the-blackberry-jde-on-64-bit-windows/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Objective C &#8211; Using a UIScrollView for Infinite Page Loops</title>
		<link>http://www.accella.net/objective-c-using-a-uiscrollview-for-infinite-page-loops/</link>
		<comments>http://www.accella.net/objective-c-using-a-uiscrollview-for-infinite-page-loops/#comments</comments>
		<pubDate>Sun, 10 Oct 2010 20:53:06 +0000</pubDate>
		<dc:creator>Jacob Haskins</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[Mobile Development]]></category>

		<guid isPermaLink="false">http://www.accella.net/?p=1080</guid>
		<description><![CDATA[When creating paging functionality for iPhone apps, there may be times that an infinite page loop would be desired. For example, if you have a small gallery of photos you are displaying, you may want to swipe through the set and have it start back at the beginning once you reach the end. The user [...]]]></description>
			<content:encoded><![CDATA[<p>When creating paging functionality for iPhone apps, there may be times that an infinite page loop would be desired. For example, if you have a small gallery of photos you are displaying, you may want to swipe through the set and have it start back at the beginning once you reach the end. The user would be able to continue swiping as much as they wanted in one direction to continue to view the content. Here are two strategies for achieving this result:</p>
<p>(<strong>UPDATE</strong>: Example code below now more extensive and bug free. Example project can be downloaded at end of article.)</p>
<p><strong>Duplicate end caps</strong></p>
<p>The first option is best suited for smaller loops. Suppose you have ten photos to display. When the user is on photo one and swipes left, it will take the user to photo ten. When the user is on photo ten and swipes right, it will take the user to photo one. The logic we will follow here is to add photos in order, but place an duplicate of photo ten to the left of photo one and a duplicate of photo one to the right of photo ten.</p>
<p><a href="http://www.accella.net/wp-content/uploads/2010/10/infinite_loops.jpg"><img class="alignnone size-full wp-image-1081" src="http://www.accella.net/wp-content/uploads/2010/10/infinite_loops.jpg" alt="" width="598" height="126" /></a></p>
<p>Now when the user scrolls to the end, we reposition the content offset of our UIScrollView. By having a duplicate photo at the end and repositioning the offset without using animation, we create a seamless experience for the user.</p>
<pre>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>scrollViewDidEndDecelerating<span class="sy0">:</span><span class="br0">&#40;</span>UIScrollView <span class="sy0">*</span><span class="br0">&#41;</span>sender <span class="br0">&#123;</span>
    <span class="co2">// The key is repositioning without animation</span>
    <span class="kw1">if</span> <span class="br0">&#40;</span>scrollView.contentOffset.x <span class="sy0">==</span> <span class="nu0">0</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
        <span class="co2">// user is scrolling to the left from image 1 to image 10.</span>
        <span class="co2">// reposition offset to show image 10 that is on the right in the scroll view</span>
        <span class="br0">&#91;</span>scrollView scrollRectToVisible<span class="sy0">:</span>CGRectMake<span class="br0">&#40;</span>3520,0,320,480<span class="br0">&#41;</span> animated<span class="sy0">:</span><span class="kw2">NO</span><span class="br0">&#93;</span>;
    <span class="br0">&#125;</span>
    <span class="kw1">else</span> <span class="kw1">if</span> <span class="br0">&#40;</span>scrollView.contentOffset.x <span class="sy0">==</span> <span class="nu0">3840</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
        <span class="co2">// user is scrolling to the right from image 10 to image 1.</span>
        <span class="co2">// reposition offset to show image 1 that is on the left in the scroll view</span>
        <span class="br0">&#91;</span>scrollView scrollRectToVisible<span class="sy0">:</span>CGRectMake<span class="br0">&#40;</span>320,0,320,480<span class="br0">&#41;</span> animated<span class="sy0">:</span><span class="kw2">NO</span><span class="br0">&#93;</span>;
    <span class="br0">&#125;</span>
<span class="br0">&#125;</span></div>
</div>
</pre>
<p><strong>3 Pages Only</strong></p>
<p>There may be times when you want an infinite page loop, but don&#8217;t want to load in a lot of content. For example, I recently worked on a project that displayed a different document with an image and text for every day of the year. The client wanted an infinite page loop so that the user would be able to scroll through the documents. However, that would be far too much data to load into a UIScrollView all at once. A different approach was needed.</p>
<p>The logic that I used was to keep the UIScrollView at just three pages. A document would load on each page and the user would always be looking at the document in the middle page. When the user scrolled to a new page, the content for each document would be reset and the offset would go back the user is back to viewing the middle page.</p>
<pre>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>viewDidLoad <span class="br0">&#123;</span>
&nbsp; &nbsp; <span class="br0">&#91;</span>super viewDidLoad<span class="br0">&#93;</span>;

&nbsp; &nbsp; &nbsp; &nbsp; documentTitles <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSMutableArray_Class/"><span class="kw5">NSMutableArray</span></a> alloc<span class="br0">&#93;</span> init<span class="br0">&#93;</span>;

&nbsp; &nbsp; &nbsp; &nbsp; <span class="co2">// create our array of documents</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">for</span> <span class="br0">&#40;</span><span class="kw4">int</span> i <span class="sy0">=</span> <span class="nu0">0</span>; i <span class="sy0">&amp;</span>lt; <span class="nu0">10</span>; i<span class="sy0">++</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>documentTitles addObject<span class="sy0">:</span><span class="br0">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span class="kw5">NSString</span></a> stringWithFormat<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;Document %i&quot;</span>,i<span class="sy0">+</span>1<span class="br0">&#93;</span><span class="br0">&#93;</span>;
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span>

&nbsp; &nbsp; &nbsp; &nbsp; <span class="co2">// create placeholders for each of our documents</span>
&nbsp; &nbsp; &nbsp; &nbsp; pageOneDoc <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>UILabel alloc<span class="br0">&#93;</span> initWithFrame<span class="sy0">:</span>CGRectMake<span class="br0">&#40;</span>0, 0, 320, 44<span class="br0">&#41;</span><span class="br0">&#93;</span>;
&nbsp; &nbsp; &nbsp; &nbsp; pageTwoDoc <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>UILabel alloc<span class="br0">&#93;</span> initWithFrame<span class="sy0">:</span>CGRectMake<span class="br0">&#40;</span>320, 0, 320, 44<span class="br0">&#41;</span><span class="br0">&#93;</span>;
&nbsp; &nbsp; &nbsp; &nbsp; pageThreeDoc <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>UILabel alloc<span class="br0">&#93;</span> initWithFrame<span class="sy0">:</span>CGRectMake<span class="br0">&#40;</span>640, 0, 320, 44<span class="br0">&#41;</span><span class="br0">&#93;</span>;

&nbsp; &nbsp; &nbsp; &nbsp; pageOneDoc.textAlignment <span class="sy0">=</span> UITextAlignmentCenter;
&nbsp; &nbsp; &nbsp; &nbsp; pageTwoDoc.textAlignment <span class="sy0">=</span> UITextAlignmentCenter;
&nbsp; &nbsp; &nbsp; &nbsp; pageThreeDoc.textAlignment <span class="sy0">=</span> UITextAlignmentCenter;

&nbsp; &nbsp; &nbsp; &nbsp; <span class="co2">// load all three pages into our scroll view</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>self loadPageWithId<span class="sy0">:</span>9 onPage<span class="sy0">:</span>0<span class="br0">&#93;</span>;
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>self loadPageWithId<span class="sy0">:</span>0 onPage<span class="sy0">:</span>1<span class="br0">&#93;</span>;
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>self loadPageWithId<span class="sy0">:</span>1 onPage<span class="sy0">:</span>2<span class="br0">&#93;</span>;

&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>scrollView addSubview<span class="sy0">:</span>pageOneDoc<span class="br0">&#93;</span>;
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>scrollView addSubview<span class="sy0">:</span>pageTwoDoc<span class="br0">&#93;</span>;
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>scrollView addSubview<span class="sy0">:</span>pageThreeDoc<span class="br0">&#93;</span>;

&nbsp; &nbsp; &nbsp; &nbsp; <span class="co2">// adjust content size for three pages of data and reposition to center page</span>
&nbsp; &nbsp; &nbsp; &nbsp; scrollView.contentSize <span class="sy0">=</span> CGSizeMake<span class="br0">&#40;</span>960, 416<span class="br0">&#41;</span>;
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>scrollView scrollRectToVisible<span class="sy0">:</span>CGRectMake<span class="br0">&#40;</span>320,0,320,416<span class="br0">&#41;</span> animated<span class="sy0">:</span><span class="kw2">NO</span><span class="br0">&#93;</span>;
<span class="br0">&#125;</span>

<span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>loadPageWithId<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">int</span><span class="br0">&#41;</span>index onPage<span class="sy0">:</span><span class="br0">&#40;</span><span class="kw4">int</span><span class="br0">&#41;</span>page <span class="br0">&#123;</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co2">// load data for page</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">switch</span> <span class="br0">&#40;</span>page<span class="br0">&#41;</span> <span class="br0">&#123;</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">case</span> 0<span class="sy0">:</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pageOneDoc.text <span class="sy0">=</span> <span class="br0">&#91;</span>documentTitles objectAtIndex<span class="sy0">:</span>index<span class="br0">&#93;</span>;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">break</span>;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">case</span> 1<span class="sy0">:</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pageTwoDoc.text <span class="sy0">=</span> <span class="br0">&#91;</span>documentTitles objectAtIndex<span class="sy0">:</span>index<span class="br0">&#93;</span>;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">break</span>;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">case</span> 2<span class="sy0">:</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pageThreeDoc.text <span class="sy0">=</span> <span class="br0">&#91;</span>documentTitles objectAtIndex<span class="sy0">:</span>index<span class="br0">&#93;</span>;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">break</span>;
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span>
<span class="br0">&#125;</span>

<span class="sy0">-</span> <span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span>scrollViewDidEndDecelerating<span class="sy0">:</span><span class="br0">&#40;</span>UIScrollView <span class="sy0">*</span><span class="br0">&#41;</span>sender <span class="br0">&#123;</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co2">// All data for the documents are stored in an array (documentTitles).</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co2">// We keep track of the index that we are scrolling to so that we</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co2">// know what data to load for each page.</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>scrollView.contentOffset.x <span class="sy0">&amp;</span>gt; scrollView.frame.size.width<span class="br0">&#41;</span> <span class="br0">&#123;</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co2">// We are moving forward. Load the current doc data on the first page.</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>self loadPageWithId<span class="sy0">:</span>currIndex onPage<span class="sy0">:</span>0<span class="br0">&#93;</span>;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co2">// Add one to the currentIndex or reset to 0 if we have reached the end.</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; currIndex <span class="sy0">=</span> <span class="br0">&#40;</span>currIndex $gt;<span class="sy0">=</span> <span class="br0">&#91;</span>documentTitles count<span class="br0">&#93;</span><span class="sy0">-</span>1<span class="br0">&#41;</span> ? 0 <span class="sy0">:</span> currIndex <span class="sy0">+</span> <span class="nu0">1</span>;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>self loadPageWithId<span class="sy0">:</span>currIndex onPage<span class="sy0">:</span>1<span class="br0">&#93;</span>;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co2">// Load content on the last page. This is either from the next item in the array</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co2">// or the first if we have reached the end.</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nextIndex <span class="sy0">=</span> <span class="br0">&#40;</span>currIndex $gt;<span class="sy0">=</span> <span class="br0">&#91;</span>documentTitles count<span class="br0">&#93;</span><span class="sy0">-</span>1<span class="br0">&#41;</span> ? 0 <span class="sy0">:</span> currIndex <span class="sy0">+</span> <span class="nu0">1</span>;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>self loadPageWithId<span class="sy0">:</span>nextIndex onPage<span class="sy0">:</span>2<span class="br0">&#93;</span>;
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>scrollView.contentOffset.x $lt; scrollView.frame.size.width<span class="br0">&#41;</span> <span class="br0">&#123;</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co2">// We are moving backward. Load the current doc data on the last page.</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>self loadPageWithId<span class="sy0">:</span>currIndex onPage<span class="sy0">:</span>2<span class="br0">&#93;</span>;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co2">// Subtract one from the currentIndex or go to the end if we have reached the beginning.</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; currIndex <span class="sy0">=</span> <span class="br0">&#40;</span>currIndex <span class="sy0">==</span> 0<span class="br0">&#41;</span> ? <span class="br0">&#91;</span>documentTitles count<span class="br0">&#93;</span><span class="sy0">-</span>1 <span class="sy0">:</span> currIndex <span class="sy0">-</span> <span class="nu0">1</span>;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>self loadPageWithId<span class="sy0">:</span>currIndex onPage<span class="sy0">:</span>1<span class="br0">&#93;</span>;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co2">// Load content on the first page. This is either from the prev item in the array</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co2">// or the last if we have reached the beginning.</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; prevIndex <span class="sy0">=</span> <span class="br0">&#40;</span>currIndex <span class="sy0">==</span> 0<span class="br0">&#41;</span> ? <span class="br0">&#91;</span>documentTitles count<span class="br0">&#93;</span><span class="sy0">-</span>1 <span class="sy0">:</span> currIndex <span class="sy0">-</span> <span class="nu0">1</span>;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>self loadPageWithId<span class="sy0">:</span>prevIndex onPage<span class="sy0">:</span>0<span class="br0">&#93;</span>;
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span> &nbsp; &nbsp; 

&nbsp; &nbsp; &nbsp; &nbsp; <span class="co2">// Reset offset back to middle page</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>scrollView scrollRectToVisible<span class="sy0">:</span>CGRectMake<span class="br0">&#40;</span>320,0,320,416<span class="br0">&#41;</span> animated<span class="sy0">:</span><span class="kw2">NO</span><span class="br0">&#93;</span>;
<span class="br0">&#125;</span></div>
</div>
</pre>
<pre>Source Code: <a href="http://accella.net/dev/Labs/InfiniteScrollView/InfiniteScrollView.zip">http://accella.net/dev/Labs/InfiniteScrollView/InfiniteScrollView.zip</a></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.accella.net/objective-c-using-a-uiscrollview-for-infinite-page-loops/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Git &#8211; Committing to a Branch</title>
		<link>http://www.accella.net/git-committing-to-a-branch/</link>
		<comments>http://www.accella.net/git-committing-to-a-branch/#comments</comments>
		<pubDate>Sat, 28 Aug 2010 22:02:49 +0000</pubDate>
		<dc:creator>Jacob Haskins</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[Web Design]]></category>

		<guid isPermaLink="false">http://www.accella.net/?p=740</guid>
		<description><![CDATA[Having VERY little exposure to Git, I admit I was a bit nervous learning that I would need to familiarize myself with Git for a recent project. Looking back, I realize my task was quite simple. Once I had finished developing a project, I needed to create a branch off a master Git repository and commit [...]]]></description>
			<content:encoded><![CDATA[<p>Having VERY little exposure to Git, I admit I was a bit nervous learning that I would need to familiarize myself with Git for a recent project. Looking back, I realize my task was quite simple. Once I had finished developing a project, I needed to create a branch off a master Git repository and commit the project files to the new branch. Here are the steps to take to commit to a branch as well as a few other things I learned along the way.</p>
<p>The place to start is of course in the <a href="http://help.github.com/" target="_blank">help section of GitHub</a>. You will need to install Git, generate a keypair and set you username and email into Git. Look to the help section for step by step instructions. Once you have that setup, you&#8217;re ready to start working with Git.</p>
<pre>
<div class="codesnip-container" >$ cd myProject
$ git init</div>
</pre>
<p>First, we have to setup our project directory to use Git. The code, &#8216;git init&#8217;, will do this for us. For my situation, I did not want to touch the master branch. I only wanted to work in a separate branch. I did not even want to fetch the files from the master repository.</p>
<pre>
<div class="codesnip-container" >$ git add .
$ git commit -m 'comment goes here'</div>
</pre>
<p>This code will add all the files in the directory to be committed and then commit those files with a comment. This will add the files to the master branch. However, I don&#8217;t want to change anything on GitHub in the master branch. Not to worry though, we haven&#8217;t connected to the remote URL. So, at this point it is only committing locally. Now that everything is established locally, let&#8217;s look at our branches.</p>
<pre>
<div class="codesnip-container" >$ git branch</div>
</pre>
<p>This will show you all the branches you have created, as well as list the branch you are working in with an asterisk. For now, it should only show &#8216;* master&#8217;. We are currently working in the &#8216;master&#8217; branch. My instructions were to not touch the master branch. So, let&#8217;s create a new branch:</p>
<pre>
<div class="codesnip-container" >$ git branch newBranch</div>
</pre>
<p>You have now created a new branch named, &#8216;newBranch&#8217;. If you now type &#8216;git branch&#8217;, it will list &#8216;master&#8217; and &#8216;newBranch&#8217;. However, you&#8217;ll notice that &#8216;master&#8217; still has the asterisk next to its name. We are still working in the &#8216;master&#8217; branch. To switch to our new branch, use the &#8216;checkout&#8217; command.</p>
<pre>
<div class="codesnip-container" >$ git checkout newBranch</div>
</pre>
<p>Now we are working in the right spot when we commit our project. We are going to be committing our project to a remote location, so our next step is to define that location.</p>
<pre>
<div class="codesnip-container" >$ git remote add origin git@github.com:user/repository.git</div>
</pre>
<p>This will add our remote location so when we commit our changes, it not only commits them locally, but also to the server. You can find the URL to use at the GitHub repository page. The word &#8216;origin&#8217; is the name of the remote location that we are adding. So, in the above example, we are adding the remote location &#8216;git@github.com:user/repository.git&#8217; and naming it &#8216;origin&#8217;. And now, the final magic command to get our project into GitHub:</p>
<pre>
<div class="codesnip-container" >$ git push origin newBranch</div>
</pre>
<p>Remember, &#8216;origin&#8217; is the name of our remote location that we have saved, and &#8216;newBranch&#8217; is the name of the branch that we are creating/pushing to. The project is now on GitHub in a new branch that we created just for the project. If you have any tips or suggestions for achieving this task, please do share.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.accella.net/git-committing-to-a-branch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>R.I.P. Wave</title>
		<link>http://www.accella.net/r-i-p-wave/</link>
		<comments>http://www.accella.net/r-i-p-wave/#comments</comments>
		<pubDate>Thu, 05 Aug 2010 04:14:05 +0000</pubDate>
		<dc:creator>Jacob Haskins</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[Web Design]]></category>

		<guid isPermaLink="false">http://www.accella.net/?p=691</guid>
		<description><![CDATA[Posted on the Google blog today: We have always pursued innovative projects because we want to drive breakthroughs in computer science that dramatically improve our users’ lives. Last year at Google I/O, when we launched our developer preview of Google Wave, a web app for real time communication and collaboration, it set a high bar for [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://googleblog.blogspot.com/2010/08/update-on-google-wave.html" target="_blank">Posted on the Google blog today</a>:</p>
<p>We have always pursued innovative projects because we want to drive breakthroughs in computer science that dramatically improve our users’ lives. Last year <a href="http://googleblog.blogspot.com/2009/05/went-walkabout-brought-back-google-wave.html">at Google I/O</a>, when we launched our developer preview of Google Wave, a web app for real time communication and collaboration, it set a high bar for what was possible in a web browser. We showed character-by-character live typing, and the ability to drag-and-drop files from the desktop, even “playback” the history of changes—all within a browser. Developers in the audience stood and cheered. Some even their laptops.</p>
<p>We were equally jazzed about Google Wave internally, even though we weren’t quite sure how users would respond to this radically different kind of communication. The use cases we’ve seen show the power of this technology: sharing images and other media in real time; improving spell-checking by understanding not just an individual word, but also the context of each word; and enabling third-party developers to build new tools like consumer gadgets for travel, or robots to check code.</p>
<p>But despite these wins, and numerous loyal fans, Wave has not seen the user adoption we would have liked. We don’t plan to continue developing Wave as a standalone product, but we will maintain the site at least through the end of the year and extend the technology for use in other Google projects. The central parts of the code, as well as the protocols that have driven many of Wave’s innovations, like drag-and-drop and character-by-character live typing, are already available as open source, so customers and partners can continue the innovation we began. In addition, we will work on tools so that users can easily “liberate” their content from Wave.</p>
<p>Wave has taught us a lot, and we are proud of the team for the ways in which they have pushed the boundaries of computer science. We are excited about what they will develop next as we continue to create innovations with the potential to advance technology and the wider web.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.accella.net/r-i-p-wave/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Objective C &#8211; Resizing and Masking an Image</title>
		<link>http://www.accella.net/objective-c-resizing-and-masking-an-image/</link>
		<comments>http://www.accella.net/objective-c-resizing-and-masking-an-image/#comments</comments>
		<pubDate>Tue, 03 Aug 2010 15:14:45 +0000</pubDate>
		<dc:creator>Jacob Haskins</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[Mobile Development]]></category>

		<guid isPermaLink="false">http://www.accella.net/?p=681</guid>
		<description><![CDATA[A while back I ran into a situation where I needed to be able to display an image in different parts of an app with different sizes and masks. The solution I settled on was to save one image and resize/mask it as necessary. The code below is what I used to achieve that. Image [...]]]></description>
			<content:encoded><![CDATA[<p>A while back I ran into a situation where I needed to be able to display an image in different parts of an app with different sizes and masks. The solution I settled on was to save one image and resize/mask it as necessary. The code below is what I used to achieve that.</p>
<pre>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="co2">// Returns a resized image</span>
<span class="sy0">-</span> <span class="br0">&#40;</span>UIImage<span class="sy0">*</span><span class="br0">&#41;</span>imageWithImage<span class="sy0">:</span><span class="br0">&#40;</span>UIImage<span class="sy0">*</span><span class="br0">&#41;</span>image scaledToSize<span class="sy0">:</span><span class="br0">&#40;</span>CGSize<span class="br0">&#41;</span>newSize <span class="br0">&#123;</span>
&nbsp; &nbsp; &nbsp; &nbsp; UIGraphicsBeginImageContext<span class="br0">&#40;</span>newSize<span class="br0">&#41;</span>;

&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>image drawInRect<span class="sy0">:</span>CGRectMake<span class="br0">&#40;</span>0,0,newSize.width,newSize.height<span class="br0">&#41;</span><span class="br0">&#93;</span>;
&nbsp; &nbsp; &nbsp; &nbsp; UIImage<span class="sy0">*</span> newImage <span class="sy0">=</span> UIGraphicsGetImageFromCurrentImageContext<span class="br0">&#40;</span><span class="br0">&#41;</span>;

&nbsp; &nbsp; &nbsp; &nbsp; UIGraphicsEndImageContext<span class="br0">&#40;</span><span class="br0">&#41;</span>;

&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> newImage;
<span class="br0">&#125;</span>
<span class="co2">// Returns a masked image</span>
<span class="sy0">-</span> <span class="br0">&#40;</span>UIImage<span class="sy0">*</span><span class="br0">&#41;</span> maskImage<span class="sy0">:</span><span class="br0">&#40;</span>UIImage <span class="sy0">*</span><span class="br0">&#41;</span>image withMask<span class="sy0">:</span><span class="br0">&#40;</span>UIImage <span class="sy0">*</span><span class="br0">&#41;</span>maskImage <span class="br0">&#123;</span>

&nbsp; &nbsp; &nbsp; &nbsp; CGImageRef maskRef <span class="sy0">=</span> maskImage.CGImage; 

&nbsp; &nbsp; &nbsp; &nbsp; CGImageRef mask <span class="sy0">=</span> CGImageMaskCreate<span class="br0">&#40;</span>CGImageGetWidth<span class="br0">&#40;</span>maskRef<span class="br0">&#41;</span>,
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CGImageGetHeight<span class="br0">&#40;</span>maskRef<span class="br0">&#41;</span>,
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CGImageGetBitsPerComponent<span class="br0">&#40;</span>maskRef<span class="br0">&#41;</span>,
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CGImageGetBitsPerPixel<span class="br0">&#40;</span>maskRef<span class="br0">&#41;</span>,
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CGImageGetBytesPerRow<span class="br0">&#40;</span>maskRef<span class="br0">&#41;</span>,
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CGImageGetDataProvider<span class="br0">&#40;</span>maskRef<span class="br0">&#41;</span>, <span class="kw2">NULL</span>, <span class="kw2">false</span><span class="br0">&#41;</span>;

&nbsp; &nbsp; &nbsp; &nbsp; CGImageRef masked <span class="sy0">=</span> CGImageCreateWithMask<span class="br0">&#40;</span><span class="br0">&#91;</span>image CGImage<span class="br0">&#93;</span>, mask<span class="br0">&#41;</span>;
&nbsp; &nbsp; &nbsp; &nbsp; CGImageRelease<span class="br0">&#40;</span>mask<span class="br0">&#41;</span>;
&nbsp; &nbsp; &nbsp; &nbsp; UIImage<span class="sy0">*</span> retImage<span class="sy0">=</span> <span class="br0">&#91;</span>UIImage imageWithCGImage<span class="sy0">:</span>masked<span class="br0">&#93;</span>;
&nbsp; &nbsp; &nbsp; &nbsp; CGImageRelease<span class="br0">&#40;</span>masked<span class="br0">&#41;</span>;
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> retImage;
<span class="br0">&#125;</span>

...
UIImage <span class="sy0">*</span>image <span class="sy0">=</span> <span class="br0">&#91;</span>UIImage imageNamed<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;myImage.png&quot;</span><span class="br0">&#93;</span>;
UIImage <span class="sy0">*</span>mask <span class="sy0">=</span> <span class="br0">&#91;</span>UIImage imageNamed<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;mask.png&quot;</span><span class="br0">&#93;</span>;
UIImage <span class="sy0">*</span>resizedImage <span class="sy0">=</span> <span class="br0">&#91;</span>self imageWithImage<span class="sy0">:</span>image scaledToSize<span class="sy0">:</span>CGSizeMake<span class="br0">&#40;</span>76,92<span class="br0">&#41;</span><span class="br0">&#93;</span>;
UIImage <span class="sy0">*</span>maskedImage <span class="sy0">=</span> <span class="br0">&#91;</span>self maskImage<span class="sy0">:</span>resizedImage withMask<span class="sy0">:</span>mask<span class="br0">&#93;</span>;</div>
</div>
</pre>
<p>Image masking from <a href="http://iphonedevelopertips.com/cocoa/how-to-mask-an-image.html" target="_blank">[iPhone developer:tips];</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.accella.net/objective-c-resizing-and-masking-an-image/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Book Review &#8211; iPhone Cool Projects</title>
		<link>http://www.accella.net/book-review-iphone-cool-projects/</link>
		<comments>http://www.accella.net/book-review-iphone-cool-projects/#comments</comments>
		<pubDate>Wed, 14 Jul 2010 19:58:24 +0000</pubDate>
		<dc:creator>Jacob Haskins</dc:creator>
				<category><![CDATA[Mobile Development]]></category>

		<guid isPermaLink="false">http://www.accella.net/?p=605</guid>
		<description><![CDATA[&#8216;iPhone Cool Projects&#8217; is a collaborative work of 7 developers/technical authors (Gary Bennett, Wolfgang Ante, Mike Ash, Benjamin Jackson, Neil Mix, Steven Peterson and Matthew &#8220;Canis&#8221; Rosenfeld) who bring their diverse experience into one inspiring location. With each new chapter, a new developer takes the stage and explains some potentially advanced and overwhelming concepts that [...]]]></description>
			<content:encoded><![CDATA[<p>&#8216;iPhone Cool Projects&#8217; is a collaborative work of 7 developers/technical authors (Gary Bennett, Wolfgang Ante, Mike Ash, Benjamin Jackson, Neil Mix, Steven Peterson and Matthew &#8220;Canis&#8221; Rosenfeld) who bring their diverse experience into one inspiring location. With each new chapter, a new developer takes the stage and explains some potentially advanced and overwhelming concepts that many developers face from time-to-time. Real world projects allowed them the opportunity to work on some very exciting projects. They then share the experience and knowledge that they gained and present it in a way for the reader to get a clear understanding of the logic they used when developing these projects.</p>
<p>As stated in the introduction: &#8220;This book is for all iPhone and iPod touch developers who want to know more so that they can tackle more difficult programming tasks on their way to creating the next great app&#8221;. This book is not for developers who are just beginning iPhone development. As the introduction points out (and which I wholeheartedly agree with), for beginning iPhone development, check out &#8216;Beginning iPhone Development&#8217; by Dave Mark and Jeff LaMarch. However, if you have a basic understanding of iPhone development and are ready to explore some more advanced concepts, then this is the book for you.</p>
<p>The developers in the book each touch on very different scenarios that you may face in development. These are: game timers and logic, peer-to-peer networking, multithreading, implementing multitouch, game development with cocos2d, streaming audio and finally developing with Core Location, XML, and SQLite. With such a wide range of topics, it&#8217;s likely that you won&#8217;t be working with everything that is covered in the book. On the other hand, that just means that this book will hold something for everyone.</p>
<p>One of the great things about this book is the authors strive to take these different advanced concepts, which some might find a little frightening to tackle on their own, and present them in a simplified way that invites the reader to continue challenging themselves to find a way to overcome the problems they face in development. For example, in chapter 3, Gary Bennett discusses multithreading. Though I have never worked with multithreading before, I found the chapter to be very informative and easy to grasp. Gary first helps you to understand what threading is. He then explains some pitfalls to avoid when threading. Finally, he includes some code for an app to show you how to implement it.</p>
<p>In addition to the easy explanation of key concepts, I found it quite refreshing to see the logic that other developers use to overcome the obstacles they face. As we all know, there may be many ways to approach any particular problem. The authors here explain the logic that they used when programming and why they did or did not approach the problem in that way. I find that getting a feel for the logical process that others use in development helps me think of problems from a different angle in my own work.</p>
<p>In conclusion, if you are an iPhone developer or are studying to become one, this book is a must read. It achieves its goal of helping its target audience to get into advanced development projects, it presents the information in a very clear way and above all, it&#8217;s packed with useful information that you will be able to use in your own projects.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.accella.net/book-review-iphone-cool-projects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Application Security – Securing the mail() function</title>
		<link>http://www.accella.net/php-application-security-%e2%80%93-securing-the-mail-function/</link>
		<comments>http://www.accella.net/php-application-security-%e2%80%93-securing-the-mail-function/#comments</comments>
		<pubDate>Tue, 29 Jun 2010 13:47:52 +0000</pubDate>
		<dc:creator>Jacob Haskins</dc:creator>
				<category><![CDATA[Web Design]]></category>

		<guid isPermaLink="false">http://www.accella.net/?p=305</guid>
		<description><![CDATA[Sending email through PHP is quite common in many web applications. I frequently do this when implementing a contact form. Utilizing my skills in HTML, CSS, AJAX, and PHP I create a nice contact form that looks good, functions well, and pleases the user. However, much to my shame, I discovered that my implementation was often [...]]]></description>
			<content:encoded><![CDATA[<p>Sending email through PHP is quite common in many web applications. I frequently do this when implementing a contact form. Utilizing my skills in HTML, CSS, AJAX, and PHP I create a nice contact form that looks good, functions well, and pleases the user. However, much to my shame, I discovered that my implementation was often quite insecure. Below you will find my shameful code, as well as tips on patching this type of security hole.</p>
<p><strong><em>THE PROBLEM</em></strong></p>
<pre>
<div class="codesnip-container" >
<div class="php codesnip" style="font-family:monospace;"><span class="re0">$to</span> <span class="sy0">=</span> <span class="re0">$_POST</span><span class="br0">&#91;</span><span class="st_h">'to_email'</span><span class="br0">&#93;</span><span class="sy0">;</span>
<span class="re0">$subject</span> <span class="sy0">=</span> <span class="re0">$_POST</span><span class="br0">&#91;</span><span class="st_h">'subject'</span><span class="br0">&#93;</span><span class="sy0">;</span>
<span class="re0">$message</span> <span class="sy0">=</span> <span class="re0">$_POST</span><span class="br0">&#91;</span><span class="st_h">'message'</span><span class="br0">&#93;</span><span class="sy0">;</span>
<span class="re0">$headers</span> <span class="sy0">=</span> <span class="st0">&quot;From: &quot;</span><span class="sy0">.</span><span class="re0">$_POST</span><span class="br0">&#91;</span><span class="st_h">'from_email'</span><span class="br0">&#93;</span><span class="sy0">;</span>
<a href="http://www.php.net/mail"><span class="kw3">mail</span></a><span class="br0">&#40;</span><span class="re0">$to</span><span class="sy0">,</span><span class="re0">$subject</span><span class="sy0">,</span><span class="re0">$message</span><span class="sy0">,</span><span class="re0">$headers</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</div>
</pre>
<p>This is pretty much what I had my contact form posting to. All I focused on was two things: all fields needed to be dynamic and the script needed to send mail somewhere. It got the job done, but there is absolutely no security measures in place. Anyone could set up an automated script to post to this page. Email header injection can allow the evil attacker free access to modify the email, change who it is sent to, send it to multiple people , change the content type and more. A line feed must be added for every header. Someone could then post the following:<strong><em> </em></strong></p>
<p>victim1@email.com%0ABcc:victim2@email.com</p>
<p>Using this and similar methods, the user has full control over our email script.</p>
<p><strong><em>THE SOLUTION</em></strong></p>
<p>First of all, you’ll notice that I’m not checking any data that is coming into my script. This security measure should always be in place. Therefore, each incoming piece of data should be sanitized and validated. Also, it’s good to make sure we have the latest release of PHP installed on our server. Newer versions of PHP will have improved security measures for email header injections.</p>
<p>Another added security measure that we can add is a token. A token is a random string generated and passed through the form, and stored in a session or cookie. Our mailing script can then verify that the users saved token matches what was passed to it. This way, we make sure that the mail is being submitted through our form, and not some external script. With these security measures in mind, let’s strengthen the security of our mailing script.<strong><em> </em></strong></p>
<pre>
<div class="codesnip-container" >
<div class="php codesnip" style="font-family:monospace;"><span class="coMULTI">/********* form.php *********/</span>

<span class="co1">// create a token</span>

<a href="http://www.php.net/session_start"><span class="kw3">session_start</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>

<span class="re0">$token</span> <span class="sy0">=</span> <a href="http://www.php.net/md5"><span class="kw3">md5</span></a><span class="br0">&#40;</span><a href="http://www.php.net/uniqid"><span class="kw3">uniqid</span></a><span class="br0">&#40;</span><a href="http://www.php.net/rand"><span class="kw3">rand</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">,</span> <span class="kw4">TRUE</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span>

<span class="re0">$_SESSION</span><span class="br0">&#91;</span>‘token’<span class="br0">&#93;</span> <span class="sy0">=</span> <span class="re0">$token</span><span class="sy0">;</span></div>
</div>
</pre>
<pre>
<div class="codesnip-container" >
<div class="html4strict codesnip" style="font-family:monospace;">// insert token into a hidden input inside the form
input name=&quot;token&quot; type=&quot;hidden&quot; value=&quot; $token; &quot;</div>
</div>
</pre>
<pre>
<div class="codesnip-container" >
<div class="php codesnip" style="font-family:monospace;"><span class="coMULTI">/********* form_submit_here.php *********/</span>

<a href="http://www.php.net/session_start"><span class="kw3">session_start</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>

<span class="kw2">function</span> check_token<span class="br0">&#40;</span><span class="re0">$token</span><span class="br0">&#41;</span><span class="br0">&#123;</span>

<span class="kw1">return</span><span class="br0">&#40;</span><span class="re0">$token</span> <span class="sy0">==</span> <span class="re0">$_SESSION</span><span class="br0">&#91;</span>‘token’<span class="br0">&#93;</span><span class="br0">&#41;</span> ? <span class="kw4">true</span> <span class="sy0">:</span> <span class="kw4">false</span><span class="sy0">;</span>

<span class="br0">&#125;</span>

<span class="kw2">function</span> check_string<span class="br0">&#40;</span><span class="re0">$string_to_test</span><span class="br0">&#41;</span><span class="br0">&#123;</span>

<span class="re0">$bad_words</span> <span class="sy0">=</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span>“cc”<span class="sy0">,</span> ”to”<span class="sy0">,</span> ”bcc”<span class="sy0">,</span> ”Content<span class="sy0">-</span>Transfer<span class="sy0">-</span>Encoding”<span class="sy0">,</span> ”content<span class="sy0">-</span>type”<span class="sy0">,</span> ”mime<span class="sy0">-</span>version”<span class="sy0">,</span> ”multipart<span class="sy0">/</span>mixed”<span class="sy0">,</span> ”<span class="sy0">%</span>0A”<span class="sy0">,</span> ”<span class="sy0">%</span>0D”<span class="sy0">,</span> ”\r”<span class="sy0">,</span> ”\n”<span class="br0">&#41;</span><span class="sy0">;</span>

<span class="kw1">foreach</span><span class="br0">&#40;</span><span class="re0">$bad_words</span> <span class="kw1">as</span> <span class="re0">$bad_word</span><span class="br0">&#41;</span><span class="br0">&#123;</span>

<span class="kw1">if</span><span class="br0">&#40;</span><a href="http://www.php.net/stripos"><span class="kw3">stripos</span></a><span class="br0">&#40;</span><span class="re0">$string_to_test</span><span class="sy0">,</span> <span class="re0">$bad_word</span><span class="br0">&#41;</span> <span class="sy0">!==</span> <span class="kw4">false</span><span class="br0">&#41;</span><span class="br0">&#123;</span>

<a href="http://www.php.net/exit"><span class="kw3">exit</span></a><span class="sy0">;</span> <span class="co1">// injection attack detected</span>

<span class="br0">&#125;</span>

<span class="br0">&#125;</span>

<span class="kw1">return</span> <span class="re0">$string_to_test</span><span class="sy0">;</span> <span class="co1">// no injection attack detected, string is safe to use.</span>

<span class="br0">&#125;</span>

<span class="kw1">if</span><span class="br0">&#40;</span><span class="sy0">!</span>check_token<span class="br0">&#40;</span><span class="re0">$_POST</span><span class="br0">&#91;</span>‘token’<span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>

<a href="http://www.php.net/exit"><span class="kw3">exit</span></a><span class="sy0">;</span> <span class="co1">// token doesn’t match, post came from outside our form.</span>

<span class="br0">&#125;</span>

<span class="re0">$to</span> <span class="sy0">=</span> check_string<span class="br0">&#40;</span><span class="re0">$_POST</span><span class="br0">&#91;</span>‘to_email’<span class="br0">&#93;</span><span class="br0">&#41;</span><span class="sy0">;</span>

<span class="re0">$subject</span> <span class="sy0">=</span> check_string<span class="br0">&#40;</span><span class="re0">$_POST</span><span class="br0">&#91;</span>‘subject’<span class="br0">&#93;</span><span class="br0">&#41;</span><span class="sy0">;</span>

<span class="re0">$message</span> <span class="sy0">=</span> check_string<span class="br0">&#40;</span><span class="re0">$_POST</span><span class="br0">&#91;</span>‘message’<span class="br0">&#93;</span><span class="br0">&#41;</span><span class="sy0">;</span>

<span class="re0">$headers</span> <span class="sy0">=</span> “From<span class="sy0">:</span> “<span class="sy0">.</span>check_string<span class="br0">&#40;</span><span class="re0">$_POST</span><span class="br0">&#91;</span>‘from_email’<span class="br0">&#93;</span><span class="br0">&#41;</span><span class="sy0">;</span>

<span class="co1">// token is valid and all our dynamic variables check out ok. Send the email.</span>

<a href="http://www.php.net/mail"><span class="kw3">mail</span></a><span class="br0">&#40;</span><span class="re0">$to</span><span class="sy0">,</span><span class="re0">$subject</span><span class="sy0">,</span><span class="re0">$message</span><span class="sy0">,</span><span class="re0">$headers</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</div>
</pre>
<p>Of course, there is much here that you may wish to alter such as better error handling, error logging, etc. By spending just a few extra minutes of typing, we have greatly strengthened the scripts security measures. Whatever variation of this script that you may use, make sure you validate input when working with dynamic variables. <strong> </strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.accella.net/php-application-security-%e2%80%93-securing-the-mail-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

