valve's

corner

JSON Serialization in Rust, Part 2

This post is intended for people coming from high level languages, such as Ruby or JavaScript and who may be surprised with the complexity of the JSON serialization infrastructure in Rust.

This is the second part of the 2 part post that deals with decoding JSON strings into Rust values. First part is available here.

Overview

When working with JSON deserialization, we’re interested in Decodable and Decoder traits.

As with serialization, hex and base64 modules are not relevant to JSON deserialization, so we should not pay attention to them.

JSON Serialization in Rust, Part 1

This post is intended for people coming from high level languages, such as Ruby or JavaScript and who may be surprised with the complexity of the JSON serialization infrastructure in Rust.

This is the first part of the 2 part post that deals with encoding Rust values into JSON. Second part will deal with converting JSON strings back into Rust values.

Overview

JSON serialization lives in the serialize crate. It contains json module where low-level implementation details live and two traits which we are interested in: Encodable and Encoder.

Please note that hex and base64 modules are not relevant to JSON serialization, so we should not pay attention to them.

Immutability in Ruby

Like many other developers, I’ve been intrigued with functional programming for a long while. I remember myself reading articles promising programming heaven for those who are brave enough to go functional. I bought a used Real World Haskell on Ebay, but sadly never finished it. I then bought Scala for the Impatient, but this time had the persistence to finish the book.

All these years functional programming seemed like a holy grail, but as a true holy grail, I was afraid it was meant to stay undiscovered.

All these years I paid my bills writing Ruby-on-Rails and JavaScript code and never made the functional leap. I never became a full-time Haskell or Scala developer and probably will never become one.

But you know what? It’s possible to be slightly more functional with normal languages we’re using every day. This article will try to demonstrate several concrete examples where functional programming is useful or elegant. I will show you the old way of doing things in Ruby and the new, more functional way of doing similar things in Ruby again.

Introduction to Full Text Search for Rails Developers

Every developer has heard of full-text search. However, most developers search with SQL and relational databases.

Almost every developer knows deep inside that full-text search is better suited for searching text, but continues to use old LIKE '%?%' queries.

I was one of those developers who never used full-text search, but I have changed and I invite others to join me and discover the other side of search with Solr.

Constant Resolution in Ruby

Ruby constant resolution has always been somewhat confusing to me. In this article I’m going to demistify it for myself and hopefully help other readers.

Anonymous Browser Fingerprinting

What is fingerprinting?

Fingerprinting is a technique, outlined in the research by Electronic Frontier Foundation, of anonymously identifying a web browser with accuracy of up to 94%.

Browser is queried its agent string, screen color depth, language, installed plugins with supported mime types, timezone offset and other capabilities, such as local storage and session storage. Then these values are passed through a hashing function to produce a fingerprint that gives weak guarantees of uniqueness.

No cookies are stored to identify a browser.

It’s worth noting that a mobile share of browsers is much more uniform, so fingerprinting should be used only as a supplementary identifying mechanism there.

In this post I’m going to explain how it works in detail and give you real-life statistics accumulated over the period of 4 months of production usage.