June 21, 2015 by Daniel P. Clark

Ruby Refinements – Not quite ready for production

I recently looked for a method on Array for a boolean response on its uniqueness.  As Ruby currently doesn’t have one I figured it’s easy enough to write one.  Now Ruby’s refinements are fairly new and a nice feature to have around.  So I decided to write a benchmark for different ways to test the…

Continue Reading »

May 2, 2015 by Daniel P. Clark

Private Module Methods in Ruby

So this is something I’ve looked into many times over the years and have never found an answer to.  But great news is that I’ve found a way! It’s as simple as defining module methods as private within the singleton class.  Here’s how I did it in my gem PolyBelongsTo module PolyBelongsTo::Core extend ActiveSupport::Concern included…

Continue Reading »

April 8, 2015 by Daniel P. Clark

Documenting Your Code

I’ve been hearing a majority of developers saying things like “You’re code should be easy enough to understand that you don’t need to document it.” and “Comments are lies waiting to happen”.  I was okay with this and after hearing this for a while I eventually stopped writing code comments. I watched a conference talk…

Continue Reading »

April 4, 2015 by Daniel P. Clark

Getting Started with MiniTest

Whet ever you may believe about testing practices; tests still provide some peace of mind and clarity in projects.  Also; if you build a library for others to use, tests are a form of validation of your work and provide trustworthiness to your code.  In the case of working with a large project that is…

Continue Reading »

March 26, 2015 by Daniel P. Clark

Different Collection Types in Ruby

In computer science, a collection or container is a grouping of some variable number of data items (possibly zero) that have some shared significance to the problem being solved and need to be operated upon together in some controlled fashion. – Wikipedia In Ruby the most common collection types used are known as Array and…

Continue Reading »

March 20, 2015 by Daniel P. Clark

Hooks

When trying to ensure that something happens around some kind of event it’s usually best if you work with a hook designed for that scenario rather than manually implementing one.  This becomes most evident in JavaScript events with jQuery and Bootstrap effects.  If you write an event listener for some change around these effects without…

Continue Reading »

March 12, 2015 by Daniel P. Clark

Substitution with Regex Groupings

As I continue to grow in experience I was looking into how I might do some in-place substitution that I had been accustomed to performing with array matching (split-map-join).  What I’m referring to isn’t just a letter for letter substitution, but something that would find a match and modify it.  For example; if I wanted…

Continue Reading »

March 9, 2015 by Daniel P. Clark

Ruby: Actionable Meta

The more you program the more likely you will need to change a string to the object the string represents. For example you may have a string with a mystery class name in it the you need to call methods on. Lets go a step further, lets say the method you need to call on…

Continue Reading »

March 7, 2015 by Daniel P. Clark

Configuration With a Singleton Instance

I was considering how I might want to further implement my gem and incorporate configuration settings for it.  I wanted only one instance of my configuration and it needed to be part of my module.  So I’ve come up with a solution I like that allows me to do this and even have a true…

Continue Reading »

March 6, 2015 by Daniel P. Clark

Numeric Bases and Defining Your Own

Lately I’ve been teaching my niece a new way to do math.  She would have difficulty with addition and subtraction of numbers if they contained more than a few digits.  I asked her if she’d ever seen a clock where the numbers rolled over (like in the movie Ground Hog Day).  She hadn’t.  I decided…

Continue Reading »

Page 2 of 4
1 2 3 4
1 2 3 4