network

iPhone/iOS: How to quit using cellular data when using WiFi

I live in Colorado, where cellular reception can be very hit or miss because of the mountains and rolling hills. As just one example there are only two spots in my apartment where I can make a phone call. So when I’m at home trying to view a website using Safari on my iPhone and the page is loading really slow, I find it really annoying that my iPhone is trying to use my cellular data rather than my home wireless network (WiFi).

Networking alvin August 1, 2017 - 11:42am

“Grasshopper, know yourself, and never fear thus
to be naked to the eyes of others.
Yet know that man so often masks himself.”

From the Kung Fu tv series

I’m a technical person. I was trained as an Aerospace Engineer, and taught myself to be a computer programmer and systems architect. I don’t really like small talk. I’m an introvert, not a networker. I don’t like networking at all. I don’t even like the word “networking.”

Source code for an Android AsyncTask (REST client) example

I just got back into using an Android AsyncTask, and it took me a little while to re-load the concepts in my head. I used AsyncTask’s a few years ago, but haven’t used them since.

To help remember how they work, I created a little AsyncTask example project, and I’ve included all of the source code for that project here. I’ll show all of the source code for my classes and configuration files, and then explain the code at the end.

An example of Android StrictMode output (with improper database access)

I was just working with an example of how to use Android’s new Room Persistence Library, and the example I was working with ran some of its code on the main Android thread, also known as its “UI thread.” I knew this was bad, but I wanted to start with someone’s example, and then figure out a good way to get the Room method calls to run on a background thread, such as using an AsyncTask. (The Android docs don’t specify a “best practice” for this atm.)

ScalaJ-HTTP examples: GET, POST, handling redirects

Table of Contents1 - Handling redirect requests with ScalaJ-HTTP2 - ScalaJ-HTTP GET request example3 - Setting ScalaJ-HTTP timeout values4 - A ScalaJ-HTTP POST request example5 - ScalaJ-HTTP: Summary

If you ever need some good ScalaJ-HTTP examples, see the test files in the project, including this HttpBinTest.scala file. That file currently shows a number of good ScalaJ-HTTP examples, including GET, POST, redirect examples with Scala.

See that page for a full list of examples, but for my own use, here are a few of them.

Processing HTTP response headers with a ScalaJ-HTTP web client

If for some reason you ever want to print out some HTTP response headers from a HEAD request when using ScalaJ-HTTP as an HTTP client, this example may help point you in the right direction:

import scalaj.http._

object TestHead extends App
{
    val response: HttpResponse[String] = Http("http://www.google.com")
        .method("HEAD")
        .timeout(connTimeoutMs = 2000, readTimeoutMs = 5000)
        .asString
    for ((k,v) <- response.headers) println(s"key:   $k\nvalue: $v\n")
}

I may write more about ScalaJ-HTTP in the future, but for today that’s a quick example of processing the response headers/parameters when making a HEAD request.