All posts filed under: programming

Spring Boot JAXB unable to marshal type error

java / programming

Working with a SOAP API with Spring Boot WS. I was getting the following error trying to create the request. I was originally directly using the JAXB generated classes to form my requests: The correct way is to use the provided JAXB ObjectFactory: But to prevent marshalling errors you need to wrap your object in a JAXBElement object: [crayon-5f9014b1e5ba4976259700/]

Stupid coding mistakes

programming / ruby

Made this mistake today while writing some code to delete data out of Redis. [crayon-5f9014b1e627f899590848/] The mistake was in the final method keep_keys. Every check to see if a key should be rejected I was adding an element to the flattened_keys array over and over again, causing my deletion to slow down over time. A simple change to memoize the keep keys made the process go from never finishing to, completing in a few seconds. […]

Using Typeahead.js without Bloodhound


A great library for adding typeahead support to your site is Twitter’s Typeahead.js. Even better is the excellent Bloodhound suggestion engine which comes with it. Sometimes though if you’re dealing with a remote suggestion engine like Elasticsearch’s completion suggester you don’t need to run remote results once again through another suggestion engine. Bypassing Bloodhound is as simple as hooking your own source function into your Typeahead definition. [crayon-5f9014b1e6311929821128/]  

Naming service classes in Rails

programming / rails

One of the core ideas of Rails is convention over configurations. Models go in app/models, controllers go in app/controllers and views go in app/views. The danger is that we stick to those conventions no matter what and we end up either with fat controllers, fat models or even worse a mixture of both. Many times we don’t take enough advantage of Ruby’s object oriented nature and the ability to extract functionality out into separate classes. Doing […]



All too often I find that CSS quickly becomes a real tangle of clashing styles and names. No matter how hard I try something always ends up breaking the styles of something else. Moving to SASS helped a lot but I find on the flip side I end up with styling that’s overly nested. I’ve recently come across BEM which is CSS methodology for naming classes. BEM stands for Blocks, Elements, Modifiers. I’ve previously looked into SMACSS […]

Better sort by rating with Spree and spree_reviews

computing / programming

The blog post How Not To Sort By Average Rating continually pops up and got me thinking about how we currently implement sort by rating. We currently use spree_reviews for capturing ratings and it takes a very simplistic approach to storing the average rating for a product: This exact scenario is mentioned in the blog post above: Why it is wrong: Average rating works fine if you always have a ton of ratings, but suppose […]

The technical debt of your former self

computing / programming

As we mature and become better developers there’s a funny case of code we previously wrote taking on a certain amount of technical debt purely because we have more experience and knowledge on how to tackle the same problems. We’ve all been there, having gone back to look at code we thought was great at the time to only wonder what the hell we were thinking, or gone back to reduce a long method to […]

Hard Deadlines

annoyances / programming

On almost every single project I’ve worked on, hard deadlines have nearly always been the cause of any stress or frustration that arises. One day you’re asked to make rough estimates and then next thing you know they become pegged to a date in the future that you must meet at all cost (But you said you think it would only take X days!). Even worse is when someone non-technical makes the estimates for you […]

Adding a custom Spree payment Gateway outside a Rails Engine

computing / programming / rails / spree

Adding a new Payment Gateway to Spree through a Rails Engine is pretty straight forward as you can hook in your new gateway after the initial payment gateway array has been created. This is how the spree_gateway gem does it: [crayon-5f9014b1e6529336396954/] If you want to do the same thing for your own project contained gateway it’s a little different. If you try to just directly edit the payment_methods array in an initializer it will get […]