Now that I’m become firmly entrenched in the Javascript world, I figured it was high time that I read ‘The Good Parts’. Since I’m working in React, and since React is just just Javascript, it wasn’t too hard to get through, though one exercise took me a bit to get my head around - Curry.
Tap, Inject, and Each_With_Object
I realized the other day that, while I’ve been using Object#tap, Enumerator#each#with_object, and Enumerable#each_with_object for some time now, I wasn’t completely clear on the difference between these methods or how best to employ them. Mostly I just threw in Object#tap wherever I saw sandwich code and called it a day.
Time for a…
Keyword Arguments
During a morning standup (less fun than actual standup) at work someone mentioned that a method was a good candidate for a refactor using Keyword Arguments. So I went back to my desk, googled it, and my newb brain said ‘Why?’.
A New Hash#map
The Problem
The Enumerable mixin’s #map/#collect methods are fantastic for mutating the values in an array but have an inconsistent behavior when applied to a hash. So since using #map/#collect on an array gives you this:
1 2 |
|
you might expect the hash to behave something like this:
1 2 |
|
but instead you get:
SyntaxError: (irb):1: syntax error, unexpected ':', expecting '}'
Everyday Rails: Testing With RSpec
What’s a pirate’s favorite testing framework? ArrrrrrrrSpec!
This past week I’ve been working through Aaron Sumner’s “Everyday Rails Testing with RSpec” in order to bone up on my TDD. This is the CliffsNotes version since, unlike ‘Romeo and Juliet’, you can’t run down to Blockbuster and rent the movie. Mostly because good luck finding a Blockbuster and also, not a lot of movies about Rails… or RSpec… I didn’t notice any model specs in the 1995 classic ‘Hackers’.
If You Want to Ace the Interview, You've Got to Break a Few Eggs: The Two Egg Problem
Someone from the previous Flatiron class (class 04-15, wish I could remember his name) sat with me and Sarah for a while, like, a long while sometime in the middle of August to walk us through a couple of questions that he or his classmates had been asked during technical interviews. One was the “Birthday Paradox” and the other was the “Two Egg Problem”.
<-MACHINE->
“Finite State Machines” is one of those terms that I’ve heard mentioned but never found the time to look into. Now that I’ve finished my three months at the Flatiron School I figured that I would give it a look.
I Didn't Write a Blog Post for Today So Here Are Some Pictures of Animals
3Dify Yourself: Three.js
Three.js is a Javascript library designed to be used to render 3D objects and animations in the browser using WebGL. It allows you to create animations without relying on proprietary plugins using the end-users GPU and as well as providing a bunch of classes and functions to let you skip a whole bunch of programming and move straight to the animating.
Primes With Regex
I ran across a blog post explaining how you can use regular expressions to determine if a number is prime. It seems like an odd use and it has been a while (kinda? Like four whole weeks!) since I’ve used regular expressions so it took a a bit of time and a whole lot of whiteboard space to figure out what was happening so this is the post topic that you’re getting god dammit!