While trying to setup a new Rails 5.2 app in Intellij it would continually be detected as a web project and give no way of adding the Ruby on Rails module. The solution is to delete the node_modules folder before creating the new project.
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-5f7071a0b1b5c915802623/]
Trying out chruby and ruby-install and installing Ruby 2.2.2 with ruby-install was giving be the error: [crayon-5f7071a0b57c0480576760/] Setting the LDFLAGS env var solved this for me: [crayon-5f7071a0b57c6108750259/]
To run Alacritty without spawning a new terminal window you can use Automator to create a new application wrapper. Create a new application document and choose Run Shell Script as the action. Then simply add the path to your built Alacritty and save the document to your Applications folder.
Made this mistake today while writing some code to delete data out of Redis. [crayon-5f7071a0b5834608141322/] 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. […]
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-5f7071a0b5891802377036/]
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 […]
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 […]
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 […]
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 […]
Some custom reports I was adding to Spree required links back to the products being listed. Accessing the Spree routes is slightly different to accessing normal Rails routes from outside a controller/view: [crayon-5f7071a0b5986525823844/]
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-5f7071a0b59d9698340026/] 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 […]
Editing a CSV file which split whenever there was a DOS carriage return (^M). Joining up the lines was as simple as using the command below. To get the ^M char you use CTRL+V CTRL+M (don’t let go of CTRL in-between). [crayon-5f7071a0b5a31041390709/]
Get a little bit more room in vim by hiding the righthand toolbar. Set this in your .gvimrc " Don't show right scrollbar set guioptions-=r