<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.9.2">Jekyll</generator><link href="http://www.yonbergman.com/feed.xml" rel="self" type="application/atom+xml" /><link href="http://www.yonbergman.com/" rel="alternate" type="text/html" /><updated>2025-02-09T03:35:07-06:00</updated><id>http://www.yonbergman.com/feed.xml</id><title type="html">Yon Bergman</title><subtitle>Yonatan Bergman is an experienced software engineer and manager with an eye for design and a passion for building great products and teams. Focused on consistently improving and nurturing team culture and productivity, as well as empowering those around him.</subtitle><author><name>Yon Bergman</name></author><entry><title type="html">From Sprints to Cycles: Revolutionizing Agile with Empathy</title><link href="http://www.yonbergman.com/2024/03/05/from-sprints-to-cycles/" rel="alternate" type="text/html" title="From Sprints to Cycles: Revolutionizing Agile with Empathy" /><published>2024-03-05T00:00:00-06:00</published><updated>2024-03-05T00:00:00-06:00</updated><id>http://www.yonbergman.com/2024/03/05/from-sprints-to-cycles</id><content type="html" xml:base="http://www.yonbergman.com/2024/03/05/from-sprints-to-cycles/"><![CDATA[<p>I gave a talk at Reversim 2024 on adopting new ways to work.
A year ago, Empathy decided to ditch the traditional Agile-Sprint methodology and start using Cycles, a system inspired by Basecamp’s Shape-up methodology.</p>

<!--more-->

<p>This new system completely upends how we work (Engineering, Product &amp; Design) and we have witnessed a significant shift in our team’s productivity, collaboration, and overall satisfaction. This talk will delve into the details of our journey, the benefits we have gained, and the key takeaways that extend beyond just the cycles system.</p>

<h2 id="video-hebrew">Video (Hebrew)</h2>

<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/AupRgDNGavw" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe>]]></content><author><name>Yon Bergman</name></author><category term="talks" /><category term="culture" /><category term="teams" /><summary type="html"><![CDATA[I gave a talk at Reversim 2024 on adopting new ways to work. A year ago, Empathy decided to ditch the traditional Agile-Sprint methodology and start using Cycles, a system inspired by Basecamp’s Shape-up methodology.]]></summary></entry><entry><title type="html">From Sprints to Cycles: Revolutionizing Agile with Empathy</title><link href="http://www.yonbergman.com/2019/06/16/high-performing-team-culture-copy/" rel="alternate" type="text/html" title="From Sprints to Cycles: Revolutionizing Agile with Empathy" /><published>2019-06-16T00:00:00-05:00</published><updated>2019-06-16T00:00:00-05:00</updated><id>http://www.yonbergman.com/2019/06/16/high-performing-team-culture%20copy</id><content type="html" xml:base="http://www.yonbergman.com/2019/06/16/high-performing-team-culture-copy/"><![CDATA[<p>I gave a talk in Reversim 2019 on engineering excellence and growing high performing engineering organizations.</p>

<!--more-->

<p>What does it mean to strive for ENGINEERING EXCELLENCE? As your engineering organization grows, you want to encourage teams and individuals to develop and improve their technical proficiency and practices. Growth puts stress on your teams’ ability to deliver kick-ass code consistently. To help them improve and grow, we built the LEVEL UP model to represent everything that’s expected of an excellent engineering team.</p>

<p>In this talk, I’ll review why we built this model, refined it and how we got teams to adopt it and the effects that it had on our department. I will also give you the tools to either use our model or fork your own specific one for your organization.</p>

<h2 id="slides">Slides:</h2>
<script async="" class="speakerdeck-embed" data-id="9283cc4d901145c9917cbd333646b6bd" data-ratio="1.77777777777778" src="//speakerdeck.com/assets/embed.js"></script>

<h2 id="video-hebrew">Video (Hebrew):</h2>
<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/T-rhGKhiDb4" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe>]]></content><author><name>Yon Bergman</name></author><category term="talks" /><category term="culture" /><category term="teams" /><summary type="html"><![CDATA[I gave a talk in Reversim 2019 on engineering excellence and growing high performing engineering organizations.]]></summary></entry><entry><title type="html">A Whole New World</title><link href="http://www.yonbergman.com/2019/02/11/a-whole-new-world/" rel="alternate" type="text/html" title="A Whole New World" /><published>2019-02-11T00:00:00-06:00</published><updated>2019-02-11T00:00:00-06:00</updated><id>http://www.yonbergman.com/2019/02/11/a-whole-new-world</id><content type="html" xml:base="http://www.yonbergman.com/2019/02/11/a-whole-new-world/"><![CDATA[<p>I recently gave an talk at the new WiX Haifa meetup on the topic of I18N (Internationalization), G11N (Globalization) and L10N (Localization).</p>

<!--more-->

<p>So you’ve launched your first service and all your customers in the US love it - great! 
Now comes the hard part - how do you make the entire world love it too.</p>

<p>In this talk, I’m going to share what from my experience building the PayPal Mobile app and expanding WeWork’s systems to span the globe.I’m going to cover it all: from encodings, translations, UGC, CATs, i18n, g11n, l10n, LQA, money, dates, names, and taxes. 
So that you can expand your app and reach new customers in London, Beijing, Tel-Aviv, and Paris.</p>

<h2 id="slides">Slides:</h2>
<script async="" class="speakerdeck-embed" data-id="f28d22ff24fc436091e3bef6958d79d1" data-ratio="1.77777777777778" src="//speakerdeck.com/assets/embed.js"></script>

