<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Richard Orelup</title>
    <description>The latest articles on DEV Community by Richard Orelup (@ripsup).</description>
    <link>https://dev.to/ripsup</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F37505%2F5e8da166-8acc-4e70-8d7f-dcace01d3790.jpeg</url>
      <title>DEV Community: Richard Orelup</title>
      <link>https://dev.to/ripsup</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ripsup"/>
    <language>en</language>
    <item>
      <title>Intro to developing for the Fitbit Ionic</title>
      <dc:creator>Richard Orelup</dc:creator>
      <pubDate>Mon, 15 Jan 2018 21:29:46 +0000</pubDate>
      <link>https://dev.to/ripsup/intro-to-developing-for-the-fitbit-ionic-bao</link>
      <guid>https://dev.to/ripsup/intro-to-developing-for-the-fitbit-ionic-bao</guid>
      <description>&lt;h2&gt;
  
  
  What led you to start developing on the Fitbit Ionic?
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Skip to the next section if you want to get more into the dev details.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;My current employer has a wellness program where you can earn up to $500 per year doing different tasks and tracking it.  My first year at the company (2016) everything on the site was extremely manual and annoying to track.  &lt;/p&gt;

&lt;p&gt;Last year the software they used moved to tracking steps instead of time for the majority of the challenges. They also gave us $60 off any item bought directly from Fitbit. Since Fitbit runs sales at the beginning of the year this meant I was able to score a Charge 2 with HR monitoring for $70. While I'm not normally a watch wearer or never been interested in a smart watch before, this device really intrigued me. Right away I looked at how I could customize it to have additional functionality I wanted. Unfortunately it wasn't possible and I was stuck with what it offered but the bug was planted in my head.&lt;/p&gt;

&lt;p&gt;With the announcement of the Ionic also came the announcement of the ability to write apps for the device which instantly caught my attention (plus additional features like GPS, waterproof) and I was ready to plop my money down. I decided to wait for the new year in case my work offered another rebate and I was hoping that there would be a new year sale.  So second week of January I placed my order and got it 2 days later. &lt;/p&gt;

&lt;p&gt;After waiting about an hour to get the device setup (not sure why it takes 30 minutes to download an update for the device initially, but it did), I opened up the getting started guide and 10 minutes later I had an app running on my watch.&lt;/p&gt;

&lt;h2&gt;
  
  
  What do you write it in?
&lt;/h2&gt;

&lt;p&gt;Apps are written in Javascript, SVG and CSS.  It looks like we have access to every sensor and input the device has from what the documentation says but obviously I haven't gotten to that point yet.&lt;/p&gt;

&lt;p&gt;The documentation is kept here - &lt;a href="https://dev.fitbit.com/"&gt;Fitbit Developer Site&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What's interesting though is that you are required to use their own web based IDE to write/build/deploy your apps. You can't do local development and push to your device. There is no local emulation either so you must test your work on an actual device. Your watch must also be connected to wifi to push a build to it which adds an annoyance for when you want to work on your app from someplace remote.&lt;/p&gt;

&lt;h2&gt;
  
  
  What can you do with it?
&lt;/h2&gt;

&lt;p&gt;Right now it seems like you can do a ton with the device because, on top of the buttons on the side, you have a a full touchscreen to work with. You can make calls to the web to pull data (pushing data I'm not to sure of yet cause it wasn't very clear in the documentation.) Things like controlling smart devices is pretty simple to do from your wrist. With access to all the sensor data I bet you could create some interesting UI interactions where you manipulate things with your arm. &lt;/p&gt;

&lt;p&gt;Someone created a barcode app that I'm using to get in to my local YMCA. The device has NFC built in for handling touch payments BUT I haven't found any documentation on if we can use it for other things.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's next?
&lt;/h2&gt;

&lt;p&gt;The first project I plan to do is a slider puzzle just to get myself use to working with the device. I'll try to do a build journal on here and share how it goes. I'll also open source the code for others interested in looking at it.&lt;/p&gt;

&lt;p&gt;Got any questions or ideas for things you would think would be cool to do with the device?  Share below! And thanks for reading.&lt;/p&gt;

