Rubyland

news, opinion, tutorials, about ruby, aggregated
Sources About
RubyMine Blog 

RubyMine 2018.2 EAP is Open: Attach to Remote Processes With the Debugger, and More!

Hi everybody,

Today we are opening the Early Access Program for RubyMine 2018.2. As making RubyMine more integral and robust is currently our top priority, in this release cycle we are staying focused on upgrading and polishing existing features and subsystems. Here’s what we are ready to give you in the first EAP build:

Download RubyMine 2018.2 EAP

Attach to remote processes with the debugger

In v2016.3, we announced the ability to attach to…

Paweł U. | Ruby on Rails Web Development Consultant Full Stack Blog 

Hosting Static Site on Dokku with Free Cloudflare CDN and SSL

Dokku static website represented by a brick wall

Dokku is dev ops for dummies and a simple way to deploy websites on a barebones VPS. In this blog post, I will describe how to use it to host a static site, and setup global assets caching with free Cloudflare CDN and SSL certificate.

I use jekyll for this blog and until recently I was hosting it on GitHub Pages. I’ve decided to move it to self-hosting with Dokku. Later in this post I will explain why in my particular case self-hosting is a better option.

Initial setup

Some of the steps in this tutorial are identical to my previous post about migrating Rails app from Heroku to Dokku.

First, you need to purchase a barebones VPS and add an SSH access to it. I will not elaborate on how…

Ruby Inside - Medium 

Building A Creative & Fun API Client In Ruby: A Builder Pattern Variation

https://pixabay.com/en/build-play-fun-creative-1159776/

I stumbled upon the Datamuse API the other day as I was looking for thesaurus-like data for some small app I am currently toying with. If you are not a 100% sure what “thesaurus-like data” means, check out Thesaurus.com. For those who consider accuracy and creativity in their choice of words an asset, this is an invaluable tool. Moreover, I find myself using it quite often at work whenever I am looking for a different, sharper name for some class, variable or method; and of course it has many, many more usages. Thesaurus is fun, and the Datamuse API supplies thesaurus-like data that is simple to consume and understand.

In this story, I…

Running with Ruby 

Lenovo ThinkPad X1 Carbon (6th Gen / 2018) Ubuntu 18.04 Tweaks

Warning: I’m not responsible for any damages or injury, including but not limited to special or consequential damages, that result from your use of this instructions.

Yesterday I’ve finally received my new Lenovo ThinkPad X1 Carbon 6 gen laptop. I cannot say anything bad about the hardware. It fits exactly into my needs and requirements. Unfortunately, there are some flaws when used with Linux (Ubuntu in my case). Here are some hints on how to make things better.

Touchpad and Trackpoint under Linux

This is the most irritating issue that you will encounter.

Note: There are few of ways to solve this problem. None of them worked for me apart from this one.

If you have a touchpad with NFC you…

Jekyll • Simple, blog-aware, static sites 

Jekyll 3.8.2 Released

Hello Jekyllers!!

Today we are releasing v3.8.2, which fixes the way Jekyll generates excerpts for posts when the first paragraph of the post contains Liquid tags that take advantage of Liquid’s whitespace control feature.

Big thanks to @kylebarbour, who first reported this issue and also very quickly submitted a fix. Also thanks to @nickskalkin for making sure that we are using the latest version of Rubocop to lint our code.

RubyMine Blog 

RubyMine 2018.1.3: bug-fix update

Hi everyone,

RubyMine 2018.1.3 (build 181.4892.67) is now released. This bug-fix update features the following improvements:

Download RubyMine 2018.1.3

See the release notes for the full list of improvements, and please report any issues you encounter.

Cheers,
Your RubyMine team

Ruby Inside - Medium 

Hot Module Reloading with Webpacker

It is time to give a boost to frontend development in Rails

If you read my previous article on how to switch from Sprockets to Webpacker, you can now start taking advantage of the features Webpack offers. One of the most interesting is Hot Module Reloading, supported out-of-the-box in Webpacker.

By default, Webpacker enables Hot Live Reload, that reloads pages when the resources change.
Just run bin/webpack-dev-server and at every javascript or stylesheet change, the page will be reloaded.

This is a cool feature but we can do a step forward: by using Chrome Devtools Workspaces, and configuring your source maps in a proper way, you can edit them directly in the browser.

Edit source files in…

The Bike Shed 

154: We All Have Work to Do (Eileen Uchitelle)

Eileen Uchitelle joins us live from RailsConf to talk about exciting improvements coming to Rails 6, problems encountered by larger Rails apps, strategies for upgrading Rails and more!

Awesome Ruby Newsletter 

Issue 105 - Paperclip is being deprecated and no longer developed

RubyGems Blog 

2.7.7 Released

RubyGems 2.7.7 includes minor enhancements, bug fixes and compatibility changes.

To update to the latest RubyGems you can run:

gem update --system

If you need to upgrade or downgrade please follow the how to upgrade/downgrade RubyGems instructions. To install RubyGems by hand see the Download RubyGems page.

Minor enhancements:

  • [RequestSet] Only suggest a gem version with an installable platform. Pull request #2175 by Samuel Giddins.
  • Fixed no assignment variables about default gems installation. Pull request #2181 by SHIBATA Hiroshi.
  • Backport improvements for test-case from Ruby core. Pull request #2189 by SHIBATA Hiroshi.
  • Fix ruby warnings in test suite. Pull request #2205…

Bug fixes:

  • Frozen…
avdi.codes 

New additions to MOOM, May 2018 Edition

Hi there! I've been quietly adding material to the MOOM beta course, preparing it for a “finished product” release. For those of you who aren't following the forums I wanted to give you a quick summary update.

Two new Capacitor Sessions pairing videos added!

While Betsy and I have nearly completed recording these sessions, publishing the videos is trailing behind because of the time taken by post-production. Each pairing session video goes through an editing process where we create session notes, remove interruptions and dead air, speed up slow silent coding sections, and spotlight the live video for discussions. This…

Ruby Weekly 

Ruby’s New Exception Keyword Arguments

#399 — May 17, 2018

Read on the Web

Ruby Weekly

Ruby’s New Exception Keyword Arguments — From the forthcoming Ruby 2.6 preview 2 release, some Kernel methods will support exception: false and exception: true options to override whether they raise exceptions or not.

Square Corner Blog

Rewriting Deprecated APIs with the 'parser' Gem — A look at reading and rewriting Ruby code using an AST and the parser gem to rewrite deprecated API calling code.

Paweł Pacana

A Rock Solid, Modern Web Stack: Rails 5 API + ActiveAdmin + Create React App — A step-by-step tutorial creating and deploying a React client…

Heroku

Drivy Engineering 

Android Makers 2018 Key takeaways

Android Makers is the largest Android event in France, organized by the PAUYG and BeMyApp. This year the event was held in Le Beffroi de Montrouge - what a great place to enjoy a conference. There was much more space than the previous Android Makers event: we were really comfortable, with all we needed to be fully focussed on the conferences.

Below are some key takeaways of these 2 days of great conferences.

Modern Android development

Romain Guy & Chet Haase, Google, Video

They gave us a big overview of the improvements of the last few years to Core Android development, from the view (ConstraintLayout) to the programming language (Kotlin) through the architecture, the tools and more.

Ke…

Drivy Engineering 

Rails 5.2: ActiveStorage highlight

Rails 5.2 was released a few weeks ago and comes with awesome features like the new credentials vault, HTTP/2 early hints, Redis cache store and ActiveStorage, which I’m going to focus on in this blog post. The project was initiated by DHH in mid-2017 and has been merged into Rails core. It’s a built-in way to deal with uploads without extra dependencies like Paperclip, Carrierwave or Shrine.

How does it work?

ActiveStorage comes with a complete DSL which allows you to attach and detach one or multiple files to a model. By default, ActiveStorage isn’t installed in a new rails project, you have to run:

rails active_storage:install

This command simply copies a migration in your projet.…

BigBinary Blog 

Rails 5.2 fixes query caching in MySQL and PostgreSQL adapters

Prior to Rails 5.2, MySQL and PostgreSQL adapters had select_value, select_values & select_rows select_{value,values,rows} methods to avoid instantiation of ActiveRecord::Result. However these methods broke query caching.