<h2 id="video">Video:</h2>
<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/75LspOu-ANk" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe>]]></content><author><name>Yon Bergman</name></author><category term="talks" /><category term="localization" /><category term="globalization" /><summary type="html"><![CDATA[I recently gave an talk at the new WiX Haifa meetup on the topic of I18N (Internationalization), G11N (Globalization) and L10N (Localization).]]></summary></entry><entry><title type="html">Keep Interviewing and Nobody Explodes</title><link href="http://www.yonbergman.com/2018/11/29/keep-interviewing/" rel="alternate" type="text/html" title="Keep Interviewing and Nobody Explodes" /><published>2018-11-29T05:53:41-06:00</published><updated>2018-11-29T05:53:41-06:00</updated><id>http://www.yonbergman.com/2018/11/29/keep-interviewing</id><content type="html" xml:base="http://www.yonbergman.com/2018/11/29/keep-interviewing/"><![CDATA[<p>Original post found at <a href="https://engineering.wework.com/keep-interviewing-and-nobody-explodes-450fd95631b2">WeWork Technology Blog</a><br />
I recently gave an ignite talk at Reversim 2018 on the topic of games in recruiting here are the video and slides I presented there.</p>

<!--more-->

<h2 id="slides">Slides:</h2>
<script async="" class="speakerdeck-embed" data-id="17801a5549ae40a4b0931c91f570d1b9" data-ratio="1.33333333333333" src="//speakerdeck.com/assets/embed.js"></script>

<h2 id="video-hebrew">Video (Hebrew):</h2>
<iframe width="560" height="315" src="https://www.youtube.com/embed/SXe4Ryf3SFo" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe>]]></content><author><name>Yon Bergman</name></author><category term="talks" /><category term="hiring" /><category term="culture" /><summary type="html"><![CDATA[Original post found at WeWork Technology Blog I recently gave an ignite talk at Reversim 2018 on the topic of games in recruiting here are the video and slides I presented there.]]></summary></entry><entry><title type="html">Swift and UIViewControllers</title><link href="http://www.yonbergman.com/2015/07/10/swift-and-uiviewcontrollers/" rel="alternate" type="text/html" title="Swift and UIViewControllers" /><published>2015-07-10T06:53:41-05:00</published><updated>2015-07-10T06:53:41-05:00</updated><id>http://www.yonbergman.com/2015/07/10/swift-and-uiviewcontrollers</id><content type="html" xml:base="http://www.yonbergman.com/2015/07/10/swift-and-uiviewcontrollers/"><![CDATA[<p>I’ve come across a very neat trick for working with UIViewControllers, storyboards (or XIBs) and Swift.  <br />
It’s a nice and easy way to remove all the setup gunk from your <code class="language-plaintext highlighter-rouge">viewDidLoad</code> methods in your ViewControllers and move them to where they belong.</p>

<!--more-->

<p>So let’s start by defining the issue - a lot of times when initializing a view controller from a storyboard you have to add some custom code to initialize something that is either hard or impossible to do in the Interface builder.</p>

<p>Let’s say that we have a page with a simple TableView and we want to initialize that TableView with a content inset so that it never overlaps the icon on the bottom</p>

<p><img src="/images/posts/swift-uiviews/ib.png" alt="" />
<small class="text-center">Our ViewController in Xcode’s Interface builder</small></p>

<p>Regularly we would have done that extra setup in our <code class="language-plaintext highlighter-rouge">viewDidLoad</code> method in the ViewController.</p>

<div class="language-swift highlighter-rouge"><div class="highlight"><pre class="highlight"><code>
<span class="kd">class</span> <span class="kt">MyViewController</span><span class="p">:</span> <span class="kt">UIViewController</span> <span class="p">{</span>
  <span class="kd">@IBOutlet</span> <span class="k">weak</span> <span class="k">var</span> <span class="nv">tableView</span><span class="p">:</span> <span class="kt">UITableView</span><span class="o">!</span>
  
  <span class="kd">func</span> <span class="nf">viewDidLoad</span><span class="p">()</span> <span class="p">{</span>
  	<span class="k">super</span><span class="o">.</span><span class="nf">viewDidLoad</span><span class="p">()</span>
	<span class="n">tableView</span><span class="o">.</span><span class="n">contentInset</span> <span class="o">=</span> <span class="kt">UIEdgeInsets</span><span class="p">(</span><span class="nv">top</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nv">left</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nv">bottom</span><span class="p">:</span> <span class="mi">100</span><span class="p">,</span> <span class="nv">right</span><span class="p">:</span> <span class="mi">0</span><span class="p">)</span>
  <span class="p">}</span>
<span class="p">}</span>
</code></pre></div></div>
<p>This is a great way to do things like that - but when you have a complicated ViewController your <code class="language-plaintext highlighter-rouge">viewDidLoad</code> method can get really messy and clogged up with lots of UI setup code.</p>

<h3 id="where-swift-comes-in">Where Swift comes in</h3>

<p>In Swift we have this awesome feature called <a href="https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Properties.html#//apple_ref/doc/uid/TP40014097-CH14-ID262"><strong>Property Observers</strong></a> that let’s us add an observer method to a property of our class, this method get’s called whenever the property gets modified. Specifically we use <code class="language-plaintext highlighter-rouge">didSet</code>.</p>