&lt;p&gt;P.S. I find it funny how it took me 10 minutes to get an app running on my new device but 4 days to write this article.  :)&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>fitbit</category>
    </item>
    <item>
      <title>Job Application Code Challenge - a PHP solution</title>
      <dc:creator>Richard Orelup</dc:creator>
      <pubDate>Tue, 17 Oct 2017 05:13:06 +0000</pubDate>
      <link>https://dev.to/ripsup/job-application-code-challenge---a-php-solution-e3i</link>
      <guid>https://dev.to/ripsup/job-application-code-challenge---a-php-solution-e3i</guid>
      <description>&lt;p&gt;Earlier today I read &lt;a href="https://dev.to/benhayehudi"&gt;Ben Greenberg&lt;/a&gt;'s &lt;a href="https://dev.to/benhayehudi/solving-a-job-application-code-challenge-30d"&gt;job application challenge&lt;/a&gt; and thought it looked like a fun little challenge. I went to my "go to" language of PHP and knocked it out quick and noticed an error with the test string that was provided.&lt;/p&gt;

&lt;p&gt;I didn't think to share my result until I saw another post by &lt;a href="https://dev.to/rpalo"&gt;Ryan Palo&lt;/a&gt; who shared &lt;a href="https://dev.to/rpalo/secret-message-7do"&gt;his Ruby solution&lt;/a&gt; to the problem.  So here is my PHP solution to the problem.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Challenge
&lt;/h2&gt;

&lt;p&gt;The challenge is this (copied from the original post):&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Sort the characters in the following string:&lt;br&gt;
abcdefghijklmnopqrstuvwxyz_&lt;/p&gt;

&lt;p&gt;by the number of times the character appears in the following text (descending):&lt;/p&gt;

&lt;p&gt;… [String omitted for brevity]&lt;/p&gt;

&lt;p&gt;Now take the sorted string, and drop all the characters after (and including) the _. The remaining word is the answer.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You can get the example string to run your code against &lt;a href="https://repl.it/MivX"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  My Solution
&lt;/h2&gt;

&lt;p&gt;So first I saw a need to get an array with a count of all each character.  One of the nice things about PHP is that a string is an array of characters already so I didn't need to do any conversion of it.  To do this I just ran it through a for loop and went through the entire array and counted each one.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class="nv"&gt;$charCount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;array&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nb"&gt;strlen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$longString&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="k"&gt;isset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$charCount&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$longString&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="p"&gt;]]))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$charCount&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$longString&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nv"&gt;$charCount&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$longString&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now that I have an array with the key being the character and the value containing the count, we need to sort the array.  This is done simply the arsort().&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class="nb"&gt;arsort&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$charCount&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="cp"&gt;?&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next we needed use implode() to concatenate all the items in the array into one string. Then it hit me that I needed to do this for the keys instead of the values of the array so I combined implode() with array_keys() to accomplish this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class="nv"&gt;$sortedString&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;implode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;array_keys&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$charCount&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="cp"&gt;?&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The last step was to drop everything including the "_" so I used explode() and, since this returns an array of strings, returned only the first string in that array which will be the word we are looking for.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Solution
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class="nv"&gt;$charCount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;array&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nb"&gt;strlen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$longString&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="k"&gt;isset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$charCount&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$longString&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="p"&gt;]]))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$charCount&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$longString&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nv"&gt;$charCount&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$longString&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nb"&gt;arsort&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$charCount&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nv"&gt;$sortedString&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;implode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;array_keys&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$charCount&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="nv"&gt;$theWord&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;explode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"_"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nv"&gt;$sortedString&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="cp"&gt;?&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I can think of other ways (like using a reduce similar to Ben's JS solution) to solve this in PHP but this was the first method that hit me.  If you have a different version you like more please share it (and why) below cause I'd love to see it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Another Solution
&lt;/h2&gt;

&lt;p&gt;The second I hit publish I thought "I bet there is a PHP function that I could use instead of the for loop that would make this even cleaner" and 5 seconds later I had it - array_count_values()&lt;/p&gt;

&lt;p&gt;The one issue I ran in to though with attempting to use this function though was that it would treat $longString as a String and not an Array. To fix that I combined it with str_split() and now we have the simpler solution below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class="nv"&gt;$charCount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;array_count_values&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;str_split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$longString&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

&lt;span class="nb"&gt;arsort&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$charCount&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nv"&gt;$sortedString&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;implode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;array_keys&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$charCount&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="nv"&gt;$theWord&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;explode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"_"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nv"&gt;$sortedString&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="cp"&gt;?&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Performance Increase
&lt;/h3&gt;

&lt;p&gt;As with most cases when using a built in PHP function over writing your own, there is a performance increase for doing this.&lt;/p&gt;

&lt;p&gt;I threw together a quick test script where I ran each version 1000 times and the second solution was just over twice as fast as the original.  So whenever possible, just use what PHP gives you.  :)&lt;/p&gt;

</description>
      <category>php</category>
      <category>beginners</category>
      <category>interview</category>
    </item>
  </channel>
</rss>