Let’s check query caching issue.

>> User.cache do
>>   2.times { User.exists?(1) }
>> end

User Exists (2.1ms)  SELECT  1 AS one FROM "users" WHERE "users"."id" = $1 LIMIT $2  [["id", 1], ["LIMIT", 1]]

User Exists (2ms)  SELECT  1 AS one FROM "users" WHERE "users"."id" = $1 LIMIT $2  [["id", 1], ["LIMIT", 1]]

As we can see, query was not cached and sql was executed second time.

In Rails 5.2, select_{value,values,rows} methods have been removed completely in this PR.

Ruby on Rails and Stuff by Paweł Dąbrowski 

Add beautiful code syntax highlighting to your Ruby on Rails app

The code syntax highlighting feature is a must-have for every developer blog or website where a code snippet can be presented. It’s easy to add it when you are using a blog engine like Jekyll or WordPress but you can also easily add it in your own Rails app. Since […]

The post Add beautiful code syntax highlighting to your Ruby on Rails app appeared first on Ruby on Rails and Stuff by Paweł Dąbrowski.

RubyGuides 

How To Dramatically Improve Your Ruby Code With Fundamental OOP Principles

A very important topic in object-oriented design is cohesion & coupling. Cohesion is about the relationship between all the methods inside a class. Are they using the same set of instance variables & parameters, all working together towards the same goal? Or does every method feel separate from each other? Coupling is how dependent is […]

The post How To Dramatically Improve Your Ruby Code With Fundamental OOP Principles appeared first on RubyGuides. Don't miss your free gift here :)

Engine Yard Blog 

Ruby on Rails vs PHP

There’s more than one way to build a web application. No matter what type of application you are trying to create, your programmers have their preferred approach and their preferred code languages to accomplish the task. In the world of web applications, most program developers have to decide between Ruby on Rails versus PHP.

Passenger - Phusion Blog 

The Big Friendly Errorpage

The Big Friendly Errorpage

One of the most common issues that Passenger users encounter is a so-called application spawning error, a failure to start their application. This is usually caused by some kind of misconfiguration or problem with the system.

In development mode, Passenger automatically shows a (developer-) "friendly error page" which contains a big dump of troubleshooting information. Though valuable, the amount and structure of the information made it difficult for users to immediately see whether it's a problem with Passenger, their application, their configuration, or maybe even with their system.

Thus we embarked on a quest to redesign the error page!

The old (pre 5.1) page

Not so long ago, the…

All Ruby Podcasts by Devchat.tv 

MRS 044: Sam Aaron

Panel: Charles Max Wood

Guest: Sam Aaron

This week on My Ruby Story, Charles talks to Sam Aaron. Sam is a programmer who likes to try to get other programmers involved and programming in creative ways. Currently, he has been making music with programming with Sonic Pi and teaching children how to do so as well. He first really got into programming when he picked up a graphing calculator when he was in school and would program games and pictures on it. They talk about what led him to Ruby and what led him to create Sonic Pi.

In particular, we dive pretty deep on:

Greater Than Code 

080: Crafting A Community with Kris Howard

We have interactive show transcripts! Powered by Gretta.

Episode Sponsored By: 

Support for the Greater Than Code podcast comes from O’Reilly Fluent and Velocity conferences, coming to San Jose, California, June 11-14. Join us for more insights, experts, and peers than ever before. You’ll get hands-on training to help you improve performance, resilience, and user experience. Register with code GTC20 to save up to $519 on your pass. Learn more at oreilly.com/bettertogether.


Panelists:

Jessica Kerr | John K. Sawers

Guest Starring:

Kris Howard: @web_goddess | YOW! Conference

Join Our Slack Channel!
Support us via Patreon!

Show Notes:

02:05 – Knitting and Computing

Software Art Thou: Knit…

BigBinary Blog 

How to mitigate DDoS using Rack::Attack

Recently, we faced a DDoS attack in one of the clients’ projects. There were many requests from different IPs to root and login paths, and we were running thrice the usual number of servers to keep the system alive. We had to throttle requests based on different parameters and the gem Rack::Attack helped us with that.

Rack::Attack is a Rack middleware from Kickstarter. It can be configured to throttle requests based on IP or any other parameter.

To use Rack::Attack, include the gem in Gemfile.

gem "rack-attack"

After bundle install, configure the middleware in config/application.rb:

config.middleware.use Rack::Attack

Now we can create the initializer config/initializers/rack_attack.rb

By…

All Ruby Podcasts by Devchat.tv 

RR 362: Measuring Ruby Performance with Rails and Discourse with Noah Gibbs

Panel:

  • Charles Max Wood
  • David Richards
  • Dave Kimura
  • Catherine Meyers

Special Guests: Noah Gibbs

In this episode of Ruby Rogues, the panelists talk to Noah Gibbs about measuring Ruby performance with Rails and Discourse. Noah wrote a book called Rebuilding Rails and is currently analyzing Ruby performance for AppFolio. They talk about how he puts benchmarks around Discourse, the 2 distinct audiences that come to Rails, and how Rails is constantly improving. They also touch on his life as a programmer leading up to being a Ruby fellow and much more!

In particular, we dive pretty deep on:

Hi, we're Arkency 

Rewriting deprecated APIs with parser gem

In upcoming Rails Event Store release we’re going to deprecate existing reader methods. They’ll be replaced in favor of fluent query interface — popularized by ActiveRecord. In order to make this transition a bit easier, we’ve prepared a script to transform given codebase to utilize new APIs.

Long story short: we had six different query methods that allowed reading streams of events forward or backward, up to certain limit of events or not and finally starting from beginning or given position in a stream. Example:

client.read_events_backward('Order$1', limit: 5, start: :head).each do |event|
  # do something with up-to 5 events from Order$1 stream read backwards
end

We’ve decided to…

All Ruby Podcasts by Devchat.tv 

MRS 043: Noah Gibbs

Panel: Charles Max Wood

Guest: Noah Gibbs

This week on My Ruby Story, Charles talks to Noah Gibbs. Noah works currently at AppFolio as their Ruby Fellow, where he does a lot of measuring and writing about Ruby performance. He also writes a lot for Ruby Weekly about Ruby performance. He first got into programming when was in the third grade and he got to use an Apple II in class. In class, they had to draw on graph paper and then “program” what they drew on their computer, and this fascinated him. They also touch on what led him to Ruby, why he fell in love with it, and what he is most proud of contributing to the Ruby community.

In particular, we dive pretty deep on:

  • Noah intro
  • What…
Hi, we're Arkency 

correlation id and causation id in evented systems

Debugging can be one of the challenges when building asynchronous, evented systems. Why did this happen, what caused all of that?. But there are patterns which might make your life easier. We just need to keep track of what is happening as a result of what.

For that, you can use 2 metadata attributes associated with events you are going to publish.

Let’s hear what Greg Young says about correlation_id and causation_id:

Let’s say every message has 3 ids. 1 is its id. Another is correlation the last it causation. If you are responding to a message, you copy its correlation id as your correlation id, its message id is your causation id. This allows you to see an entire conversation…

Passenger - Phusion Blog 

Passenger 5.3.1: crash + spawn hotfix

Passenger 5.3.1: crash + spawn hotfix

Version 5.3.1 of the Passenger application server for Ruby, Node.js, Meteor and Python has been released. This release contains two hotfixes for regressions that were discovered in 5.3.0 a few days ago.

Besides support for the latest software (Nginx stable, Ubuntu), the 5.3 series of Passenger features per-application logfiles. There has been a lot of work on the internals to enable vastly improved error reporting, but also newly planned features (hint: Support more languages).

Please be aware that you can enjoy enterprise features and sponsor the open source development directly by buying Phusion Passenger Enterprise.

Crash fix: user without shell

For 5.3.0, an internal component of…

Martian Chronicles, Evil Martians’ team blog 

Is React Native podium-ready?

Authors: Valery Bugakov, Front-end Developer at Evil Martians and Nate Gadzhibalaev, Account lead at Evil Martians