<p>We can utilize this feature to run our setup code when the view object is assigned to it’s property outlet (which happens after the ViewController decodes the storyboard).<br />
In this way we have all our UI setup code in its contextual place and our <code class="language-plaintext highlighter-rouge">viewDidLoad</code> is free to manage the logic and not the UI :)</p>

<div class="language-swift highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kd">class</span> <span class="kt">MyViewController</span><span class="p">:</span> <span class="kt">UIViewController</span> <span class="p">{</span>
  <span class="kd">@IBOutlet</span> <span class="k">weak</span> <span class="k">var</span> <span class="nv">tableView</span><span class="p">:</span> <span class="kt">UITableView</span><span class="o">!</span> <span class="p">{</span>
    <span class="k">didSet</span> <span class="p">{</span>
      <span class="n">tableView</span><span class="o">.</span><span class="n">contentInset</span> <span class="o">=</span> <span class="kt">UIEdgeInsets</span><span class="p">(</span><span class="nv">top</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nv">left</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nv">bottom</span><span class="p">:</span> <span class="mi">100</span><span class="p">,</span> <span class="nv">right</span><span class="p">:</span> <span class="mi">0</span><span class="p">)</span>
    <span class="p">}</span>
  <span class="p">}</span>
<span class="p">}</span>
</code></pre></div></div>

<hr />

<p>I’ve been really enjoying playing around with Swift for the last couple of months, I’ll be sharing some more tips as I find them :) <br />
So be sure to follow me on twitter <a href="http://twitter.com/yonbergman">@yonbergman</a>.</p>]]></content><author><name>Yon Bergman</name></author><category term="ios" /><summary type="html"><![CDATA[I’ve come across a very neat trick for working with UIViewControllers, storyboards (or XIBs) and Swift. It’s a nice and easy way to remove all the setup gunk from your viewDidLoad methods in your ViewControllers and move them to where they belong.]]></summary></entry><entry><title type="html">Static Sites with Parse</title><link href="http://www.yonbergman.com/2015/04/27/static-sites-with-parse/" rel="alternate" type="text/html" title="Static Sites with Parse" /><published>2015-04-27T22:34:41-05:00</published><updated>2015-04-27T22:34:41-05:00</updated><id>http://www.yonbergman.com/2015/04/27/static-sites-with-parse</id><content type="html" xml:base="http://www.yonbergman.com/2015/04/27/static-sites-with-parse/"><![CDATA[<p>Lately I’ve been really enjoying building my side projects on <a href="http://parse.com">Parse</a> as opposed to using Heroku. But it hasn’t all been a walk on the beach. I’ve encountered several issues when building static sites and I wanted to share two tricks for building better sites on Parse.</p>

<!--more-->

<p>First I wanted to share a few of the reasons why I enjoy using Parse:</p>

<ul>
  <li>It makes me build sites that easily withstand greater traffic since they’re mostly static</li>
  <li>I can host the static sites wherever I want Parse/S3/VPS</li>
  <li>I get to play around and hone my server side javascript skills</li>
  <li>Parse has a great offering for managing so many things (The built-in admin &amp; analytics are a blast)</li>
</ul>

<p><img src="/images/posts/parse/sea.png" alt="" />
<small class="text-center">An actual walk on the beach</small></p>

<h2 id="separating-the-code-into-multiple-files">Separating the code into multiple files</h2>

<p>One of the most basic things for a developer’s sanity is not to have all the code in one huge file, a guideline much easier said than followed in Parce. While the Parse documentation is incredibly good, it lacks any direction as to how you can manage your cloud code nicely.</p>

<p>The solution is very simple, Parse offers a way to manage dependencies in a fashion similar to - <a href="http://wiki.commonjs.org/wiki/CommonJS"><strong>CommonJS</strong></a>, with something that they call <a href="https://parse.com/docs/cloud_code_guide#modules">Modules</a>.<br />
For anyone who hasn’t worked with CommonJS or the likes, it is a simple JS module loader that lets you manage dependencies in JS.</p>

<p>Let’s take for example this simple app with a player model and one cloud function:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>- cloud
    |- models
    |    \- player.js
     \- main.js
</code></pre></div></div>

<h4 id="cloudmodelsplayerjs">cloud/models/player.js</h4>
<div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kd">var</span> <span class="nx">Player</span> <span class="o">=</span> <span class="nx">Parse</span><span class="p">.</span><span class="nb">Object</span><span class="p">.</span><span class="nx">extend</span><span class="p">(</span><span class="dl">"</span><span class="s2">Player</span><span class="dl">"</span><span class="p">,</span> <span class="p">{</span>

<span class="p">},</span> <span class="p">{</span>
  <span class="na">find</span><span class="p">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">id</span><span class="p">)</span> <span class="p">{</span>
    <span class="kd">var</span> <span class="nx">q</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Parse</span><span class="p">.</span><span class="nx">Query</span><span class="p">(</span><span class="nx">Player</span><span class="p">);</span>
    <span class="k">return</span> <span class="nx">q</span><span class="p">.</span><span class="kd">get</span><span class="p">(</span><span class="nx">id</span><span class="p">);</span>
  <span class="p">}</span>
<span class="p">});</span>

<span class="nx">module</span><span class="p">.</span><span class="nx">exports</span> <span class="o">=</span> <span class="nx">Player</span><span class="p">;</span>

</code></pre></div></div>

