Category: Featured

Adapt jQuery.getJSON to an Rx.Observable with RxJs

Rx provides an incredible and fluent API to help untangle your asynchronous JavaScript code. Here we’ll see how to adapt jQuery’s getJSON method to an Rx Observable with only a small bit of code. [code language=”JavaScript”] function getJSON(url, data) { return Rx.Observable.create(observer => { var canceled = false; if (!canceled) { jQuery.getJSON(url, data). done(data => { observer.onNext(data); observer.onCompleted(); }). fail(err => observer.onError(err)); } return () => canceled = true; });...

Asynchronous programming with Async / Await and the Scala Play Framework

Asynchronous programming has a number of advantages, most notably is its well touted ability to improve responsiveness. Asynchronous events occur independently of the main program flow and asynchronous actions are executed in a non-blocking, lock-free manner. This, ultimately, allows the main program flow to continue unimpeded, without blocking. On the flips side, asynchronous programming can be difficult to reason about. Many actions are often run simultaneously which can lead to...

Play Framework – Adapting Java 8 CompletableFutures to Play F.Promises

Recently, I have been playing around with Java 8 and the Play Framework (2.4RC1) – bad pun intended :P. As I worked to develop the codebase, I found the need to integrate with Java 8 CompletableFuture‘s. No big deal, right? At first, it didn’t seem to be, but as I continued coding, I quickly became very unhappy with how my code was turning out. The Play Framework for Java introduces...

Scala Futures by example

What is a Future? A Future is essentially a placeholder object that is created for a result that does not yet exist. Scala Futures are asynchronous and non-blocking (by default) and are thus often handled with callbacks. Hmm. What about ‘callback hell’? Scala Futures are monadic in nature and can be combined, composed, sequenced, and executed concurrently. All of this can be accomplished with Scala in a very simple, yet...

RawCap and Wireshark: How to capture and analyze local traffic from host machine to itself

Wireshark is an incredible resource when it comes to capturing and analyzing network packets or traffic. Unfortunately, on Windows, Wireshark is unable to capture packets or traffic sent from a host machine to that same host machine. This is due to the fact that such local traffic is not sent over a real network interface, but instead (in many cases) is sent over a “loopback interface”. Loopback traffic can be...