How we embraced React Native while helping a growing B2B platform to execute their new product strategy, and why we did not regret it. If you are a SaaS startup founder, a CTO, or a software engineer who considers a switch to a promising mobile framework but wants to filter out the hype—this story about our collaboration with Podium may help you make the right decision.

React Native, a Facebook-backed JavaScript framework for mobile development, is gaining traction among new startups and mature companies alike, but is it a right tool for your job? If you are asking…

EquiValent 

Ruby class methods syntax

In Ruby you are able to write class methods multiple ways.

We will quickly show 4 major ways and explain how they work and when you may want to use one over the other:

option 1 - def self.method_name

class MyModel
  def self.what_is_your_quest
    "To find the Holly Grail"
  end

  def self.what_is_your_favorite_color(knight)
    case knight
    when "Lancelot"
      "blue"
    else
      "blue, ...no red !"
    end
  end

  def hello_world
    "this is an instance method"
  end
end

MyModel.what_is_your_quest
# => "To find the Holly Grail"

MyModel.what_is_your_favorite_color("Lancelot")
# => "blue"

MyModel.new.hello_world
# => "this is an instance method"

option 2 - class << self

Andy Croll 

A job should know whether to run itself

It is a good idea to do as much of the ‘work’ of an application as possible in asynchronous jobs as it means doing less work in each controller action. Rails includes ActiveJob as a way to implement this pattern in your application.

Each ActiveJob comes with a selection of callbacks that are run at different points in a job’s lifecycle.

A list of the available callbacks are in the Active Job Rails Guide.

When a job doesn’t always need to be run, we can use these callbacks to save writing conditional logic in every location in the code where we enqueue the job.

Instead of…

…checking whether a job should be enqueued when you enqueue it…

class SendNotificationJob < ApplicationJob
  def p…
Paweł U. | Ruby on Rails Web Development Consultant Full Stack Blog 

Adding GDPR Compliance to My Rails App and Technical Blog

GDPR EU regulations represented by a hammer

New data privacy GDPR EU regulations are going live in less than two weeks. In this blog post, I will describe actions I took to add GDPR compliance to my Ruby on Rails SAAS app and this blog itself.

Your apps must comply with new regulations even if you are not located in the EU. It is enough that you have European users.

Disclaimer: I am not a lawyer and this article does not constitute legal advice.

What needed GDPR compliance

General Data Protection Regulation focuses on so-called Personally Identifiable Information (“PII”). It is every piece of information which allows you to directly or indirectly determine user’s identity.

After auditing my apps I found out that following…

avdi.codes 

SIGAVDI #33: Things fall apart

Hello friends. It's been a long time. My life has changed, and I've been debating whether to continue these emails at all, or whether to take them in a new direction. As the presence of this mail suggests, I'm leaning towards the latter.

Let me tell you a story.

Once upon a time there was a young programmer. For reasons that are beyond the scope of this story, he had decided to skip the usual aimless and fancy-free period of his 20s, and get straight to the settling-down-with-kids stage of life.

Life was strained and difficult. He longed to break free of the stress of being a sole provider and the monotony of working in a cubicle farm.

Luckily, he was a quick study, and he found people…

Giant Robots Smashing Into Other Giant Robots 

Deprecating Paperclip

In its eleventh year as an open source project, we have decided to halt work on Paperclip. This comes from a combination of already slowed work on the project, a constantly growing list of issues and pull requests that we struggle to keep on top of, and most recently the release of ActiveStorage in Rails 5.2.

Migrating

For moving from Paperclip to ActiveStorage, please see the migration guide. As you migrate and learn lessons, please contribute back to the migration guide.

Deprecation Plan

We have closed issues and pull requests unrelated to our deprecation process.

  1. Merge bug fixes. We do not want to introduce new bugs so we are being careful to merge very few…
Blog - Clean Code For Rubyists 

Variable Names: Avoiding Conjunctions

Using conjunctions in your variable names shows we are attempting to store too much data in a single variable. The English language defines conjunction as a word (e.g. words like and, or, but) that connects two clauses into the single phrase. If you spot a conjunction in a variable name, it should raise a red flag that something is wrong. Let's look at an example where a variable uses a conjunction.


# Bad example
score_and_player_count = { score: 100, player_count: 2 }

Here we have a variable that contains a hash with two data points: current score and player count. While the name score_and_player_count is descriptive, the word "and" shows that the variable is holding data for two different…

Notes to self 

InvoicePrinter 1.2

A new version of my Ruby gem for generating PDF invoices InvoicePrinter is out! This time bringing in a bundled server that can be handy for applications not running on Ruby.

Not every app out there is a Ruby application and I wanted for people on different stacks to be able to benefit from super simple PDF invoicing that InvoicePrinter enable. This is the reason why I implemented JSON support and a command line in version 1.1 and why am I adding the server in 1.2. You can run it as a standalone server or mount it in any Rack application and use its JSON API to generate the documents.

Here is the documentation.

Read more about how to use this feature in my previous posts:

Alfredo Motta 

An Introduction to Event Sourcing for Rubyists

Video here: https://skillsmatter.com/skillscasts/11903-an-introduction-to-event-sourcing Slides here: https://speakerdeck.com/mottalrd/an-introduction-to-event-sourcing-for-rubyists Code here: https://gist.github.com/mottalrd/52a99a0a67275013df5a66281a4a1b11 Event sourcing is a design pattern to build applications that are domain centric and easy to extend. The pattern is based on the usage of a persistent event log which substitutes the more classical relational database model for Rails applications. Last week I gave this presentation […]
Riding Rails 

Google Cloud Storage streaming downloads, performance improvements and more!

Hello everyone! This is Roque bringing you the latest news from the Rails world. I will cover the highlights from the last two weeks. Let’s get started!

This Week’s Contributors

39 people contributed to Rails in the last two weeks, including 9 for the first time! A big thank you to all of you!

If you’d like to see yourself on that board, why not check out the list of open issues, or get involved in the core discussion list.

Support streaming downloads from Google Cloud Storage

Active Storage now supports streaming downloads from Google Cloud Storage. You will need version 1.11 or greater of the gem google-cloud-storage.

Add option identify to ActiveStorage::Blob

This allows control…

Julia Evans 

Batch editing files with ed

The other day at work I needed to edit 200 files at once. I wanted to do something pretty simple: basically, I had files that looked like this:

foo:
  - bar
  - baz
  - bananas

and I wanted to insert an extra line after the baz line that said elephant

foo:
  - bar
  - baz
  - elephant
  - bananas

I had one extra weird requirement which was that some of the lines were indented with 2 spaces, and some with 4 spaces. The - elephant line needed to have the same indentation as the previous line.

I didn’t feel like writing a program to do this (perl would be perfect, but I don’t really remember perl at all), so I wanted to use a command line tool! A vim macro could do it, but how do you…

Schneems - Programming Practices, Performance, and Pedantry 

Rails 5.2 Active Storage: Previews, Poppler, and Solving Licensing Pitfalls

Rails 5.2 was just released last month with a major new feature: Active Storage. Active Storage provides file uploads and attachments for Active Record models with a variety of backing services (like AWS S3). While libraries like Paperclip exist to do similar work, this is the first time that such a feature has been shipped with Rails. At Heroku, we consider cloud storage a best practice, so we’ve ensured that it works on our platform. In this post, we’ll share how we prepared for the release of Rails 5.2, and how you can deploy an app today using the new Active Storage functionality.

The Bike Shed 

153: 🎶 I Would Lose 3,000 Crates, and I Would Lose 12,000 More 🎶

Is the bug in Postgres? Sean takes over operations of crates.io and keeps himself very busy. We also wrap up our experience at RailsConf.

See open positions at thoughtbot!

Become a Sponsor of The Bike Shed!

Awesome Ruby Newsletter 

Issue 104 - Exploding Rails - Ryan Bigg [VIDEO]

Ruby Weekly 

New Constant Naming Rules Coming to Ruby 2.6+

#398 — May 10, 2018

Read on the Web

Ruby Weekly

New Constant Naming Rules Coming to Ruby 2.6+ — Historically, you’ve needed to use an upper case ASCII capital letter as the first character of constant names (including classes and modules). In Ruby 2.6, you get 1000+ options thanks to this patch. (Note: It’s not supported in Ruby 2.6 preview 1, but should appear in the next preview.)

