deserialization_benchmark.rb
Each of these scenarios just changes the payload to be parsed, and does not change any deserialization options.
import 'dotenv/config'; | |
import { NestFactory } from '@nestjs/core'; | |
import * as repl from 'repl'; | |
import * as Logger from 'purdy'; | |
const LOGGER_OPTIONS = { | |
indent: 2, | |
depth: 1, | |
}; |
deserialization_benchmark.rb
Each of these scenarios just changes the payload to be parsed, and does not change any deserialization options.
First, add pry-rails to your Gemfile:
https://github.com/rweng/pry-rails
gem 'pry-rails', group: :development
Then you'll want to rebuild your Docker container to install the gems
When developing a program in Ruby, you may sometimes encounter a memory leak. For a while now, Ruby has a facility to gather information about what objects are laying around: ObjectSpace.
There are several approaches one can take to debug a leak. This discusses a time-based approach, where a full memory dump is generated every, say, 5 minutes, during a time that the memory leak is showing up. Afterwards, one can look at all the objects, and find out which ones are staying around, causing the
At Monmouth Telecom we provide high-availability cloud based telephone systems for medium to large companies. Because | |
we have written our own code in Ruby it is easy for us to customize or add additional features at the request of customers, | |
often at no charge, and that is key to our business. | |
Several years ago our engineering team developed a real time display panel for managers and operators alike that kept people | |
abreast of the status of phone extensions, conference bridges, and call queues, as well as allowing a variety of call control | |
features. We wrote this in ruby so that it would be easy to extend. The web display panel accesses customer data through | |
Active Record and is based on HTML5 with canvas and web sockets so it doesn’t require setup on the customer site. | |
Unsurprisingly it was one our more popular features and so we immediately started monitoring Rubinius as our migration path | |
for the day when one core of our 8 processor cores would become insufficient to meet demand. Well earlier this year |
# Build the relevant methods | |
-> with_self { | |
-> list { | |
-> the_program { | |
the_program[with_self, list] }}[ | |
# list | |
-> build_node { | |
with_self[-> me { | |
build_node[-> { me }, -> { raise 'too far!' }]}]}[ |
I've heard people argue "parentheses make code more readable" or "parentheses make code less ambiguous". Parentheses neither help nor hinder ambiguity or readability, your style decisions beyond use of ()
do that.
Here's a bug we introduced in our application that was allowed through by a coding style that preferred parentheses. If you follow a coding style that omits all unneccesary parentheses (only those that suppress warnings, which I prefer) this bug would have been impossible.
The bug is simple but subtle. The environment-specific data wasn't fetched from config/two.yml
because a )
was in the wrong place. Neither my coworker who wrote it, another coworker who reviewed it, nor my own review of the line caught it.
Without parentheses, though, there is no way to introduce this class of bugs because you can't chain off of intermediate results without introducing a local variable.
The main difference between the two examples is not the use of parentheses, it's the style in which the code is wri
require 'curses' | |
module Seeder | |
extend self | |
def generate_matrix | |
rand(40..200).times.map { [rand(24), rand(48)] } | |
end | |
end | |
class Universe |
#Simple Authentication with Bcrypt
This tutorial is for adding authentication to a vanilla Ruby on Rails app using Bcrypt and has_secure_password.
The steps below are based on Ryan Bates's approach from Railscast #250 Authentication from Scratch (revised).
You can see the final source code here: repo. I began with a stock rails app using rails new gif_vault
##Steps