<h4 id="cloudmainjs">cloud/main.js</h4>
<div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kd">var</span> <span class="nx">Player</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="dl">'</span><span class="s1">cloud/models/player.js</span><span class="dl">'</span><span class="p">);</span>

<span class="nx">Parse</span><span class="p">.</span><span class="nx">Cloud</span><span class="p">.</span><span class="nx">define</span><span class="p">(</span><span class="dl">"</span><span class="s2">gameOver</span><span class="dl">"</span><span class="p">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">request</span><span class="p">,</span> <span class="nx">response</span><span class="p">){</span>
  <span class="nx">Player</span><span class="p">.</span><span class="nx">find</span><span class="p">(</span><span class="nx">request</span><span class="p">.</span><span class="nx">params</span><span class="p">.</span><span class="nx">id</span><span class="p">).</span><span class="nx">then</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">player</span><span class="p">){</span>
	<span class="c1">// ... Do something with player</span>
  <span class="p">});</span>
<span class="p">});</span>

</code></pre></div></div>

<p>The two important lines to understand are the last line of <code class="language-plaintext highlighter-rouge">player.js</code> where we expose our newly created Player class to whoever will <em>depend</em> on us, <br />
and the first line of <code class="language-plaintext highlighter-rouge">main.js</code> where we announce our <em>dependency</em> on the player file and receive the class that was exposed allowing us to use it.</p>

<p>That’s all there is to setting up file dependencies in Parse cloud code.</p>

<h2 id="writing-coffeescript-code">Writing Coffeescript code</h2>

<p>Parse cloud code doesn’t support coffee script out of the box, which is a shame because it makes writing JS so much more fun. To get around this issue, I came up with a nice little solution that also lets me re-use code between the Cloud and the Client.</p>

<p>My solution relies on <a href="https://middlemanapp.com">Middleman</a> - a great library that I’ve been using more and more lately. Middleman lets you generate static sites with ease (it’s written in Ruby and very similar to Jekyll).</p>

<h4 id="mixing-middleman-and-parse">Mixing Middleman and Parse</h4>
<p>To start combining middleman and parse, it’s important to understand what Parse expects to get and run. Parse expects two main parts for a static site, first a <code class="language-plaintext highlighter-rouge">cloud/main.js</code> file as the entry point to the cloud code, and second, a <code class="language-plaintext highlighter-rouge">public</code> folder containing static html, css, js of the site.</p>

<p>If we were to create an empty Middleman project, we would be almost halfway to getting a static site running on Parse :)
Middleman’s build directory is called <code class="language-plaintext highlighter-rouge">build</code> by default and we can either reconfigure Middleman to output the static files that are compiled to <code class="language-plaintext highlighter-rouge">public</code> or create a symbolic link from <code class="language-plaintext highlighter-rouge">public</code> to <code class="language-plaintext highlighter-rouge">build</code> (I prefer the symbolic link).
To create the link, all you need to do is run:</p>

<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">ln</span> <span class="nt">-s</span> build public
</code></pre></div></div>
<p>and you can even commit this link into your git repo without filling git with junk.<br />
You now have a static site generated using Middleman running on Parse (of course you also need to deploy the changes to Parse).</p>

<p>The next part is to get the cloud code running as well. We want to write it in Coffeescript and also potentially share it with the client-side JS we rendered with Middleman and served via the <code class="language-plaintext highlighter-rouge">public</code> directory.</p>

<p>My solution is to have a file under the <code class="language-plaintext highlighter-rouge">source/javascript</code> directory that will compile to be the final <code class="language-plaintext highlighter-rouge">cloud/main.js</code></p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>- source/javascripts
		| - cloud
		|	  \- gameOver.js.coffee 
		|
		| - models
		|     \- player.s.coffee
		|
		| - all.js.coffee
		\ - cloud.js.coffee
		      
</code></pre></div></div>

<h4 id="sourcejavascriptscloudjscoffee">source/javascripts/cloud.js.coffee</h4>

<div class="language-coffee highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1">#= require_self	</span>
<span class="c1">#= require_tree ./models</span>
<span class="c1">#= require ./cloud/gameOver.js.coffee</span>
<span class="nx">MyApp</span> <span class="o">=</span> <span class="p">{}</span>
</code></pre></div></div>

<p>This file can use middleman’s Asset Pipeline (sprockets) to require any files that, at build time, will compile to the final javascript. <em>Note</em> that by structuring the source folder correctly we can share files between the js going to the client side (<code class="language-plaintext highlighter-rouge">all.js</code>) and the js running on the Parse cloud (<code class="language-plaintext highlighter-rouge">cloud.js</code>).</p>

<p>The last piece of the puzzle is to create another symbolic link, this time linking <code class="language-plaintext highlighter-rouge">cloud/main.js</code> to <code class="language-plaintext highlighter-rouge">build/javascripts/cloud.js</code> - again this is done by running the command</p>

<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">ln</span> <span class="nt">-s</span> build/javascripts/cloud.js cloud/main.js
</code></pre></div></div>

<h3 id="it-all-comes-together">It all comes together</h3>
<p>Now that we have a Middleman app ready and shared code between client and server and the cloud code all ready, deployments of a new version require this simple two-step process.</p>

<div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="o">&gt;</span> <span class="nx">middleman</span> <span class="nx">build</span>  	<span class="c1">// compile the latest version of the site and code</span>
<span class="o">&gt;</span> <span class="nx">parse</span> <span class="nx">deploy</span> 		<span class="c1">// deploy the newly compiled code to Parse's servers</span>
</code></pre></div></div>

