Procrastination as a tool for Productivity

There’s a thousand small things that I need to get done during the week. They’re only mildly the same week-to-week, and they all individually don’t take up much time at all, but together they eat far more of my productivity than they deserve. I’d found that I was spending far too much time context-switching between my real work – programming – and these other smaller tasks. Programming is the sort of job that doesn’t work well with small distractions, and these small tasks were eating far more of my time than they deserved. Something needed to change.

So a few months ago I started an experiment – instead of doing these little things as they came up during the week, I would procrastinate- er, schedule- all of that time for a single day: Tuesday.

It’s a simple change – an obvious one in hindsight – Instead of replying to emails immediately or scheduling calls for that afternoon, I decided to completely ignore them until just 1 day a week. If I needed to meet with someone, “how’s next Tuesday work for you?” If I needed to write a new blog post – Tuesday’s the day. Replying to emails? Tuesday. Generi-task that’s not crucial to building great products? Tuesday.

It’s a simple change, but it’s let me push all of my context-switching tasks into just 1 time block, which has freed up the rest of my week for dramatically fewer distractions as I program. I’ve dubbed Tuesday as my “fake productivity” day – it’s for all the things that I genuinely do need to do, but at the same time don’t help me build better software. My “real productivity” – building stuff – has been much more efficient now that I’ve moved most of my distractions out of the way.

It’s a habit I highly recommend.

Automatically Include Open Source Licenses into the Settings Bundle

There’s a good chance your iOS app includes a number of open source frameworks in its codebase, and Loose Leaf is no different. Many of these dependencies’ licenses require that you include a copy of the license in your final build. Some require other attribution or URLs. Even with just a few includes, it can quickly become difficult to manage.

Last week, we talked through how to automate our app’s version numbers, and this post will automate our bundled licenses.

The Goal: Include Licenses in our Settings

This walkthrough will help us create a custom sub-menu in our Settings.bundle to show all of our bundled licenses.

Licenses in Settings

Step 1: Prepare The Settings Bundle

First, we need to define where that section will appear in our settings bundle.

In your Settings bundle, create a new file Acknowledgements.plist:

Acknowledgements

Since the contents of this file will be auto-generated each time we compile, there’s no reason to add it into your git repo. I suggest adding the path to Acknowledgements.plist into your .gitignore file.

Next,you’ll need to add 2 items to your Root.plist – a Title and a Child Pane:

License Root.plist item

The first item creates the “LICENSE” title item, and the second creates the link to our sub-menu. It references the file “Acknowledgements.plist” to use as the child pane.

Step 2: Add License Files

Next, we need to define the licenses that we’ll be wanting to include in our Settings bundle. For each license, create a separate .license file in your project contents. No need to copy these into your built product, we only need them in our source tree – we’ll be using them to generate the contents of our Acknowledgements.plist file in the next step.

Each license file should be in the following format:

Name of the Licensed Object, eg. "JRSwizzle License" etc

contents of the license here - copy of the MPL or MIT License, etc

Step 3: The Build Script

I’m using the perl script from this Stack Overflow answer, and I’ve saved it as “generateLicenses.pl”. This perl script will be modifying the Acknowledgements.plist file for us.

#!/usr/bin/perl -w

use strict;

my $out = "Settings.bundle/en.lproj/Acknowledgements.strings";
my $plistout =  "Settings.bundle/Acknowledgements.plist";

system("rm -f $out");

open(my $outfh, '>', $out) or die $!;
open(my $plistfh, '>', $plistout) or die $!;

print $plistfh <<'EOD';

StringsTable
Acknowledgements
PreferenceSpecifiers

EOD
for my $i (sort glob("*.license"))
{
    my $value=`cat $i`;
    $value =~ s/\r//g;
    $value =~ s/\n/\r/g;
    $value =~ s/[\t]+\r/\r/g;
    $value =~ s/\"/\\\"/g;
    my $key=$i;
    $key =~ s/\.license$//;
    
    my $fullstr = "";
    
    my $cnt = 1;
    my $keynum = $key;
    for my $str (split /\r\r/, $value)
    {
        if ($cnt == 1){
            print $plistfh "\n";
            print $plistfh "Type\n";
            print $plistfh "PSGroupSpecifier\n";
            print $plistfh "Title\n";
            print $plistfh "$keynum\n";
            print $outfh "\"$keynum\" = \"$str\";\n";
        }else{
            $fullstr .= "\n\n" . $str;
        }
        
        $keynum = $key.(++$cnt);
    }
    
    $fullstr =~ s/^\s+//;
    $fullstr =~ s/\s+$//;
    
    print $outfh "\"$keynum\" = \"$fullstr\";\n";
    print $plistfh "FooterText\n";
    print $plistfh "$keynum\n";
    print $plistfh "\n";


    print $plistfh "\n";
    print $plistfh "Type\n";
    print $plistfh "PSGroupSpecifier\n";
    print $plistfh "FooterText\n";
    print $plistfh "\n\n";
    print $plistfh "\n";
}

print $plistfh <<'EOD';



EOD
close($outfh);
close($plistfh);

Important!

Make sure the Run Script is near the top of your Phases section. This script needs to be run before the Copy Resources item in your Build Phases.

