javascript

How to use `curl` scripts to test RESTful web services

Table of Contents1 - GET, POST, DELETE, and PUT examples2 - More POST examples3 - Headers returned by the server4 - Discussion5 - Summary

There may be better ways to do this, but when I was writing a mobile app, with the JavaScript client written in Sencha Touch and the server written with the Play Framework, I wrote some curl scripts to simulate GET, POST, DELETE, and PUT request (method) calls to my Play Framework REST/RESTful web services.

The lack of type safety was difficult to scale ...

From this AirBnB article about using React Native: “JavaScript is an untyped language. The lack of type safety was both difficult to scale and became a point of contention for mobile engineers used to typed languages who may have otherwise been interested in learning React Native ... A side-effect of JavaScript being untyped is that refactoring was extremely difficult and error-prone.”

Using structs in JavaScript (example, syntax)

Bearing in mind that I rarely use JavaScript and I’m not an expert in it, I like the idea of using something like a C-like “struct” in my JavaScript code, so I used the following approach on a recent project. First, I define my JavaScript struct:

function Book(title, href, imageUri, description) {
    this.title = title;
    this.href = href;
    this.imageUri = imageUri;
    this.description = description;
}

Then I define an array of Book types:

JavaScript console.table logging/debugging output alvin May 3, 2018 - 3:12pm

I haven’t worked with JavaScript much in the last few years, and I just learned about this cool console.table output-logging technique, which I just saw on this website, which has several other good JavaScript debugging techniques.

How to get multiple, random, unique elements from a JavaScript array alvin April 18, 2018 - 3:39pm

As a note to self, this JavaScript code gets multiple, random, unique elements from a JavaScript array and displays three of those elements in the second div:

iPhone 8 vs Intel Core i5 web performance

With Twitter being Twitter, I saw this image there, and now I can’t find it again. But it shows that the new iPhone 8 is significantly faster at rendering a cnn.com page.

Actually, since I can’t find the original source, I don’t know if they both rendered mobile web pages, or whether they tried several times to make sure it wasn’t just a hiccup. But seeing that the architecture in a little phone can come anywhere near the performance of a desktop/laptop processor that’s still being sold makes one wonder about the future.

Update: I think this was the original source of the image.