Laravel 5.4 – Higher Order Messaging For Collections

Two words: HELL, YES

The best way of showcasing this new feature is through code samples. Pretend you have a collection and you want to perform an operation on each of the items:

$invoices->each(function($invoice) {

With this new feature you will be able to simplify this into:


via Laravel News

Using an Encrypted Realm in a background or notification processes?

Note: This post's primary purpose is to help me think through this problem. I have no prescribed solution at the end of it. The conversation will continue on Stack Overflow. I will update this post once I have a final approach.

Realm has a great write up and sample code for encrypting your database. This documentation and sample work as intended, until you try to decrypt realm when:

  1. A user has a password on their phone
  2. The device is locked
  3. Your app is trying to do work with Realm when a remote notification comes in

This happens because we can't access the keychain to get (or create) the key to en/decrypt the Realm. The default kSecAttrAccessible value is kSecAttrAccessibleWhenUnlocked

There are a few options as I see them:

  1. Change kSecAttrAccessible to kSecAttrAccessibleAlways. I don't like this because it's a) too open and b) it was slated to be deprecated in iOS 9
  2. Change kSecAttrAccessible to kSecAttrAccessibleAfterFirstUnlock or kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly. This is better but still feels too open to me, even though the docs state: This is recommended for items that need to be accessed by background applications
  3. Create a second, non-encrypted Realm to use as a staging database. Store notification data here, then when the app wakes up from user interaction (the device would be unlocked), move the data from the staging Realm into the encrypted real one. This doesn't feel right either, as we'll have data temporarily not encrypted
  4. Combine 2 and 3 and encrypt the staging Realm, and protect it's key with kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly
  5. ??

I'm currently trying to decide if #2, if #3 is worth putting the time into, or if I can come up with a #5

Using iOS 10 devices with Xcode 7

Peter Steinberger started a GREAT gist on Using Xcode 7.3.1 and iOS 10 devices.

Below is what worked for me to get a few extra test devices (my carry phone runs the 10 beta) working with Xcode 7. Can't upgrade to 8 just yet. Working with a contractor and don't want to move too many pieces.

My Setup

Xcode 7.3.1 and Beta 6 iOS 10 beta 6 (Beta 7 is out, after getting this to work, I don't think I'm upgrading just yet)


  1. sudo ln -s /Applications/\ \(14A5339a\)/ /Applications/
  2. iPhone: Settings > General > Reset > Network Settings
  3. Reboot iPhone (after it wakes back up from the network reset)
  4. Reboot Mac (restarting Xcode alone didn't work)

It these steps don't work for you, check out the gist for other options.

Metallica’S New Song Is Their Ballsiest In Decades

The metal-heads who thought Metallica had turned into tired old wussies should sit down and shut up for three minutes, because the quartet is back with a new song that ranks as its best work in decades.

​"Hell Yeah"

Metallica has been my favorite band since middle school. Their discography playlist is constantly played on Spotify. Since S&M, their work has been lack-luster. I've listened to it in the hopes it will be good. It never is.

After listening to this teaser song, I am VERY, VERY, excited. It's GREAT

Opening iTerm2 Tabs at Specific Directories

I love iTerm2. I can customize the stock just about as much, but it's much easier in iTerm. I find myself always opening the same 3 or 4 tabs when I get into coding mode. Luckily iTerm2 has great scripting support

The 4 tabs I always open for Kidfund are:

  1. Our iOS project
  2. Our Laravel project. Usually where I run artisan commands
  3. Our Laravel project; Tails most recent file in the log directory
  4. Our Laravel project; I jump around from here. Usually CD-ing to 1. the realm directory to pop it into Realm Browser

I didn't want this to run all of the time so I didn't have this script run each time iTerm opens. I instead wired it into an Alfred command. If you are interested you can download that here

The underlying script is as follows. It's crud, and could definitely be more flexible, but it works for me at the moment. Hopefully it can help you craft something to your needs

tell application "iTerm2"
  tell current session of current window
    write text "cd ~/workspace/kidfund/ios"
  end tell
  tell current window
    create tab with default profile
      tell current session of current tab
        write text "cd ~/workspace/kidfund/web"
      end tell
  end tell
    tell current window
    create tab with default profile
      tell current session of current tab
        write text "cd ~/workspace/kidfund/web && tail -f storage/logs/\"$(ls -at storage/logs | head -n 1)\""
      end tell
  end tell
    tell current window
    create tab with default profile
      tell current session of current tab
        write text "cd ~/workspace/kidfund/web"
      end tell
  end tell
end tell