<p>We just need to make sure you configure your Parse app to server static content and we’re good to go :)</p>

<p><img src="/images/posts/parse/eize.jpg" alt="" />
<small class="text-center">A site developed in Middleman &amp; Parse</small></p>

<hr />

<p>I really hope these two pointers find their way to helping people building cool things, let me know if this helped you or if you have any follow-up questions.</p>

<p>You can always find me on twitter <a href="http://twitter.com/yonbergman">@yonbergman</a>.</p>]]></content><author><name>Yon Bergman</name></author><category term="parse," /><category term="javascript" /><summary type="html"><![CDATA[Lately I’ve been really enjoying building my side projects on Parse as opposed to using Heroku. But it hasn’t all been a walk on the beach. I’ve encountered several issues when building static sites and I wanted to share two tricks for building better sites on Parse.]]></summary></entry><entry><title type="html">Global day of coderetreat 2014 - New Session</title><link href="http://www.yonbergman.com/2014/11/16/global-day-of-code-retreat-new-session/" rel="alternate" type="text/html" title="Global day of coderetreat 2014 - New Session" /><published>2014-11-16T04:34:41-06:00</published><updated>2014-11-16T04:34:41-06:00</updated><id>http://www.yonbergman.com/2014/11/16/global-day-of-code-retreat-new-session</id><content type="html" xml:base="http://www.yonbergman.com/2014/11/16/global-day-of-code-retreat-new-session/"><![CDATA[<p>This weekend I had the pleasure of hosting the 4th annual <a href="http://gdcr.coderetreat.org/">Global Day of Coderetreat</a> at our eBay offices in Tel-Aviv. This was the 4th year hosting and facilitating the GDCR one of my favorite events of the year.
This year we got really creative and came up with a completely brand new type of session which was great!</p>

<!--more-->

<p><img src="/images/posts/gdcr/too-many-cooks.jpg" alt="" />
<small class="text-center">People mesmerized to ‘Too Many Cooks’</small></p>

<p>For those of you who haven’t heard about it - the <a href="http://gdcr.coderetreat.org/">Global Day of Coderetreat</a> is a day where 150+ cities around the world, from Australia to Hawaii, all host a coderetreat.<br />
Coderetreats are events where developers come together to hone their craft and work on bettering themselves and their coding community.<br />
In a coderetreat we usually have 6 sessions throughout the day where you solve <a href="http://en.wikipedia.org/wiki/Conway's_Game_of_Life">Conway’s Game of Life</a> each time paired with a different partner and set to different constraints.</p>

<p><img src="/images/posts/gdcr/Gospers_glider_gun.gif" alt="" /></p>

<p>This year me and my co-host <a href="http://twitter.com/avivby">@avivby</a> wanted to try something new.
For the past 3 years we have a routine that more or less works, with the order and timing of the different sessions.</p>

<p>We had a small issue in past years that after lunch people get tired - to try and combat that we moved our best session (the evil mute programmer) to be just after lunch. This helped greatly but created a new issue - now people where getting unfocused after this 4th session.</p>

<p>We were talking before this year’s event and trying to come up with a new and exciting session that we can add during the day. I remembered that in the last GOGARUCO I was exposed to a different code kata called the <a href="https://github.com/professor/GildedRose">The Gilded Rose</a>, I really liked the idea of having a kata where you work on existing code that simulates the pain of working on a real legacy system.<br />
We decided that we want to have a sessions like that in this years’ coderetreat, we discussed where the source/starting code will be from and though what better than from the evil mute programmer session.</p>

<h3 id="initech---new-employee-onboarding-process">Initech - New employee onboarding process</h3>
<p>So in this year’s coderetreat at the end of the 4th session (Evil mute programmers) we asked everyone instead of deleting the code to zip the code and tests and to upload them to a mini-site that we set up for them.
<img src="/images/posts/gdcr/upload.png" alt="" /></p>

<p>After the retrospective for the 4th session we kicked of the 5th session by welcoming everyone to their new job at Initech and assuring them that the legacy system they’re going to be working on for the next session was built by our best people :)</p>

<p><img src="/images/posts/gdcr/choose.png" alt="" />
In this 5th session they would be receiving a random zip file containing the code from one of the other pairs in the previous session and they had to complete the code while fitting the code to a new constraint (they now have to support a sized infinite world.)
<img src="/images/posts/gdcr/download.png" alt="" />
This session was a blast, almost as fun as the evil mute programmer one - people had the chance to receive code that had tests (even though they they didn’t always pass) and have to adapt someone else’s code. It really helped keep the excitement from the 4th session alive and had people very energetic all the way to the end of the coderetreat.</p>

<h3 id="building-the-site">Building the site</h3>
<p>The mini-site is very simple, it’s a single page application written with Backbone, Coffeescript, SASS, HAML &amp; Parse.com.
It isn’t the nicest piece of code but I built it in a couple of hours and it works.<br />
I chose to use Parse as a database/backend mostly because I wanted to try it out and it was a delightful experience. It was super easy to get going with Parse as a simple data storage and even easier to integrate it with Backbone.<br />
It was a long time since I’ve done Backbone without Marionette - and I really can’t see how one can do that in a real project. <a href="http://marionettejs.com/">Marionette</a> just solves so much of the cruft that comes out of working with Backbone.</p>

<p><img src="/images/posts/gdcr/parse.png" alt="" /></p>