Shannon Skipper

Caching in Rails 5.2 — A preview chapter from the author’s new book that runs through the various ways to cache in Rails, including a reach back to page caching.

Stefan Wintermeyer

Manifold Is the…

Posts 

Privacy Enhancements

The European Union’s General Data Protection Regulation (GDPR) will be enforced from May 25th forward. In the light of this I adjusted some things on *.gettalong.org websites.

No External Resources

I have never used many external resources but now even those few are gone. This means:

  • Fonts that were previously hosted by Google Fonts are now locally hosted. So Google won’t get any IP adresses or other data.

  • All Javascript, CSS and images are also locally hosted. This was already the case with the exception of a few images.

The disadvantage of this approach is that browser caching won’t be as effective. However, this is offset by using longer caching times due to…

RubyGuides 

How to Use The Strategy Design Pattern in Ruby

Let’s talk about the strategy design pattern! This design pattern helps you change the main algorithm inside a method. You do this by passing in a class that implements this algorithm, instead of hardcoding it into the class. And when I say algorithm I don’t mean a fancy computer science algorithm, but any code that […]

The post How to Use The Strategy Design Pattern in Ruby appeared first on RubyGuides. Don't miss your free gift here :)

Passenger - Phusion Blog 

Passenger 5.3.0: Ubuntu 18.04, Nginx 1.14, per-app logging, spawn error page

Passenger 5.3.0: Ubuntu 18.04, Nginx 1.14, per-app logging, spawn error page

Version 5.3.0 of the Passenger application server for Ruby, Node.js, Meteor and Python has been released. There are no breaking changes; we've increased the minor version due to a few big additions.

In the 5.2 series, we did a major internal overhaul of configuration management. In 5.3 we've done a big overhaul of the error reporting. Packages for Ubuntu "Bionic" were added, as well as support for the latest stable Nginx (1.14.0). There's also a new option for Passenger Enterprise users: per-application logfiles.

Please be aware that you can enjoy enterprise features and sponsor the open source development directly by buying Phusion Passenger Enterprise.

Ubuntu 18.04 "Bionic" packages

We've…

Search Results for “ruby” – via @codeship 

Rails Frontend Testing with JavaScript Insights

Reading Time: 8 minutes

One of the newer things that Rails 5+ provides is system tests. This gives us a full frontend testing experience with Capybara, which runs each of our tests through a real browser window to perfectly provide what a normal web user would experience. Having this baked in to Rails makes for an elegant way to get started and hit the ground running.

What’s more, Rails will generate our standard CRUD system tests per resource when we use the Rails generator to generate it with the models name and attribute fields. This makes swapping in frontend frameworks a much more seamless experience.

In this post, we’ll tackle what changes to the code are required to get our previous…

Test Double | Our Thinking 

A better technical interview (2018)

Our interview processes tend to focus solely on one outcome: a successful hire. But what about all of the other people who go through our interview process? If we aren't thinking about them and empathizing with their situations, we are prone to giving out lots of bad experiences. Let's focus on every candidate who goes through our interview process and create great outcomes for everyone.

The inspiration for this talk came from Sam Jones' excellent talk of the same name.

The video above was presented at Code PaLOUsa 2018 on March 30, 2018.

Relevant links

Greater Than Code 

079: Respect As Currency with Richard Schneeman

We have interactive show transcripts! Powered by Gretta.

Episode Sponsored By: 

Support for the Greater Than Code podcast comes from O’Reilly Fluent and Velocity conferences, coming to San Jose, California, June 11-14. Join us for more insights, experts, and peers than ever before. You’ll get hands-on training to help you improve performance, resilience, and user experience. Register with code GTC20 to save up to $519 on your pass. Learn more at oreilly.com/bettertogether.


Panelists:

Rein Henrichs | Janelle Klein | John K. Sawers | Jamey Hampton

Guest Starring:

Richard Schneeman: @schneems | schneems.com | CodeTriage | Keep Ruby Weird  

Join Our Slack Channel!
Support us via Patreon!

Sho…

All Ruby Podcasts by Devchat.tv 

RR 361: Ruby Elapsed Time with Luca Guidi

Panel:

  • Charles Max Wood
  • David Richards
  • Dave Kimura

Special Guests: Luca Guidi

In this episode of Ruby Rogues, the panelists talk to Luca Guidi about Ruby elapsed time. Luca works remotely for DNSimple and is most well known in the Ruby community for his open source projects, such as Hanami. They talk about NTP, time drifts, and the pros and cons to using a monoatomic clock. They also touch on the importance of being exposed to different languages in order to be a well-rounded developer.

In particular, we dive pretty deep on:

  • Luca intro
  • His elapsed time blog post
  • Why he wrote the blog post
  • What is NTP?
  • NTP = Network Time Protocol
  • The importance of keeping your computer time…
Engine Yard Blog 

What to Look for When Considering Application Hosting

Cloud computing has made hosting business-critical applications easier and less expensive. Application hosting makes deploying the resources you need easier and faster—without the overhead of additional hardware, software, and personnel. Once you decide to host your business applications, the question becomes, what criteria do you need to consider when looking for an application hosting provider?

GoRails Screencasts 

How to Migrate from Paperclip to Rails ActiveStorage

Now that the Paperclip gem has been deprecated, it's recommended that you migrate your apps to ActiveStorage
BigBinary Blog 

Increase reliability of background job processing using super_fetch of Sidekiq Pro

Sidekiq is a background job processing library for Ruby. Sidekiq offers three versions: OSS, Pro and Enterprise.

OSS is free and open source and has basic features. Pro and Enterprise versions are closed source and paid, thus comes with more advanced features. To compare the list of features offered by each of these versions, please visit Sidekiq website.

Sidekiq Pro 3.4.0 introduced super_fetch strategy to reliably fetch jobs from the queue in Redis.

In this post, we will discuss the benefits of using super_fetch strategy.

Problem

Open source version of Sidekiq comes with basic_fetch strategy. Let’s see an example to understand how it works.

Let’s add Sidekiq to our Gemfile and run b…

BigBinary Blog 

Rails 5.2 sets Ruby version in Gemfile and adds .ruby-version file by default

This blog is part of our Rails 5.2 series.

For Ruby developers, it’s common to switch between multiple Ruby versions for multiple projects as per the needs of the project. Sometimes, the process of going back and forth with multiple Ruby versions could be frustrating for the developer. To avoid this we add .ruby-version files to our projects so that version manager tools such as rvm, rbenv etc. can easily determine which Ruby version should be used for that particular project.

One other case that Rails developers have to take care of is ensuring that the Ruby version used to run Rails by the deployment tools is the one that is desired. In order to ensure that we add ruby version to Gemfile

Idiosyncratic Ruby 

What the Regex?

Regexes, the go-to-mechanism for string matching, must not only be written, but also need to be applied. This episode acts as a reference with some style advice for working with regular expressions in Ruby. If you are looking for resources on writing the actual regexes, take a look at the link collection at the bottom.

What do you Want to Achieve?

1 - Task: Check if Regex Matches

1a) match?

This is the preferred way to check for a match since…

Appfolio Engineering 

To Sleep, Perchance to Dream: Rails Ruby Bench and Sleepy GC

Hey, folks! It's been a few weeks since my last post about Rails Ruby Bench, so let's talk about some things you don't see it do, but it does behind the scenes! We'll also talk about an interesting new performance change that may be coming to Ruby 2.6.

That change is Eric Wong's Sleepy GC bug report and patch. With SleepyGC, Ruby will garbage collect with spare (idle) cycles. If you're just here for the latest Ruby development news, skip this post and click the bug report. Original sources are always more compete than commentary, right?

(Want to skip the narrative and go straight to the upshot? Skip to the bottom -- look for "So Did It Work?")

A Little Story

A few days ago, the excellent Sam…

Ruby Together News 

April 2018 Monthly Update

Hello! Welcome to the monthly update. During April, we paid for 133.5 hours of developer work, supported by Stripe, Coinbase, reinteractive, Airbnb, and many others.

ruby together news

