Swift Xcode Asynchronous Testing

A while back I posted my tweak to some Xcode testing for asynchronous calls. Here’s an update I did in Swift for XCTestCase.

extension XCTestCase {
  /**
   For use testing async functions.
   Will wait for completion of the function.
   You need to provide a test function for when the call is completed.
   The ultimate timeout should be provided for cases of there not
   being a response.
   
   let _ = self.waitUntilReady(completionTest: { () -> Bool in
   return remoteInterface?.isBusy == false
   })
   
   or as a trailing closure:
   
   let _ = self.waitUntilReady() {
   return remoteInterface?.isBusy == false
   }
   
   optionally using your own timeout:
   
   let _ = self.waitUntilReady(timeout: 20) {
   return remoteInterface?.isBusy == false
   }
   
   */
  func waitUntilReady(timeout seconds:TimeInterval = 30, completionTest: () -> Bool) -> TimeInterval {
    let start = Date.timeIntervalSinceReferenceDate
    let loopUntil = Date(timeIntervalSinceNow: seconds)
    
    while completionTest() == false && loopUntil.timeIntervalSinceNow > 0 {
      RunLoop.current.run(mode: .defaultRunLoopMode, before: loopUntil)
    }
    
    let finish = NSDate.timeIntervalSinceReferenceDate
    let runtime = finish - start
    return runtime
  }
}

Mac Black Screen of Death

After a power outage, my iMac (27″, Late 2012) with macOS Sierra (10.12.2) booted into a black screen with the mouse in the upper left. Notifications seemed to be showing up (as they do on the login screen).

Several leads didn’t pan out. Ones that were basically different kind of resets.

Mark Gibbs tipped me off that it might be a problem with a corrupted /Library/Preferences/com.apple.loginwindow.plist file.

Single User Mode

Booting into single user mode (Command-S during boot) drops you into a terminal, which allowed me to look at the file. Not knowing what it’s supposed to look like, it was hard to tell if the (likely digitally stored) file should look like.

bplist00€	


_RetriesUntilHint\GuestEnabled_OptimizerLastRunForSystem\lastUserName]autoLoginUser_OptimizerLastRunForBuild_HiddenUsersList[AccountInfoXlastUser_autoLoginUserScreenLocked^lastLoginPanic	
XbshirleyXbshirley`°Y_conveyor”\MaximumUsersYAllLoginsYOnConsole—Xbshirley—XloggedIn	#AæFt?È`2?[hvë£Ø?‘„ÂÊÎÙ?",68;DGPQZ

The beginning of that file indicates it’s a property list stored in binary form, so it’s hard to interpret in textual form.

The filesystem is read-only when you boot into single user mode, so by default you can’t delete (or preferably move) the file.

Remount Filesystem

The answer to that I found on Stack Overflow. You can use the UNIX mount command to remount the existing filesystem in a writable state.

sudo /sbin/mount -uw /

Rename File

Once that was the case, I rename the file (incase I needed it for something) and then

cd /Library/Preferences
mv com.apple.loginwindow.plist com.apple.loginwindow.plist.XXX

Once that was done, exiting single user mode and rebooting is as simple as

reboot

A few items were reset from my previous login, but otherwise all was well.

Open Letter on Bike Path Diversion

Mayor Sylvester Turner
sylvester.turner@houstontx.gov
@SylvesterTurner

Council Member Ellen Cohen
districtc@houstontx.gov
@EllenCohen1

Dear Mayor Turner and Council Member Cohen,

When I read the Chronicle article attached below, I understood the need for a detour around the often used route, and appreciated the thought put into it. It seemed like a good solution.

The article states “The detours will not be continuous, but periodic throughout the construction project when construction nearby could create unsafe conditions along the original bike trails” as well as “the detour and reroute are expected to begin between April and May and will last through the third quarter of 2017.”

However there seems to be either,

  1. a miscommunication,
  2. a failure to execute, or
  3. deception by someone

going on in this situation.

There are already signs up along the path redirecting users to use the detours. They have been up for over 10 days. There is also signage that appears to indicate that cyclists should use the sidewalk on the west side of Houston Avenue as the detour.

This is neither safe, nor acceptable.

I would like to know if the original decision has been changed or if there is a timing and communication failure occurring. Please remedy the situation.

Your Constituent,
Bill Shirley

Heights Area Bike Trails to be Rerouted to Houston Avenue“, Tara White, Houston Chronicle,  Wed Mar 9 2016

CC:
Council Member Karla Cisneros (as the detour is in your district)
districth@houstontx.gov
@Karla4Houston

Deidrea George, TxDOT Houston Public Information Office (quoted in the article)
Email via web-form
@TxDOTHoustonPIO

Tara White, freelance writer for Chronicle (author of the article)
viewpoints@chron.com
@houstonchron

Continue reading Open Letter on Bike Path Diversion

Politically Correct Incorrectness

Recent Reuters coverage by Emily Flitter of the 2016 campaign was asking Donald Trump supporters why they liked and supported Trump. Many of the answers were “he’s not Politically Correct”, that he “says what he thinks, I like that, he’s not political [sic] correct”, “he’s not afraid to say what he thinks”, and “he’s speaking for a lot of people … who have been hindered to say anything because of how political [sic] correct we’ve become as a nation … Trump’s made people feel like they can ‘voice out'”.

trump quoteFrom there the comments went on to The Wall™– “there needs to be something done about our border, he got right to the point”, “we need to just not let any more people in. Their values are different than ours. Are we allowed over there without a visa?”, and “he says what we’re all thinking”.


The phrase “he’s not politically correct” seems to be the politically correct term for “openly racist” to me. Certainly among parts of his base. They feel they can “voice out” their racist opinions. (‘Racist’, ‘Dangerous’, and ‘Un-American’ -U.S.News.)

I’m sorry if they didn’t feel they can always voice an opinion. I’m also sorry they feel it’s acceptable to voice out their racist views in public.

I think even more of his supporters aren’t necessarily racist, but ignorant of the overall economic necessity of the flow of people, for everyone but, in this case, specifically for the U.S. We do need to fix immigration policy. But it needs to be changed so that we can track and manage those in our country supporting the lower tier of our economy.

Yes, there’s something we need to fix. No, the solution is not a wall.

Aside: travel, with or without a visa, is not particularly the issue here. In response to the supporter asking “are we allowed over there without a visa?” …

Yes. Yes, we are allowed to travel “over there” (by which I suspect you mean “south of the border”) without a visa. American citizens can enter 166 countries visa free. They include most of Central and South America, most of Europe, Southeast Asia, and large parts of Africa.

Take them up on it. Please travel. Perhaps your xenophobia will be tempered after you do.