<p>I built the mini-site as part of the already existing site I had for the Israeli coderetreat events so it was based on a very simple Sinatra server that compiles the HAML/SASS/Coffee - but you can probably do without it and deploy to S3 or anyplace that accepts static sites.</p>

<p>I extracted the code so you can easily set up your own server running on Heroku - just <a href="https://github.com/yonbergman/coderetreat-initech">clone the repo</a> and follow the instructions.</p>

<hr />

<p>If you haven’t participated in a coderetreat yet, look for the next one being held close to you or organize one by yourself. It’s an exciting event that brings back energy and passion into coding.</p>

<p>You can always find me on twitter <a href="http://twitter.com/yonbergman">@yonbergman</a>.</p>]]></content><author><name>Yon Bergman</name></author><category term="culture" /><summary type="html"><![CDATA[This weekend I had the pleasure of hosting the 4th annual Global Day of Coderetreat at our eBay offices in Tel-Aviv. This was the 4th year hosting and facilitating the GDCR one of my favorite events of the year. This year we got really creative and came up with a completely brand new type of session which was great!]]></summary></entry><entry><title type="html">Meiosis in Rails Apps</title><link href="http://www.yonbergman.com/2014/11/09/meiosis-in-rails-apps/" rel="alternate" type="text/html" title="Meiosis in Rails Apps" /><published>2014-11-09T14:36:35-06:00</published><updated>2014-11-09T14:36:35-06:00</updated><id>http://www.yonbergman.com/2014/11/09/meiosis-in-rails-apps</id><content type="html" xml:base="http://www.yonbergman.com/2014/11/09/meiosis-in-rails-apps/"><![CDATA[<p>After coming back from an exiting trip to the US and talking at GOGARUCO I had the chance to give a more technical talk this year in my own city of Tel-Aviv.</p>

<!--more-->

<p>Last week we had the 3rd Israeli Rails conference in Tel-Aviv and I had fun meeting all the guests coming to give talks and share a drink with them.</p>

<p>I also gave a more technical talk about splitting a Rails app into several apps and gems and gave a case study for an app I got to work on.</p>

<h2 id="slides">Slides</h2>
<script async="" class="speakerdeck-embed" data-id="79566940449b013247e31e66e8a60207" data-ratio="1.33333333333333" src="//speakerdeck.com/assets/embed.js"></script>

<h2 id="video">Video</h2>
<p>Coming soon</p>]]></content><author><name>Yon Bergman</name></author><category term="talks" /><category term="rails" /><category term="ruby" /><summary type="html"><![CDATA[After coming back from an exiting trip to the US and talking at GOGARUCO I had the chance to give a more technical talk this year in my own city of Tel-Aviv.]]></summary></entry><entry><title type="html">Building Board Games with Ruby - GoGaRuCo 2014</title><link href="http://www.yonbergman.com/2014/10/01/building-board-games-with-ruby-gogaruco-2014/" rel="alternate" type="text/html" title="Building Board Games with Ruby - GoGaRuCo 2014" /><published>2014-10-01T00:00:00-05:00</published><updated>2014-10-01T00:00:00-05:00</updated><id>http://www.yonbergman.com/2014/10/01/building-board-games-with-ruby-gogaruco-2014</id><content type="html" xml:base="http://www.yonbergman.com/2014/10/01/building-board-games-with-ruby-gogaruco-2014/"><![CDATA[<p>I had the absolute pleasure of speaking at this year’s <a href="http://gogaruco.com/speakers/#ybergman">Golden Gate Ruby Conference</a> in San Francisco.
It was my first time speaking outside of Israel and it was awesome.</p>

<p>I want to thank the organizers <a href="https://twitter.com/wifelette">@wifelette</a> <a href="https://twitter.com/joshsusser">@joshsusser</a> <a href="https://twitter.com/purp">@purp</a> &amp; <a href="https://twitter.com/sarahmei">@sarahmei</a> for organizing an aswesome conference.<br />
I was sad to hear that this was the last GoGaRuCo - but was honored to not only attend for the third time but to get to speak at the last GoGaRuCo.
A big shout out goes out to all the other attendees of the conference and especially the other speakers - you were all awesome and super nice.</p>

<!--more-->

<h2 id="talk-summary">Talk Summary</h2>

<p>In my talk I shared the story of how I built and designed my first board game, how ruby helped me hone and optimize the game mechanics and parameters.<br />
I started with a short intro to board gaming right now, what goes into making a game and I continued with my experiences while building <a href="/missiles_and_microchips">Missiles &amp; Microchips</a>.</p>

<h2 id="video">Video</h2>
<iframe width="560" height="315" src="//www.youtube.com/embed/EcnvbsXdbtI?rel=0" frameborder="0" allowfullscreen=""></iframe>

<h2 id="slides">Slides</h2>
<script async="" class="speakerdeck-embed" data-id="a655fd5022790132ff8e7a94a7c4ee2d" data-ratio="1.77777777777778" src="//speakerdeck.com/assets/embed.js"></script>

