Thursday, June 25, 2015

Creating ES6 JSfiddles with Babel

One of the things I’ve wanted to start to start learning is what is new in ES6.  There are a lot of new features in ES6 that are pretty awesome.  There are some that can even be implemented today using other libraries or polyfills such as promises.  However, for other features it can be harder to implement.  

The good news is there are libraries out there that will compile your ES6 script into backwards compatible JS.  The one I am looking into is Babel  https://babeljs.io.  Babel would typically be set up in your development/build process like any other compiler, but this one would theoretically fade away and leave you with ES6 scripts when browsers catch up to it.  

So to get started playing around with ES6 scripts, Babel has provided a live editor here: https://babeljs.io/repl/ which is nice.  However that doesn’t let you save anything, or show it off in a blog, etc.  So I went to see if JS fiddle has any out of the box support for Babel, and found it doesn’t.  I knew that Babel had a client side compiler (which shouldn’t obviously be used for production), so I tried to find that listed somewhere in a CDN.  I couldn’t find it, so I decided to see if I can reference it via google drive.  After some time investigating and finding this site I found how I was able to do it http://www.komku.org/2013/08/how-to-host-javascript-or-css-files-on-google-drive.html.  You are only allowed to reference files with a .js extension so I had to use method 1, and I generated the following url https://www.googledrive.com/host/0B4QQSpfhQZN5bXdTVTI0VFpjZW8/browser.js

    
Once you have it listed as an external resource on the JS Fiddle you can then create <script> blocks with the type of text/babel in your HTML area.  Once babel loads it will automatically compile those blocks and you are good to go!

Cheers!

Thursday, June 11, 2015

Project Euler

A couple years back I started on my first project Euler problem, and just a bit ago I finished my 50th problem.   If you aren't familiar with Project Euler, it is essentially a bunch of math problems that you solve programmatically, but you can read more about it on the site.

I didn't know until this blog post.

I really enjoy working on these challenges.  The problems typically require good problem solving, efficient algorithms, and good use of data structures.  So these types of problems are great for learning a new language, practicing an old one, preparing for an interview, or just honing your coding skills.  I have become fairly decent in Ruby by working on these (and a few other projects) to the point where I can pick it up after a few months of not using it and not miss a beat.

I might switch up languages soon.  I have always thought about trying out a true functional language, just for fun.  Regardless,  I plan on solving problems every so often to keep my skills sharp.  You can see all of my solutions (good and bad) on github here.   Also if you try it out and like it, you can add friends on project Euler to track each other's progress.  Add me with the following key 517763_1aef854359e6e315b4f1e358b8544e78 and I will add you back.

Cheers!