<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jesse Sessler on Medium]]></title>
        <description><![CDATA[Stories by Jesse Sessler on Medium]]></description>
        <link>https://medium.com/@jsessler?source=rss-81a04ace1263------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*RDRo9cClQAOLNwkvsigndg.jpeg</url>
            <title>Stories by Jesse Sessler on Medium</title>
            <link>https://medium.com/@jsessler?source=rss-81a04ace1263------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 11:17:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jsessler/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[React Native: Stop Shaking Your Phone!]]></title>
            <link>https://medium.com/delivery-com-engineering/react-native-stop-shaking-your-phone-1f4863140146?source=rss-81a04ace1263------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f4863140146</guid>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Jesse Sessler]]></dc:creator>
            <pubDate>Thu, 05 May 2016 15:43:11 GMT</pubDate>
            <atom:updated>2016-05-05T20:33:04.212Z</atom:updated>
            <content:encoded><![CDATA[<p>If you’re developing a React Native app on an Android device then you know this story.</p><p>You’re sitting there holding your $500 phone plugged in to your $2,000 MacBook and you need to reload the app. So you shake it. You’re nervous because you probably shake it 300 times a day and one of these days it’s going to slip and now you’re out $2,500. The worrying makes your hands sweaty, only increasing the likelihood of a slip-up, so you get even more nervous and… well, you get the idea.</p><p>Here’s a nifty trick to prevent that from happening, and to make life just a little bit easier during development. <strong>You can set up a keyboard shortcut to open the menu on your phone from your laptop</strong>.</p><ol><li>Set up an Automator Service by opening Automator, clicking “New Document”, and choosing “Service”.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*LbOUt_-w8bbtGIh_nUUeUA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/1*UR6mQHL9E4GnmEOkitNZ-A.png" /></figure><p>2. Find and select the “Run Shell Script” action. Choose “no input” for “Service receives” and enter:</p><pre>/usr/local/bin/adb shell input keyevent 82</pre><p>If adb is located elsewhere in your system, change the path to adb. You can find out with:</p><pre>$ which adb</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/663/1*hgTA3Wvo_qxRQSBXwE5qDQ.png" /></figure><p>3. Save and remember what name you give the action.</p><p>4. Open “System Preferences”, go to “Keyboard” and select the “Shortcuts” tab. Select “Services” on the left column and find your service by name.</p><p>5. Click where it says “none” and enter the keyboard shortcut you want to use. Make it something unique or it will conflict with an existing shortcut.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/447/1*3PozIEnJqbLasThMagqfyw.png" /></figure><p>Notes:</p><ul><li>Android only</li><li>Must be plugged in</li><li>If you’ve never run the following with this device, run it first before trying the shortcut:</li></ul><pre>$ adb reverse tcp:8081 tcp:8081</pre><p>And that’s it. Enjoy!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f4863140146" width="1" height="1" alt=""><hr><p><a href="https://medium.com/delivery-com-engineering/react-native-stop-shaking-your-phone-1f4863140146">React Native: Stop Shaking Your Phone!</a> was originally published in <a href="https://medium.com/delivery-com-engineering">Delivery.com Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Native in an Existing iOS App: Dynamic Routing.]]></title>
            <link>https://medium.com/delivery-com-engineering/react-native-in-an-existing-ios-app-dynamic-routing-7013e03fa9ad?source=rss-81a04ace1263------2</link>
            <guid isPermaLink="false">https://medium.com/p/7013e03fa9ad</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Jesse Sessler]]></dc:creator>
            <pubDate>Thu, 21 Jan 2016 20:05:04 GMT</pubDate>
            <atom:updated>2016-01-21T20:13:57.598Z</atom:updated>
            <content:encoded><![CDATA[<p><em>This guide is </em>Part Two<em> in our four-part series </em>Using React Native in an Existing iOS App<em>. </em><a href="https://medium.com/delivery-com-engineering/react-native-in-an-existing-ios-app-delivered-874ba95a3c52"><em>Click here for </em>Part One: Getting Started.</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/705/1*PTMKjjyukuK9uExWoJME4w.png" /></figure><p>Now that we have the ability to use a React Native View anywhere in our app, we need to be able to render different views for different use cases. In other words, we need a router. For this we’ll use the <a href="https://facebook.github.io/react-native/docs/navigator.html">&lt;Navigator /&gt;</a> component provided by RN.</p><p>Originally our two native buttons rendered the same RN View. Now we’re going to alter these button actions to route to two different views by passing the route name to our RCTRootView.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/280/1*yBJhgN25kaOYYlUzDOwLZw.gif" /></figure><p><strong>React View 1 (Obj C View) </strong>renders our content and a background color changing component.</p><p><strong>React View 2 (Swift) </strong>simply renders the content.</p><p>You can find all of the code here on Github: <a href="https://github.com/Deliverydotcom/ReactNativeHybridExample/tree/navigator-routing">https://github.com/Deliverydotcom/ReactNativeHybridExample/tree/navigator-routing</a></p><h4>File Structure</h4><p>Let’s have a look at the file structure for our <strong>ReactComponents</strong> folder:</p><p>.<br>├── Components<br>│ └── ChangeBackground.js<br>├── Views<br>│ ├── ObjectiveCView.js<br>│ └── SwiftView.js<br>├── index.ios.js<br>├── node_modules<br>│ └── react-native<br>└── package.json</p><p>The <strong>Views </strong>folder contains any components that the router will render. The <strong>Components </strong>folder contains any child components needed by the Views.</p><h4>The Router</h4><p>The first thing we need to define is the <strong>RouteStack</strong>. This maps each route name to the view component that should be rendered. Following <a href="https://facebook.github.io/react-native/docs/navigator.html">the documentation</a> we need a <strong>renderScene</strong> method and an <strong>initialRoute </strong>object. In the <strong>renderScene </strong>method we’ll pass our props to the view component so it has access to data passed from Objective C or Swift. We’ll also pass a reference to the &lt;Navigator /&gt; itself so the view component can push more views on the stack, but we won’t be doing that here.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c7b98f5a680684f6620504088c4ece13/href">https://medium.com/media/c7b98f5a680684f6620504088c4ece13/href</a></iframe><h4>UIViewController Changes</h4><p>We just need to make a small change to our <strong>ReactNativeViewController </strong>(from <a href="https://medium.com/delivery-com-engineering/react-native-in-an-existing-ios-app-delivered-874ba95a3c52">Part 1</a>) to pass the route name to <strong>data</strong>. We’ll add a public property called <strong>route </strong>so we can pass a route from anywhere in our app.</p><p><em>Objective C:</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/042bc9e023d68e95fe6558c3fbc10dbf/href">https://medium.com/media/042bc9e023d68e95fe6558c3fbc10dbf/href</a></iframe><p><em>Swift:</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d6c9cbd46e9b4275489d5886878ca80c/href">https://medium.com/media/d6c9cbd46e9b4275489d5886878ca80c/href</a></iframe><p>Now we can set the route for our respective button click events.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1e699ffed24f3a5493b7668caae27b6c/href">https://medium.com/media/1e699ffed24f3a5493b7668caae27b6c/href</a></iframe><p>And that’s it!</p><p>Dynamic routing using the &lt;Navigator/&gt;. Delivered.</p><p>Up next, we’ll talk about using <a href="http://microsoft.github.io/code-push/">Codepush</a> to push instant app updates. Stay tuned!</p><p>If you have any questions or comments, feel free to reach out to us on Twitter at <a href="https://medium.com/u/81a04ace1263">Jesse Sessler</a> and <a href="https://medium.com/u/f4d1a315ca06">Bruno Barbieri</a> and on Discord at <strong>jemise111 </strong>and <strong>brunobar79.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7013e03fa9ad" width="1" height="1" alt=""><hr><p><a href="https://medium.com/delivery-com-engineering/react-native-in-an-existing-ios-app-dynamic-routing-7013e03fa9ad">React Native in an Existing iOS App: Dynamic Routing.</a> was originally published in <a href="https://medium.com/delivery-com-engineering">Delivery.com Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Native in an Existing iOS App: Getting Started.]]></title>
            <link>https://medium.com/delivery-com-engineering/react-native-in-an-existing-ios-app-delivered-874ba95a3c52?source=rss-81a04ace1263------2</link>
            <guid isPermaLink="false">https://medium.com/p/874ba95a3c52</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Jesse Sessler]]></dc:creator>
            <pubDate>Fri, 08 Jan 2016 20:56:29 GMT</pubDate>
            <atom:updated>2016-01-21T20:12:14.050Z</atom:updated>
            <content:encoded><![CDATA[<p><em>This guide is </em>Part One<em> in our four-part series </em>Using React Native in an Existing iOS App<em>. </em><a href="https://medium.com/delivery-com-engineering/react-native-in-an-existing-ios-app-dynamic-routing-7013e03fa9ad"><em>Click here for </em>Part Two: Dynamic Routing</a>.</p><p>Two months ago, we at <a href="https://delivery.com/">delivery.com</a> released our new <a href="https://itunes.apple.com/us/app/delivery.com-food-alcohol/id435168129?mt=8">iOS app</a>. With so many web-turned-mobile developers on the iOS team, we were incredibly excited about the possibility of building new views using JavaScript. One month ago, we released our first three React Native views into production. This guide can help you do the same.</p><p>RN has a <a href="https://facebook.github.io/react-native/docs/embedded-app-ios.html#content">getting started guide</a>, which this closely follows. But in addition to getting an RN View rendered inside your existing iOS app, this guide will also cover passing data into your RN View, provide examples in Objective C <em>and </em>Swift, and cover some of the issues that we faced along the way.</p><p>This guide is Part 1 in a series. In future guides we’ll cover how to:</p><ol><li>Use &lt;Navigator/&gt; as a router for multiple RN views inside your app.</li><li>Use <a href="http://microsoft.github.io/code-push/">Codepush</a> for pushing bug fixes to production <a href="https://twitter.com/brunobar79/status/684782555002990592">in 45 seconds</a>.</li><li>Enable more interactivity with your Native and RN code through notifications, and exporting custom views, and modules.</li></ol><p>You can find the full example on Github here: <a href="https://github.com/Deliverydotcom/ReactNativeHybridExample">https://github.com/Deliverydotcom/ReactNativeHybridExample</a>.</p><h4>Getting Started</h4><p>To get set up, follow the steps in the “Requirements” and “Install React Native Using CocoaPods” sections from the <a href="http://facebook.github.io/react-native/docs/embedded-app-ios.html">official guide</a>. This will ensure you have Node, Cocoapods, and all other prerequisites to get started.</p><p>To keep all of our JS in one place, we’ll create a folder called “ReactComponents” at the root of our project. Let’s keep our node_modules inside this folder.</p><p>.<br>├── Podfile<br>├── Podfile.lock<br>├── Pods<br>├── ReactComponents<br>│ ├── node_modules<br>│ └── package.json<br>├── ReactNativeExample<br>├── ReactNativeExample.xcodeproj<br>└── ReactNativeExample.xcworkspace</p><p>And our Podfile should contain:</p><pre>pod ‘React’, :path =&gt; ‘./ReactComponents/node_modules/react-native’, :subspecs =&gt; [<br> ‘Core’,<br> ‘RCTImage’,<br> ‘RCTNetwork’,<br> ‘RCTText’,<br> ‘RCTWebSocket’<br>]</pre><p><strong><em>Note: </em></strong>Add more subspecs as needed. E.g. <strong>RCTLinkingIOS</strong> is needed to use the <strong>LinkingIOS </strong>module.</p><p>Now run:</p><pre>$ pod install</pre><p>to ensure that your pod is pointing to the right directory. From this point on, make sure you are working in your project’s .xcworkspace.</p><h4>The UIView</h4><p>First we’ll create a class that subclasses UIView (called <strong>ReactNativeView</strong>). This will serve as our RN View’s wrapper. This class should have one public property called <strong>data</strong> and one method called <strong>initializeReactView </strong>that initializes our RN View. In this method we will:</p><ol><li>Set up the data dictionary to pass any data into React.</li><li>Initialize the RCTRootView (provided by RN) with JS code from either our dev server or JS bundle.</li><li>Add the RCTRootView to our wrapper view and set constraints to take up the entire space.</li></ol><p><strong><em>Note:</em></strong> If you’re writing this in Swift, make sure you include <strong>RCTRootView.h</strong> in your Bridging-Header.</p><p><em>Objective-C:</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2a1c5b0b9fdd3691a581295bddc3fd48/href">https://medium.com/media/2a1c5b0b9fdd3691a581295bddc3fd48/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e23de10db81fbfcb515d13243233230e/href">https://medium.com/media/e23de10db81fbfcb515d13243233230e/href</a></iframe><p><em>Swift:</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/613386dccbd8950a10b4169db9d31c9c/href">https://medium.com/media/613386dccbd8950a10b4169db9d31c9c/href</a></iframe><h4>The UIViewController</h4><p>Now that we have our RN View wrapper ready to go, we need to create a class that subclasses UIViewController. Let’s call it <strong>ReactNativeViewController</strong>. You can do this in a storyboard, nib, or code. Just make sure you have a reference to the <strong>ReactNativeView</strong> in your UIViewController class. Let’s name that reference <strong>reactViewWrapper</strong>.</p><p>In our <strong>ReactNativeViewController</strong>’s <strong>viewDidLoad </strong>method<strong> </strong>we’re going to set any additional data we want to pass to our JS and then run the <strong>initializeReactView</strong> method we wrote earlier. In this case we’re passing one property called <strong>content</strong> that we’ll later render in JS.</p><p><em>Objective C:</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/93146e8e7c93b876a1227637f63c5822/href">https://medium.com/media/93146e8e7c93b876a1227637f63c5822/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d1c5fe5484ded9b19f742cf01d73329a/href">https://medium.com/media/d1c5fe5484ded9b19f742cf01d73329a/href</a></iframe><p><em>Swift:</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/50a7eaac57e9205d71dba851a991af6a/href">https://medium.com/media/50a7eaac57e9205d71dba851a991af6a/href</a></iframe><h4>The JavaScript</h4><p>With all of that in place, we’re ready to start writing our RN code! Let’s create a file inside our <strong>ReactComponents</strong> folder called <strong>index.ios.js</strong>. This serves as our entry point into our RN code. In this file we’ll create a very simple RN app with one component, called <strong>ReactNativeExample </strong>in this case, and we’ll just render the <strong>content </strong>passed from our <strong>ReactNativeViewController</strong>. We have access to the data that was passed as a property called <strong>initialProperties</strong> in the <strong>ReactNativeExample</strong>’s props.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c3ccbaeaf255180e98b55c261607304b/href">https://medium.com/media/c3ccbaeaf255180e98b55c261607304b/href</a></iframe><p>And that’s it! Now let’s get this app up and running.</p><h4>Development Mode</h4><p>To get up and running we need to start our RN development server. From the root of our project run:</p><pre>$ (JS_DIR=`pwd`/ReactComponents; cd ReactComponents/node_modules/react-native; npm run start — — root $JS_DIR)</pre><p><strong><em>Note:</em></strong> App Transport Security will block requests to localhost by default. If you haven’t done so already, follow this guide to enable them: <a href="http://bencoding.com/2015/07/20/app-transport-security-and-localhost/">http://bencoding.com/2015/07/20/app-transport-security-and-localhost/</a>.</p><p>In <strong>ReactNativeView</strong> let’s set the <strong>REACT_DEV_MODE</strong> to true, compile our app, and navigate to our <strong>ReactNativeViewController</strong>. You should see the server build your bundle and see your <strong>ReactNativeExample </strong>component rendered. Every time we save a JS file the server should re-create the bundle.</p><p><strong><em>Note: </em></strong>Shake the device to see a list of developer tools like live reload and Chrome debugging.</p><h4>Release Mode</h4><p>Once we’ve finished developing, we are ready to build for release. First, we need to create the <strong>main.jsbundle</strong> where the JS code will live in production. Let’s go into our <strong>ReactComponents</strong> folder and run:</p><pre>$ react-native bundle --dev false --platform ios --entry-file index.ios.js --bundle-output ../main.jsbundle --minify</pre><p><strong><em>Note:</em></strong> The first time the <strong>main.jsbundle</strong> file is created it needs to be manually added to the Xcode project. To do this, find the file in Finder and drag it into the Xcode Project Navigator inside your project folder.</p><p><strong><em>Note: </em></strong>In Release mode, make sure Chrome debugging is disabled or you’ll see a WebSocket connection failure.</p><p>In <strong>ReactNativeView</strong>, let’s set <strong>REACT_DEV_MODE</strong> to false, compile our app, and we’re good to go!</p><p>From here you should be all set to continue developing your iOS RN hybrid app. If you run into any problems along the way, feel free to reach out to us on Twitter at <a href="https://medium.com/u/81a04ace1263">Jesse Sessler</a> and <a href="https://medium.com/u/f4d1a315ca06">Bruno Barbieri</a> and on Discord at <strong>jemise111 </strong>or <strong>brunobar79.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=874ba95a3c52" width="1" height="1" alt=""><hr><p><a href="https://medium.com/delivery-com-engineering/react-native-in-an-existing-ios-app-delivered-874ba95a3c52">React Native in an Existing iOS App: Getting Started.</a> was originally published in <a href="https://medium.com/delivery-com-engineering">Delivery.com Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Html Columns Without Tables Using Column-Count (in angular)]]></title>
            <link>https://medium.com/@jsessler/html-columns-without-tables-using-column-count-in-angular-c789877cb92c?source=rss-81a04ace1263------2</link>
            <guid isPermaLink="false">https://medium.com/p/c789877cb92c</guid>
            <category><![CDATA[angularjs]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Jesse Sessler]]></dc:creator>
            <pubDate>Fri, 13 Mar 2015 12:35:17 GMT</pubDate>
            <atom:updated>2015-03-13T14:25:07.499Z</atom:updated>
            <content:encoded><![CDATA[<h2>Html Columns</h2><h3>Without Tables</h3><h3>Using Column-Count (in angular)</h3><pre>&lt;table&gt;&lt;/table&gt;</pre><p>I cringe when I see that. I’m not sure if that’s justified. I’m not even sure why. But at some point I was taught to never use &lt;table&gt; and it just stuck with me. Maybe there are still good uses for the table element. I haven’t come across any so I’ve had no reason to do any research on the topic.</p><p>But I was recently asked to organize some elements into columns and rows, and I worried that the easiest way to do this was with a &lt;table&gt;. To my surprise I came across a few new CSS3 properties that would help me avoid it. Rather than rewrite the docs on these I’ll just encourage you to check out the documentation and give a small example. Here’s one to get you started:</p><p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/column-count">column-count</a></p><p>And here’s a simple example:</p><pre>&lt;ul&gt;<br>  &lt;li ng-repeat=”letter in letters”&gt;<br>    {{letter}}<br>  &lt;/li&gt;<br>&lt;/ul&gt;</pre><pre>angular.module(‘letterApp’, [])<br>  .controller(‘letterCtrl’, function($scope){<br>    $scope.letters = [<br>      ‘a’, ‘b’, ‘c’,<br>      ‘d’, ‘e’, ‘f’,<br>      ‘g’, ‘h’, ‘i’,<br>      ‘j’, ‘k’, ‘l’,<br>      ‘m’, ‘n’, ‘o’,<br>      ‘p’, ‘q’, ‘r’,<br>    ];<br>  });</pre><pre>ul {<br>  list-style-type: none;<br>  -webkit-column-count: 6;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/767/1*z9V6ROubokT5qvMe4dDKgA.png" /></figure><p>Looks great right?! And it’s incredibly simple to use. A couple browser prefixes and you have support for everything except &lt;IE10 (but c’mon people…)</p><p>What happens when the number of elements you have doesn’t divide evenly with the number of columns you need? Let’s add the rest of the alphabet and see how column-count behaves.</p><pre>angular.module(‘letterApp’, [])<br>  .controller(‘letterCtrl’, function($scope){<br>    $scope.letters = [<br>      ‘a’, ‘b’, ‘c’,<br>      ‘d’, ‘e’, ‘f’,<br>      ‘g’, ‘h’, ‘i’,<br>      ‘j’, ‘k’, ‘l’,<br>      ‘m’, ‘n’, ‘o’,<br>      ‘p’, ‘q’, ‘r’,<br>      &#39;s&#39;, &#39;t&#39;, &#39;u&#39;,<br>      &#39;v&#39;, &#39;w&#39;, &#39;x&#39;,<br>      &#39;y&#39;, &#39;z&#39;<br>    ];<br>  });</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/785/1*dj3FP29U3GHWh8BFzlIAXg.png" /></figure><p>Hmm. That’s not quite what I wanted. Ideally (in my opinion) instead of filling each column with the maximum number of elements possible, and throwing the leftovers in the last row, I’d like the elements to be as evenly distributed as possible.</p><p>I checked the docs, no luck there. Checked Stack Overflow, nothing. After a few minutes of unsuccessful Googling I wrote a small function and some markup/style to do it myself.</p><pre>&lt;ul ng-repeat=&quot;column in columns&quot;&gt;<br>  &lt;li ng-repeat=”letter in column”&gt;<br>    {{letter}}<br>  &lt;/li&gt;<br>&lt;/ul&gt;</pre><pre>angular.module(‘letterApp’, [])<br> .controller(‘letterCtrl’, function($scope){</pre><pre>   function columnize(items) {<br>     var columns = [],<br>     columnSizes = [],<br>     columnCount;</pre><pre>     // logic to figure out columnCount<br>     columnCount = 6; // assume it’s 6</pre><pre>     var baseColSize = Math.floor(items.length / columnCount);<br>     var extras = items.length % columnCount;</pre><pre>     for (var i = 0; i &lt; columnCount; i++) {<br>       columnSizes.push(extras &gt; 0 ? baseColSize + 1 :      baseColSize);<br>       extras—-;<br>     }</pre><pre>    for (var j = 0; j &lt; columnSizes.length; j++) {<br>      columns[j] = items.splice(0, columnSizes[j]);<br>    }</pre><pre>    return columns;<br>  }</pre><pre>  var letters = [<br>    ‘a’, ‘b’, ‘c’,<br>    ‘d’, ‘e’, ‘f’,<br>    ‘g’, ‘h’, ‘i’,<br>    ‘j’, ‘k’, ‘l’,<br>    ‘m’, ‘n’, ‘o’,<br>    ‘p’, ‘q’, ‘r’,<br>    ‘s’, ‘t’, ‘u’,<br>    ‘v’, ‘w’, ‘x’,<br>    ‘y’, ‘z’<br>  ];</pre><pre>  $scope.columns = columnize(letters);<br>});</pre><pre>ul {<br>  list-style-type: none;<br>  float: left;<br>  width: 100px;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/767/1*7eUxEPz6gZP6deoevROMHw.png" /></figure><p>Now we have evenly distributed columns of 5 and 4 elements.</p><p>If you found this helpful or have any other comments let me know on Twitter!</p><p><a href="https://twitter.com/jsessler">https://twitter.com/jsessler</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c789877cb92c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Easy JavaScript time profiling using Chrome’s console]]></title>
            <link>https://medium.com/@jsessler/easy-javascript-time-profiling-using-chromes-console-69d651b7109d?source=rss-81a04ace1263------2</link>
            <guid isPermaLink="false">https://medium.com/p/69d651b7109d</guid>
            <dc:creator><![CDATA[Jesse Sessler]]></dc:creator>
            <pubDate>Fri, 24 Oct 2014 19:21:02 GMT</pubDate>
            <atom:updated>2015-06-08T19:53:44.936Z</atom:updated>
            <content:encoded><![CDATA[<h3>Easy Javascript Time Profiling</h3><p>Using Chrome’s Developer Console</p><p>I’m a relative newcomer to the world of front end development. I shudder to think of what life was like before the days of the magical Chrome console. I probably spend 50% of my day using it, and learn a new trick every week (now every day: <a href="http://devtoolstips.com/">http://devtoolstips.com/</a>).</p><p>Last week I wrote a function that processed some data every time a user clicked on an element before re-rendering it on the screen. There was a noticeable delay in the rendering but it was tough to determine if this was caused by the data processing or the rendering function itself. My mentor informed me that my target for data processing function should be under ~16 milliseconds.</p><p>Time profiling this function was incredibly simple using Chrome’s developer console. Just throw in</p><pre>&quot;console.time(&lt;some_name&gt;)&quot;</pre><p>right before the line where you want to start the timer and</p><pre>&quot;console.timeEnd(&lt;some_name&gt;)&quot;</pre><p>right after the line where you want to end it.</p><p>Let’s say you want to look at the difference in performance of two different functions, one using JQuery and one using vanilla JS. Let’s add 1,000 paragraphs to the DOM using insertBefore, because that seems like a fun and practical thing to do.</p><pre>function addParagraphs() {<br>  console.time(&#39;js adding paragraphs&#39;);<br>  var n = 1000;<br>  for (var i = 0; i &lt; n; i++) {<br>    var placeHolder = document.getElementById(&#39;placeholder&#39;);<br>    var paragraph = document.createElement(&#39;P&#39;);<br>    var textNode = document.createTextNode(&#39;Test Paragraph&#39;);<br>    paragraph.appendChild(textNode);<br>    document.body.insertBefore(paragraph, placeHolder);<br>  }<br>  console.timeEnd(&#39;js adding paragraphs&#39;);<br>}</pre><pre>function jqAddParagraphs() {<br>  console.time(&#39;jq adding paragraphs&#39;);<br>  var n = 1000;<br>  for (var i = 0; i &lt; n; i++) {<br>    var placeHolder = $(&#39;#placeholder&#39;);<br>    var paragraph = $(&#39;&lt;p&gt;Test Paragraph&lt;/p&gt;&#39;);<br>    paragraph.insertBefore(placeholder);<br>  }<br>  console.timeEnd(&#39;jq adding paragraphs&#39;);<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*SYnduV3PvkX6rOKWxjgsog.png" /></figure><p>Looks like in this case vanilla JS is 20 times faster than JQ. And it took all of 4 lines and about 2 minutes to determine that.</p><p>There you have it, a quick and easy way to time profile functions in javascript.</p><p>Documentation and some other nifty Chrome console tricks here: <a href="https://developer.chrome.com/devtools/docs/console-api">https://developer.chrome.com/devtools/docs/console-api</a>. If you thought this was handy definitely check out console.profile. Let me know what you think on twitter!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=69d651b7109d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>