It's our birthday! 🎉🎂 As of this update, Ruby Together is officially 3 years old. Thanks for all of your help and support along the way.

In April, Ruby Together was supported by 80 different companies, including Sapphire member Stripe. 6 companies joined as new members, including Piece of Code and Coinbase.

On top of those companies, 6 new developers signed up as members or friends of Ruby Together, including Tom Johnson, Pat Allan, Jameson Hampton, and Jeremy Flores. In total, we were supported by 92…

Paweł U. | Ruby on Rails Web Development Consultant Full Stack Blog 

Screencast - My Ruby on Rails Workflow, Productivity Tips and Tools

In this screencast, I implement an improvement to subscription payments handling in my side project Abot. I show my typical Ruby on Rails workflow, productivity tools, and techniques.

[Duration] 25m


Links and Resources

Abot - Anonymous Feedback, Polls and Surveys for Slack Teams

Be Focused Pro - Focus Timer - Pomodoro timer

Magnet App - MacOS windows management

block.sh - script for blocking distracting websites

aliases.sh - my shell aliases

Vintage Mode - Vim mode in Sublime Text

Oh My Zsh - better bash

Z plugin - quick folders navigation

Zeus gem - Rails app preloader

Smart Init gem - unified service objects API

P.S. This is my first try at screencasting. Feedback on…

Drifting Ruby Screencasts 

Ruby on Rails Development with Microsoft Windows 10

Developing a Ruby on Rails application on Windows can be difficult, but doesn't have to be with Bash on Windows. Learn how to use Bash to install the Ruby interpreter.
Notes to self 

Making PDF invoices from JavaScript and Node.js

This is an example of how to use the new InvoicePrinter Server that I announced recently to start invoicing from your Node.js projects.

Before we start writing any JavaScript let’s install invoice_printer gem and start the server that will generate the final PDF for us:

$ gem install invoice_printer --version 1.2.0.alpha1
$ invoice_printer_server

Once we have that in place we can start out with specifying the actual invoice object (in form of JSON):