Step 4: Build your project!

That’s it! Just build and run your project, and all of the licenses should be auto-included into your Settings bundle automatically. If you ever need to add or remove more licenses, just add or remove more .license files from your project’s directory and they’ll be automatically included in the next build. Easy!

This process has been incredibly helpful for Loose Leaf‘s build process. I include a number of different open source frameworks, and this has been incredibly helpful for organizing those licenses into the build. Of course, I also have a number of frameworks that I’ve open sourced as a part of Loose Leaf’s development, so maybe I’ll see one of those included in your project too!

Streaming Xcode and iPad Development with OBS

Developer Livestreams

Since January, I’ve occasionally live streamed Loose Leaf iOS development to YouTube. I even took some time in April to stream and open source a 2D physics game from scratch! It’s been a challenging and fun experience personally, and has more broadly grown into quite a subculture – sites like Watch People Code, Livecoding.tv, and even articles by CNN and Wired show the trend’s recent growth.

When I first started to stream, it was surprisingly difficult to get started. I wasn’t quite sure what software to use or how to set things up. This post aims to help new streamers and be a quick and easy way to get streaming quickly.

What do I need?

You only need a few tools to get started:

  1. Open Broadcast Software: https://obsproject.com/download
  2. Live Video Display: http://www.zachpoff.com/software/live-video-delay/ (optional)
  3. Your own Youtube channel

Step 1: Schedule a Live Event on YouTube

OBS is the key to your streaming puzzle – it’s the piece that streams your desktop to YouTube, so step one is to configure it with your personal YouTube settings. First, login to your YouTube channel and go to your “Creator Studio.”

Creator Studio

Next, expand the Video Manager and select “Live Events” from the sidebar. Then click to add a new Live Event – don’t worry, it won’t go live without your say-so later on.

Live Events

Fill out any title you’d like, pick a date far in the future, and click “Create Event”. Next, in the Ingestion Settings section, you’ll be telling YouTube how you’ll be sending it your stream. For this, I have it set to 500-2000Kb (480p).

bitrate

Once you’ve selected your bitrate, YouTube will show you your personal stream settings. This is what we’ll use to configure OBS:

stream key

Step 2: Configure OBS

Open OBS and click on the Settings button. Then, select the Stream settings option and select YouTube as your stream type, and then copy your “Stream Name” from the above strep into the “Stream key” field in OBS.

stream settings

Next, we’ll need to make sure your stream bitrate etc are setup properly – click on the Output tab and set your bitrate to 1500.

bitrate settings

Last but not least, go to your Video settings and set your scaled resolution to 854 x 480. My internet plan only allows up to 3Mb/s upload speed, so 480p is as much as I can stream before maxing out my bandwidth.

resolution settings

Now OBS is configured properly, but we still need to tell it exactly which window / screen to stream! On to Step 3….

Step 3: Creating a Scene

OBS lets you easily switch between multiple independent “Scenes” while you stream – convenient for switching between a static “Setting up” image to your live video stream, etc. For now, we’ll just setup a single video stream source: create a new scene in OBS with the little green plus icon Screen Shot 2015-06-12 at 11.20.08 PM, and name it anything you like. With that scene selected, add a new Source to the list with its green plus icon Screen Shot 2015-06-12 at 11.20.08 PM and choose “Display Capture.” If you have multiple monitors, pick your display, then click “Ok”.

Step 4: Test the Stream!

Now you’re setup and ready to go! Switch back over to YouTube and click into your Live Control Room.

Live Control Room

You should see a red bar across the top saying that YouTube is not receiving any data. Switch over to OBS and click on the Start Streaming button. After a few seconds, you should see that red bar disappear and the Preview button will enable. Click that Preview button to see how your stream is doing, then go live when you’re ready!

Step 5: Setup your Webcam (optional)

OBS has support for adding your webcam as a video source, but I found that it lagged considerably behind the stream of the desktop. Instead, I suggest installing Live Video Display. After it’s launched, we’ll need to select your iSight as it’s camera source. Select the Video Settings button, choose your iSight camera from the list, and pick the smallest capture resolution:

Video Settings

We’re only using Live Video Display for the webcam, not for anything else, so turn off its audio settings:

Audio settings

Last but not least, set it to have zero frames of delay – this’ll force it to push your webcam to OBS as fast as it can capture it:

Screen Shot 2015-06-12 at 11.44.31 PM

Now that your webcam source is setup, we need to configure OBS to know about it. In OBS, click the green plus icon Screen Shot 2015-06-12 at 11.20.08 PM to add another source to your scene. Choose Game Capture (Syphon) and name it anything you like. When its properties window opens, check the Inject box and launch SyphonInject, then choose Live Video Display from the list – you should see your webcam pop into the preview window. Click OK to confirm, and that’s it! Now you should see your webcam on top of your desktop screen!

Step 6: Enjoy!

I’ve really enjoyed live streaming some of my iOS development – I’ve met new people, learned new things, and enjoyed it all from start to finish! If you’d like to follow along on any of my dev streams – either for Loose Leaf, Spare Parts, Remotely, or others – head on over to my YouTube or LiveCoding.tv pages :)

Google Author link
Page 1 of 4812345...102030...Last »