<h2 id="sketch-note">Sketch Note</h2>
<p><img src="https://pbs.twimg.com/media/Bx7WhNxCQAAfv6i.jpg" alt="" />
+10 awesome points to <a href="https://twitter.com/jessabean">@jessabean</a> who not only gave an awesome talk on Sketch Noting but sketch noted several talks including mine ;)</p>]]></content><author><name>Yon Bergman</name></author><category term="talks," /><category term="ruby" /><summary type="html"><![CDATA[I had the absolute pleasure of speaking at this year’s Golden Gate Ruby Conference in San Francisco. It was my first time speaking outside of Israel and it was awesome.]]></summary></entry><entry><title type="html">Building an API with Rails: Parsing Data</title><link href="http://www.yonbergman.com/2014/08/20/building_api_with_rails_parsing_data/" rel="alternate" type="text/html" title="Building an API with Rails: Parsing Data" /><published>2014-08-20T15:14:32-05:00</published><updated>2014-08-20T15:14:32-05:00</updated><id>http://www.yonbergman.com/2014/08/20/building_api_with_rails_parsing_data</id><content type="html" xml:base="http://www.yonbergman.com/2014/08/20/building_api_with_rails_parsing_data/"><![CDATA[<p>Recently I had the chance of working on a project that was 95% API. 
There are tons of blog posts on the best practices behind building an API with Rails. Most of them have a lot of very cool info on things from security, versioning and auditing calls.
Many of the guides mention the importance of using a serializer that’s more complex and feature-full than Rails’ standard <code class="language-plaintext highlighter-rouge">respond_to</code> and <code class="language-plaintext highlighter-rouge">.to_json</code>.</p>

<p>You have many options, whether it’s
<a href="https://github.com/rails/jbuilder">JBuilder</a>, 
<a href="https://github.com/rails-api/active_model_serializers">ActiveModel::Serializer</a>, 
<a href="https://github.com/intridea/grape#restful-model-representations">Grape</a>,
or <a href="https://github.com/nesquena/rabl">Rabl</a>.</p>

<!--more-->

<p><img src="/images/posts/parsing_api/cuneiform.jpg" />&lt;/img&gt;</p>

<p>I found that <a href="https://github.com/rails-api/active_model_serializers">ActiveModel::Serializer</a> works in a way that best fits me, both from functionality and style perspectives.<br />
The issue with these libraries is that they only handle the creation of JSON representations of your data objects in a way that you can pass out, but what about the other way around?<br />
When writing an API, you will encounter the need to parse data sent to you from JSON format to something that fits your object model.</p>

<h2 id="parsing-data">Parsing Data</h2>

<p>I found that using <a href="https://github.com/intridea/hashie">Hashie</a> is the best tool for this job. It fits the style I was looking for and mirrors using ActiveModel::Serializer on the serializing end.
Hashie is awesome because it comes with a lot of things out the gate that helps you parse nested data objects.
Hashie has verification and transformation capabilities which are a <strong>must</strong> when working with data passed into your system.
Hashie also provides a very clean output that both works as a Hash (with indifferent access) <code class="language-plaintext highlighter-rouge">object[:property]</code> and as an object that you can access like a regular class <code class="language-plaintext highlighter-rouge">object.property</code>.</p>

<p>Here’s an example of parsing a request sent to an imaginary API that books tickets:</p>

<div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">module</span> <span class="nn">Api</span>
 <span class="k">class</span> <span class="nc">TicketBooker</span>
    <span class="k">def</span> <span class="nc">self</span><span class="o">.</span><span class="nf">book_ticket</span><span class="p">(</span><span class="n">request_body</span><span class="p">)</span>
        <span class="n">parsed_request</span> <span class="o">=</span> <span class="n">new</span> <span class="no">Request</span><span class="p">(</span><span class="n">request_body</span><span class="p">)</span>
        <span class="c1"># ... more work</span>
    <span class="k">end</span>
 <span class="k">end</span>
 
 <span class="c1"># Incoming JSON format</span>
 <span class="c1"># {</span>
 <span class="c1">#   'user_id': 13,</span>
 <span class="c1">#   'booking': {</span>
 <span class="c1">#     'show_id': 37,</span>
 <span class="c1">#     'price': 75.99,</span>
 <span class="c1">#     'seats': 2,</span>
 <span class="c1">#     'preorder': true,</span>
 <span class="c1">#   }</span>
 <span class="c1"># }</span>

 <span class="k">class</span> <span class="nc">Request</span> <span class="o">&lt;</span> <span class="no">Hashie</span><span class="o">::</span><span class="no">Trash</span>
  <span class="n">property</span> <span class="ss">:user_id</span><span class="p">,</span> <span class="ss">required: </span><span class="kp">true</span>
  <span class="n">property</span> <span class="ss">:booking</span><span class="p">,</span> 
           <span class="ss">with: </span><span class="o">-&gt;</span> <span class="p">(</span><span class="nb">hash</span><span class="p">)</span> <span class="p">{</span> <span class="no">Request</span><span class="o">::</span><span class="no">Booking</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="nb">hash</span><span class="p">.</span><span class="nf">symbolize_keys</span><span class="p">)</span> <span class="p">}</span>

  <span class="k">class</span> <span class="nc">Booking</span> <span class="o">&lt;</span> <span class="no">Hashie</span><span class="o">::</span><span class="no">Trash</span>
    <span class="n">property</span> <span class="ss">:show_id</span><span class="p">,</span> <span class="ss">required: </span><span class="kp">true</span>
    <span class="n">property</span> <span class="ss">:price_cents</span><span class="p">,</span> <span class="ss">from: :price</span><span class="p">,</span> <span class="ss">with: </span><span class="o">-&gt;</span> <span class="p">(</span><span class="n">float</span><span class="p">)</span> <span class="p">{</span> <span class="p">(</span><span class="n">float</span> <span class="o">*</span> <span class="mi">100</span><span class="p">).</span><span class="nf">to_i</span> <span class="p">}</span>
    <span class="n">property</span> <span class="ss">:number_of_seats</span><span class="p">,</span> <span class="ss">from: :seats</span>
    <span class="n">property</span> <span class="ss">:preorder</span>
  <span class="k">end</span>