const invoice = {
  "number": "NO. 198900000001",
  "provider_name": "John White",
  "provider_tax_id": "",
  "provider_tax_id2": "",
  "provider_street": "5th Avenue",
  "provider_street_number": "1",
  "provider_postcode": "747 05",
 …
Ruby on Rails and Stuff by Paweł Dąbrowski 

Create a beautiful chart with just one line. For those who loves Ruby but does not like JavaScript

It is nice to have charts in the Ruby on Rails app but it’s sometimes difficult to prepare proper data and then display it using JavaScript in the view. Let me introduce you the solution: Chartkick and Chartable gems. Chartkick is a gem for displaying beautiful and useful charts just […]

The post Create a beautiful chart with just one line. For those who loves Ruby but does not like JavaScript appeared first on Ruby on Rails and Stuff by Paweł Dąbrowski.

The Bike Shed 

152: I Look For Stories (Nickolas Means)

We catch up with Nick Means at RailsConf and discuss storytelling, "human error", advice for job seekers, and the idea of licensing software developers.

Awesome Ruby Newsletter 

Issue 103 - Ruby's Rack Push: Decoupling the real-time web application from the web

Ruby Weekly 

Ruby on WebAssembly, and an update on Ruby 3 concurrency

#397 — May 3, 2018

Read on the Web

Ruby Weekly

Ruby on WebAssembly — Until recently, we’ve had to compile other languages to JavaScript to make them work in the browser, but WebAssembly brings a language-independent executable format to browsers. Learn how LLVM helped give birth to WebAssembly, what WebAssembly means, how we can use Ruby to target it, and the gem that makes it all a bit easier to play with.

Tom Black

Ruby’s Rack Push: Decoupling The Real-Time Web Application from the Web“Something exciting is coming.” A new pull request to Rack contains an approach to WebSockets and SSE where they’re…

Bo Wild

BigBinary Blog 

Deploying Docker Registry on Kubernetes using S3 Storage

In today’s era of containerization, no matter what container we are using we need an image to run the container. Docker images are stored on container registries like Docker hub(cloud), Google Container Registry(GCR), AWS ECR, quay.io etc.

We can also self-host docker registry on any docker platform. In this blog post, we will see how to deploy docker registry on kubernetes using storage driver S3.

Pre-requisite:

As per docker registry documentation, We can simply start the registry using docker image registry.

Basic parameters when…

Notes to self 

Fixing ‘failed to find type parsed [keyword] for [name]’ error for Elasticsearch and Searchkick

Just a quick remainder about what slowed me down today.

If you are getting the following error:

Searchkick::ImportError ({"type"=>"mapper_parsing_exception", "reason"=>"failed to find type parsed [keyword] for [name]"} on item with id '010b5aea-7ff0-43ef-a488-7dd8938d325d')

Chances are that you are running old version of Elasticsearch!

GoRails Screencasts 

Vue.js Slots with Tailwind CSS and Rails

Learn how to use Vue.js slots to make even more reusable components. In this episode, we build a dropdown menu for Tailwind CSS apps using Vue.js slots.
Idiosyncratic Ruby 

idiosyncratic_eval

When you get farther upwards the steep hill that is Ruby mastery, you will come across some powerful, yet slightly evil methods: instance_eval and class_eval¹. They allow you to execute code and define methods tied to a specific class, at the same time giving you access to outer scope variables through the Ruby block syntax. Their exact behavior varies, depending on the context they are used in. So what is the difference between all the evals?

¹ Also aliased as module_eval

Eval / Method Definition Comparison

In the following tables, you will find all combinations of defining a method and executing it in a different class context:

Class Scope

Definition Method No
Junior Developer 

Building ruby with jemalloc

There's been a lot of discussion recently about running Ruby with jemalloc. Sounds like some good memory savings to be had basically for free. I ran into an issue initially when compiling Ruby with the --with-jemalloc option. On Mac OSX Sierra, compiling Ruby 2.4.2 from source and using jemalloc 5.0.1, I got this linker error:

... lots of build process output ....
linking miniruby
Undefined symbols for architecture x86_64:
  "_je_calloc", referenced from:
      _rb_objspace_alloc in gc.o
... and much more ....

One fix is a small change to the autoconf script, configure.in. Ruby 2.4.1's configure.in script had this but 2.4.2 didn't:

4211a4212,4214
> AS_CASE(["$with_jemalloc: $LIBS "],…
All Ruby Podcasts by Devchat.tv 

MRS 042: Josh Greenwood

Panel: Charles Max Wood

 

Guest: Josh Greenwood

 

This week on My Ruby Story, Charles talks to Josh Greenwood. Josh was recently on Ruby Rogues and he works for a consulting company called Test Double, where he works remotely with clients all across the country. He first got into programming because he was always around computers because of his Dad, and he always loved playing video games. His first real exposure to programming was when he found an HTML book on his Dad’s bookshelf and he used it to build a website. They talk about what led him to Ruby, what made him fall in love with programming, and much more!

In particular, we dive pretty deep on: 

Test Double | Our Thinking 

JavaScript Is Too Convenient

Which conveniences do we take advantage of everyday? Which are taking advantage of us?

Objects and functions sure are convenient, so convenient that we do many shortsighted things just because they're easy.

In-line objects and anonymous functions create a poor signal to noise ratio, making it hard to understand your code.

Learn ways to give confusing things names, focus on what's important, and write nicer code.

The video above was presented at SCNA - New York City on April 19, 2018.

Relevant links

Paweł U. | Ruby on Rails Web Development Consultant Full Stack Blog 

Quick Tip - Increase Your Productivity with Rails Console Aliases

Keyboard represents IRB console aliases

Recently I’ve started using a productivity technique which saves me a lot of unnecessary typing when working with Rails apps. In might seem trivial but I still wanted to share it because it makes my everyday work easier.

Aliases FTW

I am a huge fan of using aliases. Whenever I find myself typing the same characters string more than few times I make an alias out of it. Until recently I was only aliasyfying my bash commands. I even created a tool which helps me track bash commands which are good candidates for an alias.

Currently, I have over 100 bash aliases on my local machine:

aliases | wc -l => 126

Recently I found out that I can also aliasify my workflow in a Rails console. Read…

Greater Than Code 

078: Caring About Healthcare with Kenzi Connor and Laurie Voss

We have interactive show transcripts! Powered by Gretta.

Episode Sponsored By:

Support for the Greater Than Code podcast comes from O’Reilly Fluent and Velocity conferences, coming to San Jose, California, June 11-14. From ops to apps, Velocity + Fluent tears down silos, enabling and fostering the kind of cross-department collaboration essential to driving innovation and speeding product delivery. Early Price ends this Friday, May 4th–save up to $599 using code GTC20. Learn more at oreilly.com/bettertogether.


Panelists:

Coraline Ada Ehmke | Jamey Hampton | John K. Sawyers | Jessica Kerr

Guest Starring:

Laurie Voss: npm

Kenzi Connor: Cloud City Development

Join Our Slack Channel!
Support…

Show…

All Ruby Podcasts by Devchat.tv 

RR 360: Cucumber is 10 years old with Aslak Hellesøy

Panel:

  • Charles Max Wood
  • David Richards

Special Guests: Aslak Hellesøy

In this episode of Ruby Rogues, the panelists talk to Aslak Hellesøy about Cucumber. Aslak has been a software developer since around 1997 and has been in the Ruby community since around 2003. He created Cucumber in 2008, which has been his hobby on the side since its creation. They talk about the difference between TDD and BDD, what Cucumber is, and how it works. They also stress the importance of having conversations in order to facilitate collaboration and trust.

In particular, we dive pretty deep on:

Jekyll • Simple, blog-aware, static sites 

Jekyll 3.8.1 Released

Happy May Day :tada:

The Jekyll team is happy to announce the release of v3.8.1, which fixes a couple of bugs that were introduced two weeks ago in v3.8.0. If you have experienced trouble regarding post excerpts or non-published posts, this release should be the remedy. Thanks to @Chaosed0 and @domLocalHeroes for originally reporting these issues, and to @ashmaroli for fixing them so quickly.

As a reminder, we have started work on Jekyll 4.0. If there are any features that you would love to see added to Jekyll, or any pain points you would like to see removed, please do add your ideas to the Jekyll 4.0 idea list.

Brandon Hilkert 

Reducing Sidekiq Memory Usage with Jemalloc

Ruby and Rails don’t have a reputation of being memory-friendly. This comes with a trade-off of being a higher level language that tends to be more developer-friendly. For me, it works. I’m content knowing I might have to pay more to scale a large application knowing I can write it in a language I enjoy.

Turns out…Ruby’s not the memory hog I’d previously thought. After some research and experimentation, I’ve found jemalloc to offer significant memory savings while at least preserving performance, if not improving it as well.

The Problem

At Bark, we poll external APIs for millions of monitored social media, text, and emails. This is all done through Sidekiq background jobs. Even though…

Riding Rails 

Arel merged to Active Record, faster image processing and more

Hello 🌧 from London! This is Kir, bringing you the latest Rails updates in this episode of the newsletter.

This Week’s Contributors

28 people contributed to Rails in the last week, including 3 for the first time! A big thank you to all of you!

If you’d like to see yourself on that board, why not check out the list of open issues, or get involved in the core discussion list.

Use ImageProcessing gem for Active Storage variants

ImageProcessing gem provides a wrapper around MiniMagic and ruby-vips, allowing you to change backends on the fly and benefit from libvips being up to 10x faster than ImageMagick.

Update ‘rails_welcome.png’ to reflect a more diverse population

The Getting Started…

example.com 

Minitest 6: Test Feistier!

I’ve released my slides for my Rails Conf talk titled Minitest 6: Test Feistier!.

TL;DR: usability improvements, (more) parallelization and distribution are coming, but how much is still up for grabs and I’d love to talk about it and/or get help with it.

I’d love for parallel testing to become the new default, requiring opt-out rather than opt-in.

I would love to see how my tests break across the board when this is turned on. Hopefully, not much at all, and when they do it should be because of legitimate problems in my design that break thread-safety and I’m happy to find and fix those.

I’d love to see test distribution become a standard feature. Making multi-process and multi-machine…

Scout ~ The Blog 

Finding and fixing N+1 queries in Django apps

The Django ORM makes it easy to fetch data, but there's a downside: it's easy to write inefficient queries as the number of records in your database grows.

One area where the ease of writing queries can bite is you is with N+1 queries. Expensive N+1 queries go undiscovered in small development databases. Finding expensive N+1 queries is an area where Scout is particulary helpful.

Lets say you deploy a new Django view that renders a list of invoices and their associated retail store:

With a bare-bones development database, this performs just fine. However, when you deploy to production, performance will suffer significantly if a customer has many invoices.

When you add Scout to your…

RubyGuides 

How To Use The Decorator Pattern in Ruby

The decorator design pattern… What is it, and how can you use this pattern in your Ruby projects? The decorator design pattern helps you enhance an object by adding new capabilities to it without having to change the class. Let’s have a look at an example. Logging & Performance In this example we are making […]

The post How To Use The Decorator Pattern in Ruby appeared first on RubyGuides. Don't miss your free gift here :)

Appfolio Engineering 

Ruby and Haskell: Culture is What You Don't Say

I'm working through a Haskell book with some friends. Learning something new is always good! But it's also because I write and teach Ruby. Learning from other communities helps me notice the cultural differences between, say, Haskell and Ruby.

I'm working with the excellent book "Haskell Programming from First Principles." It's far and away the best Haskell instruction I've found so far. It's easy to look at weirdness in bad instruction and say, "oh, this just isn't very good." But when you see things that seem weird in a first-class book like this, you're usually looking at a cultural difference.

Am I trashing Haskell? Or Haskell culture? Oh, heck no. I am really glad there are purists out…

Schneems - Programming Practices, Performance, and Pedantry 

git push baby products

When it comes to life events, there’s none that require quite as much “gear” as having a new baby. I recently had my second kid and it’s given me some time to think about the products that truly bring me joy versus those that are merely necessary. There’s plenty of baby product recommendation lists out there, this one is mine.

Schneems - Programming Practices, Performance, and Pedantry 

How to Implement a Ruby Hash like Grammar in Parslet

Before you can understand how to build a parser using parslet, you need to understand why you might want to. In my case I have a library called rundoc it allows anyone to write documentation that can be “run”. For example, someone might write docs that had this:

Ruby Inside - Medium 

Caching in Ruby on Rails 5.2

This Medium post is a copy of Chapter 14 about caching from my “Learn Rails 5.2” book (Amazon Link, Apress Link) which was published in April 2018 by Apress. Please contact me in case you need consulting or training for Rails, Phoenix or WebPerformance.

Homepage: https://www.wintermeyer-consulting.de
Email:
sw@wintermeyer-consulting.de
Twitter:
@wintermeyer

Abstract

With the caching of web applications, most people tend to wait to implement it until they encounter performance problems. First the admin usually looks at the database and adds an index here and there. If that does not help, the admin then takes a look at the views and adds fragment caching. But this is not the best approach for…

AkitaOnRails.com 

Running Arch Linux over Windows 10!

Ok, anyone that has been reading my blog for the past year or two knows how I enjoy Arch Linux (in particular Manjaro Gnome).

I am also still very much intrigued by the idea of Windows Subsystem for Linux (or WSL) which properly debuted in the Windows 10 Anniversary Edition back in mid-2016.

It's been almost 2 years and we're expecting some significant updates to WSL compatibility and performance for the next Spring Creators Update (or version 1803) scheduled to arrive on April 30, 2018. This brings it closer to make WSL actually usable for professional programmers. Just to give you an idea, right now you will have orders of magnitude better performance if you run your favorite Linux…

Andy Croll 

Use Hash#fetch when using Rails params in controllers

In a URL, we often need to access parameters that aren’t part of the regular Rails routes. For example, the query parameter in /search?q=term.

The parameters for a Rails action are stored in an ActionController::Parameters object which behaves quite a bit like a standard Ruby hash.

A Ruby hash is typically accessed using square brackets, like hash[key], but you can also use the method fetch, like hash.fetch(key).

Instead of…

…accessing required parameters from the params hash using the typical #[] method…

class ThingController < ApplicationController
  # ... actions

  private

   def an_important_param
     params[:important_and_required]
   end
end

Use…

…the #fetch method to raise…

AkitaOnRails.com 

[SmallTips] Running GitLab CI Runner Locally

If there is one thing you should always do is to maintain your test suite. Every bug you fix, every new feature, you should add new tests.

I have been working very hard in past few weeks, quite literally coding non-stop, 7 days a week. Remember that "stop complaining you don't have time, what do you do from midnight to 6 AM?" thing? Yeah, won't apply to me.

And it's exactly when you're sleep deprived, exhausted when you start to add mistakes. Even though your code runs, locally, you will shoot yourself in the foot in one of those 3 AM coding spree sessions.

The test suite was really my sidekick, co-pilot, bringing me back to my senses whenever the night got too dark.

I maintain my own…

Julia Evans 

How to get a core dump for a segfault on Linux

This week at work I spent all week trying to debug a segfault. I’d never done this before, and some of the basic things involved (get a core dump! find the line number that segfaulted!) took me a long time to figure out. So here’s a blog post explaining how to do those things!

At the end of this blog post, you should know how to go from “oh no my program is segfaulting and I have no idea what is happening” to “well I know what its stack / line number was when it segfaulted at at least!“.

what’s a segfault?

A “segmentation fault” is when your program tries to access memory that it’s not allowed to access, or tries to . This can be caused by:

  • trying to dereference a null pointer…
Karol Galanciak - Ruby on Rails and Ember.js consultant 

Advanced Ember Data Customization - Different Model Types in Ember App and API For The Same Resource

A great advantage of using Ember Data with JSONAPI-compliant adapters/serializers is that there is almost nothing extra needed to work with the data layer – just create the models with names matching the types of the resources returned by the API and you are good to go! However, sometimes you may need to customize the naming which means that the names of the models in the Ember application will be different than the ones expected by the API and their corresponding types. What are the steps required to make it work in Ember Data?

Anatomy Of The Problem

Imagine that the API you work with has two resources: User and Picture and that a User can have many Pictures. However, in the Ember…

Valentino Gagliardi 

How To Use Async Await in React (componentDidMount Async)

How to use Async Await in React?

How To Use Async Await in React

You want to use Async Await in React the same as you do in Node.JS?

create-react-app supports async/await out of the box.

But if you work with your own webpack boilerplate you may hit regeneratorRuntime is not defined.

If you’re hitting that error and you want to use Async Await in React, look no further.

In this post we’ll see how to:

  • fix regeneratorRuntime is not defined
  • use async/await in React with Fetch
  • handle errors with Fetch and async/await

Ready?

How To Use Async Await in React: what is async/await?

Let’s introduce a bit of async/await first.

async/await in Javascript is nothing more than syntactic sugar over Promises.

Why so? Are Javascript…

Ruby – Sihui Huang 

Moving Millions of Dollars with Ruby While Still Able to Sleep at Night

Notes for my talk in Ruby X Elixir Conf Taiwan 2018. (Click here for the video.)

Welcome to this talk: Moving Millions of Dollars Daily with Ruby While Still Able to Sleep at Night.

Before we start, I have a secret to share.

In my programming career,

I have not only written code

but also bugs

lots of bugs.

more than three bugs

more than six bugs

probably as many bugs as this slides can fit

I tried very hard to write bug-free code.

But sometimes there were still bugs.

When my bug was found

I would be like “Ouch! that’s not fun.”

Bugs might or might not have customer impacts. Most of the time, I would be able to fix them quickly and life would be fine again.

But then something changed …

The Bike Shed 

151: Scheming About Schema

Derek & Sean discuss their final preparations for RailsConf, the role of Diesel's schema.rs is in comparison to schema.rb in Rails, and how Derek took down production.

All Ruby Podcasts by Devchat.tv 

MRS 041: Marla Brizel

Panel: Charles Max Wood

Guest: Marla Brizel

This week on My Ruby Story, Charles talks to Marla Brizel. Marla works at Test Double and has been programming full time for the past four years. She first got into programming when she got a job at a startup where they helped her learn how to program for herself and she fell in love with it. They talk about her background as a project manager and the importance of empathy for the user. They then touch on how she got into Ruby and things that she is particularly proud of contributing to the Ruby community.

In particular, we dive pretty deep on:

  • Marla intro
  • How did you first get into programming?
  • Has been working in tech for the past decade
Awesome Ruby Newsletter 

Issue 102 - Why I am declining funding from ruby together | Sam Phippen

Anthony Super 

Dynamic Syntax Highlighting with React.js

Let’s say you’re building a modern web app. You’re using react, you’re set up with webpack code splitting, you render stuff on the server-side, everything is awesome. Even better, your dependencies are really lean-and-mean: you fetch stuff as you go, so the initial bundle is very small!

You might run into a problem, though, if you need to render user-generated Markdown. You’re already using the excellent react-markdown library, so that’s all working fine, but the recommended way to do syntax highlighting has the rather large problem that you need to manually require the languages you want to use. Worse, they’re all bundled together.

You don’t want this. You want to be able to deliver no…

Test Double | Our Thinking 

Running a business, demystified

The video above was recorded at RailsConf 2018 in Pittsburgh, Pennsylvania. It attempts to answer 12 questions we received from the development community about starting and scaling your own business.

We're the first to admit that we don't know everything about creating and running your own company. It's true, we've managed to keep the (remote) lights on at Test Double for over six years, but we attribute most of what we've learned to others who have helped us along the way. We've received phenomenal mentorship from business leaders we deeply respect. We've read—well, Todd has read—lots of books on sales and management. And our roles as consultants have given us front row seats to a lot of…

Ruby Weekly 

Can Pattern Matching Become Native to Ruby?

#396 — April 26, 2018

Read on the Web

Ruby Weekly

Top 10 Errors From 1000+ Rails Projects (and How to Avoid Them) — Analysis of the ten most common errors from over 1000 Rails projects monitored by Rollbar, along with advice on avoiding such errors yourself.

Phil Nash

Bringing Proper Pattern Matching to Ruby — A presentation at RubyKaigi proposed a way to add pattern matching to Ruby but how could (and should) it be implemented?

Victor Shepelev, Brandon Weaver, et al.

Slow CI Build? Make It Run in 2 Minutes or Less — Semaphore Boosters automatically parallelize large Ruby test suites with…

BigBinary Blog 

Ruby 2.6 added option to raise exception in Kernel#system

This blog is part of our Ruby 2.6 series. Ruby 2.6.0-preview1 was recently released.

We write scripts to automate setup and deployment of Rails applications. In those scripts, at many places, we need to run system commands like bundle install, rake db:create, rake db:migrate and many more.

Let’s suppose we need to run migrations using rake db:migrate in a rails project setup script. We can use Kernel#system method.

irb> system('rake db:migrate')

Ruby 2.5.0

Executing system returns true or false. Another feature of system is that it eats up the exceptions.

Let’s suppose our migrations can run successfully. In this case system command for running migrations will return true.

irb> system
Ruby Together News 

April 22 Board Meeting Results

april 22 board meeting results

Attendees and agenda

The full board was present, including André Arko, Coraline Ada Ehmke, Valerie Woolard Srinivasen, Allison Sheren McMillan, Courteney Ervin, and Adarsh Pandit. Topics included increasing communication with the community, increasing transparency about how projects are funded, and the board's position on funded project governance.

Decisions

To increase communication and transparency about board conversations and decisions, we have created a GitHub repository for the Ruby Together Board of Directors. The repo will include planned agendas for future board meetings, summaries of meetings after they happen, and instructions on how to provide…

Search Results for “ruby” – via @codeship 

Gaining Deeper Insights with Data Science

Reading Time: 5 minutes

If you’ve seen any tech job listings within the past year or so, odds are you’ve seen a description that contains the words data science or data scientist. Data science isn’t as much of a buzzword these days as it is a source of confusion. What exactly does a data scientist do? Do they wear lab coats and work under fluorescent lights all day? The answer is probably different than our imaginations would lead us to believe.

Data science, simply put, is the discipline of taking large amounts of data and deriving useful patterns and conclusions from it. I want to lay out some practical ways for us to not only understand the value of data science, but apply it practically…

Mike Perham 

Taming Rails memory bloat

MRI, the standard Ruby interpreter, has a serious problem with memory bloat in large Rails apps. It's quite common for me to see Sidekiq processes which are 1-2GB in RSS or even larger! It turns out that a large part of this memory usage is due to memory fragmentation: MRI uses the OS's memory allocator by default (on Linux, almost always GNU glibc), which seems to work poorly with Ruby's memory allocation patterns.

Nate Berkopec went into great detail about Ruby memory bloat. His blog post is a much deeper dive.

One important note: this behavior is specific to GNU glibc on Linux. OSX and BSD appear to have better quality allocators, not as prone to fragmentation.

Reducing Arenas

The…

Greater Than Code 

077: Creating Space to Shine with Anjuan Simmons

Episode Sponsored By:

Support for the Greater Than Code podcast comes from O’Reilly Fluent and Velocity conferences. Taking place in San Jose, California, June 11-14, it’s the best place to get the latest in software development, performance, operations, resilience, and so much more. Early Price ends next Friday, May 4th. Register with code GTC20 to save up to $599 on your pass! Learn more at http://oreil.ly/2o07Ufw.


Panelists:

Rein Henrichs | Janelle Klein  | Coraline Ada Ehmke

Guest Starring:

Anjuan Simmons: anjuansimmons.com

Join Our Slack Channel!
Support us via Patreon!

Show Notes:

RubyConf 2017: Lending Privilege by Anjuan Simmons

01:18 – Anjuan’s Superpower: Flexibility

04:55 –…

All Ruby Podcasts by Devchat.tv 

RR 359: Panelist Thoughts, Gripes, and Ideas

Panel:

  • Charles Max Wood
  • Brian Hogan
  • Eric Berry
  • Dave Kimura
  • David Richards

In this episode of Ruby Rogues, the panel talk about their thoughts, gripe about things they don’t like, and discuss some new ideas. Some of the things they discuss include having a frozen version of your code, node modules, code dependencies, and more. They also touch on the fact that making shortcuts now means that you will have to pay for it later.

In particular, we dive pretty deep on:

  • Having a frozen version of your code is a good idea
  • Dependency problems
  • Ruby gems
  • Gem in a Box
  • Rubygems.org
  • Node modules
  • npm install
  • Do you have to manually add all the gems to the gem in a box?
  • You don’t ever…
Ruby Pigeon 

Testing Example Code In Your Jekyll Posts

Blocks of code in blog posts and articles often contain errors. I see it frequently, in other people’s writing and my own. Code examples are usually not tested, or even run through a compiler/interpreter, so errors are not surprising.

I’d like my code examples to be as good as the real code that I write. Ideally, all code examples would have tests, which are run before the site is deployed, as part of a CI build process.

And so, I created a Jekyll plugin to enable that workflow.

jekyll-include_snippet

jekyll-include_snippet is a plugin for Jekyll that allows snippets of text to be included from other files. This allows code to be kept separately from the markdown, which makes it easier…

The rest of this…

All Ruby Podcasts by Devchat.tv 

MRS 040: Mindaugas Mozūras

Panel: Charles Max Wood

Guest: Mindaugas Mozūras

This week on My Ruby Story, Charles talks to Mindaugas Mozūras. Mindaugas is from Lithuania and currently works at Vinted. He started about 5 ½ years ago as a software developer writing Ruby and now he the head of engineering at Vinted. He also has written an open source project called Pronto. He first got into programming when he was mesmerized by his father’s work computer and always grew up playing games that had to do with building things. They also touch on how he got into Ruby, what made him fall in love it, how he got his first Ruby job, and what he is working on now.

In particular, we dive pretty deep on:

Riding Rails 

RailsConf 2018 Edition

Hello 🌨 from Pittsburgh! RailsConf was amazing: more than a thousand attendees showing that Rails is more alive and welcoming than ever.

All the presentations will be available on YouTube in about a month. For now, you can take a sneak peek by browsing the slide decks: from Rails 6 to Active Storage, from Migrations to Testing, from Upgrades to API, from Router to Contributing, from GraphQL to Performance, from Collaboration to Communication, from Kafka to PostgreSQL, from Warden to Authorization, from Economy to Art, from Bugs to Security, from Containers to Crypto, from Interviews to History, from Teams to Trust, from Shopify to GitHub, from Engines to Crowdsourcing, from Mortality to Li…

This Week’s Contributors

37 people contributed to Rails in the last week, including 9 for the first time! A big thank you to all of you!

If you’d like to see yourself on that board, why not check out the…

Greater Than Code 

Special Edition: Code Is Social! LIVE from RailsConf 2018

Episode Sponsored By:

and                          

Panelists:

Coraline Ada Ehmke | Jamey Hampton | John K. Sawers

Guest Panelists:

Dinah Shi | Nick Quaranto | Vaidehi Joshi

Join Our Slack Channel!
Support us via Patreon!

Show Notes:

In this special episode of Greater Than Code, the panelists and guest panelists talk to an audience live from RailsConf 2018 about our relationship with our code, and the ways we have emotional ties with what we do, but also how there’s more to it than that.

Thank you to RailsConf, O’Reilly Media, and Cloud City Development for helping to make this happen in real-time! We couldn’t have done this without your thoughtful support.

Transcript:

CORALINE:  Hello and…

JRuby.org News 

JRuby 9.1.17.0 Released

The JRuby community is pleased to announce the release of JRuby 9.1.17.0

JRuby 9.1.x is our current major version of JRuby. It is expected to be compatible with Ruby 2.3.x and stay in sync with C Ruby. JRuby 9.1.17.0 is our latest release…

Major features of JRuby 9000:

  • Ruby 2.x compatibility
  • A new optimizing runtime based on a traditional compiler design
  • New POSIX-friendly IO and Process
  • Fully ported encoding/transcoding logic from MRI

If you do find issues then report them on using our issue tracker at http://bugs.jruby.org. We also encourage users to join our IRC channel (#jruby on Freenode) and…

Hi, we're Arkency 

Using singleton objects as default arguments in Ruby

Sometimes you would like to define a method which takes an optional argument, but the programmer might pass nil. And your code needs to distinguish between the value not being provided (default value) and nil. How can it be achieved?

The usual solution for default value is to define them as nil or other empty/zero values which makes sense such as 0 or a string, an empty array, etc.

class Foo
  def bar(one, two: nil)
    # ...
  end
end

But what if you need to distinguish between nil and no value being provided? What if you want to distinguish between:

foo.bar(:something, two: nil)

and

foo.bar(:something)

Here is the solution. Define a single, unique object and use it as a default.…

Appfolio Engineering 

Ruby Coordinator Processes for Fork Servers

Often I think, "threads are really annoying. Why don't people use processes?" Then, I use processes. Usually as I'm thinking, "processes are really annoying. Why don't I use threads?" The joke's on me either way, of course.

Until Guilds happen, those are mostly our options, outside special cases that can use EventMachine or Fibers or actors or whatever. I tend to consider processes to be the lesser evil for general use. And by "general use" I mean "not on Windows."

But cleaning up processes can be ugly. Oh, man. If you don't catch all your dead children you get zombie processes. And that's not even the most gruesome mixed metaphor in Unix concurrency.

So: let's look at a pattern in Ruby for…

Paweł U. | Ruby on Rails Web Development Consultant Full Stack Blog 

Direct, Secure Rails Client-side File Uploads to AWS S3 Buckets

Lock represents secure file upload from Rails apps to Amazon S3 Bucket

Many Ruby on Rails apps use Amazon AWS S3 buckets for storing assets. When dealing with files uploaded by front-end web or mobile clients there are many factors you should consider to make the whole process secure and performant. In this blog post, I will describe common pitfalls and an optimal solution when it comes to handling client-side file uploads.

I will be using Fog gem (version 2.0.0 at the time of writing) in the examples. It is a dependency of Carrierwave and Paperclip two popular file uploader gems. If you use either of them, you should already have it included in your app. If not just add:

gem 'fog'

to your Gemfile.

It is a lower level API than Carrierwave, Paperclip or S…