Quantcast
Channel: Lucas Caton - English posts
Browsing latest articles
Browse All 66 View Live

How to test Rails mailers using RSpec

ActionMailer module has been reconstructed in Rails 3 and mailers have their own subdirectory (app/mailers) since then.This blog post will demostrate how to test them in Rails using RSpec. Assuming...

View Article



My Vimfiles

Vimfiles are configuration files for the Vim editor. It includes the editor preferences, theme (color scheme), fonts, plugins, custom functions, and more.I’ve finally created my own from scrach, which...

View Article

My new gem "code2pdf"

I’ve created a gem called code2pdf, which is a simple and open-source tool to convert your codebase to a PDF file. It might be especially useful in case you need to register you software.In order to...

View Article

How to remove several lines in the Vim editor using Regex

A quick tip for those who use Vim: if you need to remove several lines that match your regular expression, you can achive that by running:g/pattern/dLet’s say you want to remove the commented lines...

View Article

Regex to match Youtube URLs (using Ruby)

I’ve created a regular expression in order to match Youtube URLs. As Youtube URLs starts with https://youtube.com and https://youtu.be, the following regex solves the...

View Article


My dotfiles

I’ve finally created a repository with my dotfiles. Dotfiles are configurations files, usually with their names beginning with a dot (hidden files) and located on your home folder (~/).You can check it...

View Article

Image may be NSFW.
Clik here to view.

Replacing "Selenium" with "Poltergeist"

My friend @pellegrino gave me an awesome tip: to replace “Selenium” with “Poltergeist”. For those who don’t know, Poltergeist is a PhantomJS driver for Capybara. I’ve done it in some projects and it...

View Article

Pair programming with tmux

Server:tmux -2-S /tmp/pair new-session -s PairProgramming chmod 777 /tmp/pairClient:tmux -2-S /tmp/pair attach-session -t PairProgramming

View Article


How to test ElasticSearch in a Rails application

When I started using ElasticSearch in my Rails applications, I had a problem to create separate indexes for the automated tests.The problem was: there is no way to create more than one database in...

View Article


Image may be NSFW.
Clik here to view.

New blog layout

I’ve finally changed my blog theme.This one is cleaner, I hope y’all enjoy it :)

View Article

Image may be NSFW.
Clik here to view.

An easy way to split windows in Vim

There are several ways to split windows in Vim.This one is now my favorite:

View Article

Image may be NSFW.
Clik here to view.

A simple way to deploy your Rails applications

When I have a very simple Rails app, I avoid adding Capistrano or any other complex tool to deploy it.Instead, I use a simple shell script, which access the server via SHH and do what needs to be...

View Article

Getting root permission to change a file without leaving Vim

You know when you open a file on Vim and after some changes you realise you’d need root permission to save the changes?I used to think that there isn’t other way other than:Copy the content of the...

View Article


Image may be NSFW.
Clik here to view.

Hellо, I am a compiler

I’ve found the following text here and thought it’d be nice to share it with you. Hope you enjoy it as much as I did :)Hellо, I am a compiler.I just scanned thousands of lines of code while you were...

View Article

Image may be NSFW.
Clik here to view.

Interesting script written in Ruby: "The Globe"

I’ve just found this amazing Ruby script!In order to run it yourself, just create a Ruby file called a.rb with the following content:v=0000;eval$s=%q~d=%!^Lcf<LK8,...

View Article


Image may be NSFW.
Clik here to view.

Have a Rails 2 app? You can run it on the newest Ruby!

Do you have a legacy Rails application which is still running on Rails 2?There are several reasons to migrate your application to new Rails versions, like to improve the security, to be able to use a...

View Article

Image may be NSFW.
Clik here to view.

An awesome Wiki built with Ruby and Rails!

I’ve been worked on a small open-source project. I’m talking about ruby_wiki, a simple wiki built with Ruby on Rails:If you’re interested, feel free to fork and contribute to the project.

View Article


Image may be NSFW.
Clik here to view.

What's on my macOS menu bar

ApplicationDescriptionTypeCaffeinePrevent your Mac from automatically going to sleep, dimming the screen or starting screen saversFree ColorSnapper Color pickerPaid1PasswordPassword...

View Article

How to use command line on macOS

A friend of mine (who used to use Windows) has bought a Mac recently and he asked me how to use the command line on macOS:My answer was:99% of commands are identical in Linux. This is good news as...

View Article

Image may be NSFW.
Clik here to view.

CampJS 2014 - the best geek event I ever attended

A few days ago I was in CampJS, the best geek event I ever attended.This is the official website (which is pretty cool by the way): http://campjs.com/.Why it was the best in my opinion:It happened at...

View Article

Image may be NSFW.
Clik here to view.

If you really need to create a monkey patch, do it properly

Sometimes we need to create a monkey patch for a gem or external lib. In these cases, it’s good to force it to fail if the gem has been bumped up. Let’s use Paperclip as an...

View Article


Image may be NSFW.
Clik here to view.

What is "frozen_string_literal" in Ruby?

Freezing Strings feature improves apps performance by freezing Strings. So, Matz - Ruby’s creator - decided to make all String literals frozen (immutable) by default in Ruby 3.0.In order to have a...

View Article


Image may be NSFW.
Clik here to view.

Why I regenerated my SSH key and maybe you should too

I think we all agree it’s a good practice to regenerate your SSH key from time to time. Not sure about you, but the first thing that comes to my mind when I think about that is: it’d take forever to...

View Article

Rake task to import a production DB dump

Every now and then I need to write a script (rake task) to import a production database dump.This is code I usually use:require'yaml'namespace:dbdodesc'Downloads and imports a production DB...

View Article

Puma vs. Unicorn

TL; DR - Just use Puma.Rails has changed its default server from Webrick to Puma in Rails 5!It also supports Action Cable (one of the new features from Rails 5) and Basecamp said they’re using Puma in...

View Article


Prevent Rails from writing development/test log files

I can’t remember the last time I needed to open/read log/development.log or log/test.log. These files usualy just consume disk space unnecessarily (some test.log files can easily reach more than 1...

View Article

Image may be NSFW.
Clik here to view.

New blog theme

Last time I updated this blog’s theme was in 2012!It was about time to have a fresh new look and there you have it! \o/

View Article

[Ruby] How to get the name of the calling method?

I was about to run a rake task which would make important changes in my database. My code was similar to this:defmigrate_active_accountsaccounts=Account.active# Code to migrate accounts...

View Article

How to setup multiple Heroku accounts (for heroku-cli)

Both Heroku and its CLI are great. However, there’s no way to access multiple accounts via terminal out of the box. If you have a personal and a work account and need an easy way to switch between...

View Article



How to run your feature specs using Capybara and Headless Chrome

Google has recently announced a way to run the Chrome browser in a headless environment. If you’re using Capybara gem, you can easily start using headless Chrome. Without further ado, let’s do it:1)...

View Article
Browsing latest articles
Browse All 66 View Live




Latest Images