This tumblog is dead-is-dead-is-dead
You’ll now find me at regretful.ly
Same infrequent posts, same lack of attention, same adoration of all impractical, but now with a newer, sadder name. Win win!
You’ll now find me at regretful.ly
Same infrequent posts, same lack of attention, same adoration of all impractical, but now with a newer, sadder name. Win win!
Simple to reason about
Simple to decompose
Simple to compose
Composition leads to reuse
Programming, motherfucker
Lightweight Syntax
Pragmatic
Hype
Fun
Simplicity vs Ease
This is a stupid slide, we can talk about it later.
Service Layer behind a Rails app
Full Stack
During the times we’re not using Clojure, we will be better Ruby devs for having done so
Learning new things is hard
We are the next wave of BASIC programmers
As a Rubyist that learning curve is lower
Tooling
Vulnerability
This becomes more apparent to me every day
Let’s look at some code
There are two things that immediately strike me as problematic when trying to talk to you (dear reader audience), and those are as such: ego and confidence. Perhaps with more concision that could be said as solely confidence.
I need to feel good about what I’m saying to you personally, which I seldom do. I often reflect fondly upon things I’ve done or said or created in the past, but seldom at the moment (and the times I do, tend to be with crafts I’m more practiced in, writing not being one of them). So, here is an open effort to disregard that inkling of stfu that’s lurking back there.
Second, and more importantly (and perhaps encompassing the first) is confidence. I don’t know about you, but myself, as a student of all things and everything, am very seldom confident in… well, anything. Right? It would be foolish to be so. There are so many (brilliant) people out there, doing so many (brilliant) things, that are on levels that I can only begin to grasp, why should I think that anything I do is actually correct? (or even approaching being as such).
Perhaps the problem is even simpler than ego and confidence, it’s an issue of respect really. If you’re going to read what I’m putting forth here, it should be worth your time. When it’s something brief and obviously helpful (ie: found this in a google search, thanks bro!) then yes, I can justify breathing these words in front of you, when it’s me waxing philosophically about my current understanding of software (development), then it’s MUCH LESS OBVIOUSLY SO, to me.
From here on out I’m going to assume what I have to say matters with the hopes that one day it does. Sorry in the meantime, but I hope when we’re approaching the end of our journey you’ll forgive me (and that I’ve produced something of value to you).
TLDR: Fuck it, I need to brush up on my prose. (Also, wtf, c’mon, someone has to listen to me. You like hearing about monads from someone who doesn’t have a cs degree and hearing about life from someone who can’t figure it out, right?)
(ending with a statement in parens is pretty lacking in emphasis)
A (perhaps crude) exploration of the Maybe Monad in Ruby.
I realize this is somewhat treaded turf, however it was done for my own learning, and I think came out pretty clean! Needs tests and could be made more flexible, yada yada.
Usage:
nil.maybe { |n| n + 2 + 3 }
=> nil
Which is essentially the same as nil.try(:+, 1).try(:+, 2).try(:+, 3) If the result is nil anywhere in the chain, the block simply returns nil
I doubt I’d actually do this, but the pattern of defining a method, only to have it return the inverse of another method is common enough.
ie:
def unregistered? !registered end
But alas… stupid ruby things are fun.
So there.
Currently, ruby-debug19 head is broken in ruby 1.9.2
in your Gemfile, have you happily debugging again.
Thanks to abuiles for finding this solution :)
Last week, @voxdolo and I were faced with a problem: our application needed to make 3 API calls at once, and while two of the services were ok (finishing in three seconds or so), the third would take up to 8 seconds to retrieve it’s data. When done synchronously this meant on a good day we’d get out in 14 seconds, which is simply unacceptable.
After deciding we didn’t want to manage threads ourselves, we discovered the excellent Peach library. Peach, which stands for parallel each, is an insert and go parallelized each (via [].peach) for arrays, not to mention map ([].pmap) and select ([].pselect). Simply replace the standard ruby method calls you need to be asynchronous with the peach equivalent, and you’re good to go.
In case you haven’t gotten it yet…
So while the name is only clever for the basic each, the lib is still awesome for quickly tackling async actions.
With a little UX love and the now 8 second data retrieval, we were able to make this workflow intuitive to the user (and less painful in development). Huzzah.
One caveat: In using this with MRI, you will see a slight decrease in speed of an individual process, however in our case, the gains have been dramatic.
One should be aware when using ! methods (slice!, map!, etc!) on the collections returned from Mongoid queries ie:
foos does not have foo1..3 shifted from the array as you’d expect, it’s state has not been mutated.
I’m not sure if this is by design or otherwise (it most certainly is a by-product of the lazily evaluated nature of Mongoid queries, but for the time being
foos = foos.to_a; foos.slice!(0,3)
will do the trick.
Just something to look out for!
I’ve been using RVM (and gemsets) to manage my Rubies lately, to much success.
I however ran into the issue today of trying to install rspactor (think autotest on ‘roids) which depends on RubyCocoa to monitor changes to the filesystem.
As it would turn out, when you vanilla install a Ruby via RVM, RubyCocoa is unsupported.
To enable installation of RubyCocoa you’ll need to set a few flags during Ruby installation:
rvm install 1.8.7 --debug --reconfigure -C --enable-shared=yes
Then you are able to configure and install RubyCocoa as usual
cd path/to/rubycocoa/src
ruby install.rb config --build-universal=yes
ruby install.rb setup
ruby install.rb install
Thanks to a googled gist for the nudge(handholdingpush) in the right direction.