<span class="k">end</span>


</code></pre></div></div>

<p>This code accepts a JSON and parses the data out into the format that the rest of the system accepts. 
You can nest as many of these as you want, as we use the Hashie::Trash’s transformation block to pass the parsing to a deeper level of the nesting.</p>

<p>It also handles exceptions really well - if a required parameter is missing an <code class="language-plaintext highlighter-rouge">ArgumentError</code> will be raised.
Similarly, if the user passes any unexpected parameter a <code class="language-plaintext highlighter-rouge">NoMethodError</code> will be raised.<br />
You could potentially allow passing of unknown parameters by including a module provided in hashie.</p>

<div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">class</span> <span class="nc">Request</span> <span class="o">&lt;</span> <span class="no">Hashie</span><span class="o">::</span><span class="no">Trash</span>
  <span class="kp">include</span> <span class="no">Hashie</span><span class="o">::</span><span class="no">Extensions</span><span class="o">::</span><span class="no">IgnoreUndeclared</span>
<span class="k">end</span>
</code></pre></div></div>

<p>The Hashie::Trash object created is really flexible and you can use it as a clean object and access properties in a very nice way, or as a Hash which you can use it normally. <br />
Potentially you could transform the inbounding request to fit a Rails’ nested_attributes chain so that you could validate the data and pass it straight to a Rails’ model <code class="language-plaintext highlighter-rouge">.create</code> method which is really cool - just note that if you do that and use Rails 4+ or strong parameters, you’ll need to use <a href="https://github.com/Maxim-Filimonov/hashie_rails">Hashie::Rails</a> which bypasses an issue with <code class="language-plaintext highlighter-rouge">:permitted?</code> on Hashie objects.</p>

<div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1"># using a Hashie object</span>

<span class="n">parsed_request</span> <span class="o">=</span> <span class="n">new</span> <span class="no">Request</span><span class="p">(</span><span class="n">request_body</span><span class="p">)</span>
<span class="n">parsed_request</span><span class="p">.</span><span class="nf">user_id</span>                <span class="c1"># 13</span>
<span class="n">parsed_request</span><span class="p">[</span><span class="ss">:user_id</span><span class="p">]</span>              <span class="c1"># 13</span>
<span class="n">parsed_request</span><span class="p">.</span><span class="nf">booking</span><span class="p">.</span><span class="nf">price_cents</span>    <span class="c1"># 7599</span>
<span class="n">parsed_request</span><span class="p">.</span><span class="nf">booking</span><span class="p">[</span><span class="ss">:price_cents</span><span class="p">]</span>  <span class="c1"># 7599</span>
<span class="n">parsed_request</span><span class="p">.</span><span class="nf">booking</span><span class="p">.</span><span class="nf">preorder?</span>      <span class="c1"># true</span>
<span class="n">parsed_request</span><span class="p">.</span><span class="nf">merge!</span><span class="p">({</span><span class="ss">foo: :bar</span><span class="p">})</span>    <span class="c1"># {...}</span>
</code></pre></div></div>

<h2 id="other-uses">Other Uses</h2>

<p>You can also use Hashie to parse responses when you call an API.
It’s super useful especially when working with APIs that have a very standard way to respond.
I first saw this used in an old version of <a href="https://github.com/octokit/octokit.rb/tree/v1.25.0">Octokit</a> where they used <a href="https://github.com/lostisland/faraday_middleware/blob/master/lib/faraday_middleware/response/mashify.rb">Faraday</a> to mashify the responses from the GitHub API.<br />
<em>Hashie::Mash</em> is a more loose version of Hashie::Trash that doesn’t support transformations or requires and is useful when you just want to generically wrap a Hash in a more robust interface. Hashie::Mash is also auto deep, meaning that any sub-hashes are also wrapped by the Mash.</p>

<p>When I started wrapping calls to other APIs in the server, I also used Hashie to parse the responses generated, although I used <a href="https://github.com/jnunemaker/httparty">HTTParty</a> and not Faraday to do the calls. (The code that wrapped the response was delegated to an HTTParty parser, but that’s a story for a different blog post.)</p>

<hr />

<p>When working on the API, it was very surprising that not many people touched the subject of parsing requests and I hope this helps a few people down the path of building better, more stable APIs… until next time :) <br />
You can always find me on twitter <a href="http://twitter.com/yonbergman">@yonbergman</a>.</p>

<p><em>P.S.</em> I’ll be speaking at this year’s <a href="http://gogaruco.com/speakers/#ybergman">Golden Gate Ruby Conference</a> in San Francisco in September. It’d be cool to meet you so say hey if you see me walking around the conference hall.</p>]]></content><author><name>Yon Bergman</name></author><category term="rails," /><category term="ruby" /><summary type="html"><![CDATA[Recently I had the chance of working on a project that was 95% API. There are tons of blog posts on the best practices behind building an API with Rails. Most of them have a lot of very cool info on things from security, versioning and auditing calls. Many of the guides mention the importance of using a serializer that’s more complex and feature-full than Rails’ standard respond_to and .to_json.]]></summary></entry></feed>