Excluding multi-day events when displaying upcoming events (The Events Calendar)

Background Notes

  • Using The Events Calendar plugin by Tribe for WP as a community calendar.
  • Need to show five upcoming events in a section on the home page.
  • Only want to show events that have a start date of today or in the future.

Issue

The function get_tribe_events would pull in events that encompassed today’s date but had started in the past. The client only wanted events that had a start date of today or in the future to be displayed to avoid a situation where five long spanning events stayed on the homepage as the next upcoming events.

testing

Investigation

The problem seemed to stem from the way The Events Calendar was handling reoccurring events (or events that spanned multiple days). It would apply a start date of today’s date if today was encompassed in the date range of the event. Therefore, in a foreach loop when you asked get_tribe_events to only show upcoming events or all events with a start day of at least today it would also include these multi-day events.

I tried a slew of conditional statements in the loop to try and ignore the events whose start date was in the past but I just couldn’t get it quite right, the loop still counted these false-positives and I was continually having to update the posts_per_page argument to prevent there from being too many or too few events. It wasn’t until I start printing a second instance of the start date of an event that I learned the loop was behaving normally but I targeting a fake start date.

From reading around it seems like each event (specifically those that were reoccurring or multi-day) were given two start dates in the database and get_tribe_events was pulling the “wrong” one for use in it’s decision on what was an upcoming event. If an event spanned multiple days it would receive today’s date as it’s start date so the loop would know to continue showing it even if the actual start date of the event was months in the past.

Solution

Once I knew that I needed to target a specific row in the database I switched across to a WP_Query to utilize the meta_query argument. I was then able to target the actual start date of the event with _EventStartDate and use compare to tell the query to only display events that occurred on or after today’s date.

upcoming-resolved

Here’s the code I used to solve the problem:

Globo world clock app

This new app solves a reoccurring problem for me. I want to figure out a suitable time to call my Mum in Brisbane, Australia or my Dad in Bangalore, India.

In the past I try to remember how many hours ahead of Omaha each city is and then, literally, count on my fingers. When daylight savings kicks in here, I’m totally lost. My next stop would be the Clock app to check the local time and then count ahead until I hit a time that everyone is available.

I actually started a Treehouse course on iOS development in the hope that I could build this very app, or a dumbed down version of it.

Globo’s top feature, in my mind, is the “set actual time” screen that lets you pick a time, either locally or for another location, and then see what time it is across all locations you have saved. If it’s 10am in Brisbane, what time is it in Omaha?

If you communicate with anyone in different timezones then I recommend you grab this app for $0.99 and never mis-schedule a call or meeting again.

The 10pm reminder

About 5 months ago I wrote of my woes with time tracking. I tried to find software that tracked my time for me and I specifically called out Rescue Time as a solution. It was not.

The next stop on my quest for better time tracking was a bit extreme. I decided to use a method, detailed by TJ Luma, where my Mac automatically took screenshots every 30 seconds. I could then sort through those screenshots to see what program, file, site etc I was in at any particular time. I ended up with a folder containing seven days worth of screenshots and no desire to look through them.

I solved all of my time tracking problems with a simple reminder. Every day at 10pm my phone buzzes one last time. It’s a reminder that asks “Do you have time to track from today?” For the first week I had things to add to my work log. It was annoying (even with the text expander snippets and Drafts). I started to track my time more accurately while I was doing the work just to avoid the 10pm chore. My reward for building a better habit was that I could go to sleep or read or just relax after 10pm rather than filling out a time sheet.

iPad 10pm Reminder

The reminder keeps my freelance work in check but I just took a position with a design agency and that means accounting for how I spend every minute of my working day. I use Day One as a work journal to handle this. Katie Floyd talked about using Day One on an MPU episode and I always thought it would be a great solution. The software provides a lot more context than a plain text file can with data like weather, photos, motion activity and location. I keep Day One open on my desktop at all times and I record anything I work on with a start and stop time. I’m able to quickly take that info and move it across into the company’s time tracking system.

Using Spaces with dual monitors in OS X Mavericks

Jump to the How to part

I bought a 13″ MacBook Pro in 2009 with the expectation that I would save again and buy a 27″ Cinema Display so I could actually get work done. While I still covet the larger screen I’ve been able to manage just fine with the smaller built in one. How can I get anything accomplished on a 1280×800 screen you ask?

Spaces

Spaces is a feature of OS X (since Leopard) that enables you to create and switch between multiple desktops. I use three, although you can create up to 16, and I use the different desktops as dedicated places for different types of apps. Safari stays on desktop 1. Coda 2 and Dash are on desktop 2. Photoshop/Illustrator/Acorn are on Desktop 3. All other apps are called up and closed as I need them, no matter what space I’m on.

It’s not a perfect scenario but I’ve found that it works for me and I have established muscle memory for switching between desktops quickly and performing tasks on the active windows with keyboard shortcuts. It’s now just the way I work.

Adding a new dual screen set up

When I started working for Webster I got a different set up. A 24″ iMac and a 23″ Cinema Display as a second monitor. Sweet, I thought, no more switching between desktops I have tons of space now. Turns out, more screen real estate just means more open windows and a huge unorganized mess. Out of habit I would use my keyboard shortcuts while doing web work to try and switch between Safari and Coda and get frustrated when I had to ⌘+ Tab 10 times to get back to the app I wanted instead.

I had tried Spaces with multiple displays before Mavericks and I was annoyed that when you switched desktops both screens would switch as one. I actually said to one of my current co-workers how much I wished that Spaces could be display independent.

I went to Mission Control in the System Preferences anyway and my heart actually leapt when I saw this screen:

Dual Screen setting in Spaces

I could now use two desktops on the newer, crisper iMac screen (for code, browser testing, Photoshop/Acorn etc) and keep the 23″ Cinema Display reserved for DayOne (time tracking), Reminders (tasks), nvAlt (text files) and any window I need as reference for the work I’m doing on the main screen. I’m really happy with this set up and I’m starting to save again for that 27″ display to use at home.

In my experience the multiple display support in Mavericks is a big set forward.

The How To Part

With two or more displays connected go to your machine’s System Preferences and click on Mission Control in the top line of icons. On that screen, ensure that “Displays have separate Spaces” is checked.

Dual Screen setting in Spaces

You can now activate Mission Control by using the keyboard shortcut specified in the lower portion of that same Mission Control settings screen (seen above). Alternatively, you can enable mouse and track pad gestures to call up Mission Control. Just visit the Mouse and Trackpad areas under your System Preferences.

Once you access Mission Control, adding new Desktops is as simple as moving your mouse towards to top right corner of the screen and clicking on the +

Mission Control

Customizing Further

The way I typically switch between my Spaces is by using a keyboard shortcut that moves me to a desktop either left or right of the one I’m currently on.

To do this:

–> go to Keyboard in your System Preferences window.
–> click on Shortcuts in the top menu.
–> Select Mission Control from the list on the left and look for “Mission Control” with an expander arrow on the right.
–> Inside that list you’ll find “Move left a space” and “Move right a space.”
–> Set up your own preferred keyboard shortcut by selecting an action from the list on the right and then clicking on the existing shortcut (it will say “none” if there isn’t a shortcut already set up.)
–> Hold down your preferred key combo and you’re in business – mine are alt + → and alt + ←

This is the guy behind the guy behind the guy.

This is a great interview with many of the people involved in the making of Swingers. I love the retelling of how the final scene with Favreau, Vaughn and the baby came together.

I was 17 when I saw Swingers for the first time. I had no idea who these actors were but I knew I wanted to be as cool as Trent or Sue. I must have watched it close to the New Year because on Jan 31, 1999 I threw on a tight white singlet, bowling shirt, suit pants and yes an extra long wallet chain and raised a toast to the ladies.

I rode the train home. At 4am. Alone. So money.

50GB of free cloud storage with new Box iOS app

I jumped on this great offer last time the promo ran and I now use Box as my cloud based photo storage drive. The new 3.0 app is a huge improvement aesthetically and photos are faster to load than in previous versions of the app.

Box works in a similar way to Dropbox or Google Drive allowing you to access files synced to your Box account from any internet connected device. It makes sharing and collaborating on files easier and has been reliable for me since I joined in 2011.

This promotion runs through Feb 15th 2014 and is a no brainer if you use an iPhone or iPad and are in need of expanded storage.

A push for in-house web teams

This post was written as a response to the Jan 9 post on boagworld: The recruitment crisis. During my procrastination to hit publish Paul has since written How to change your company to be digital first which addressed many of the sentiments I express here.

————–

I see where Paul Boag is going with this post and admittedly I would love to find a company who is willing to change their structure and culture to better suit the typically hard to employ web professional that I am. Digital is essential, Boag says, “[w]hether you are selling kitchens or raising money for cancer research” but I think it’s the disbelief in that statement that is going to make retainment of talent so difficult during this mass agency exodus.

It’s not just web professionals who crave these working environments. All employees want more control, flexibility and trust from their employers. They all want a bright and colorful office with the latest technology, an espresso machine and a few hours a week reserved for paid training or self-directed learning.

If a company gears their culture towards a small group of employees then they will alienate the rest. This creates resentment between employees and your newly hired web workers will jump ship to find more accepting coworkers or just take you up on the offer to work from home rendering all previous investments wasted.

Upon reading Boag’s post I immediately thought of a recent Slate article about creativity being rejected when it seeks to change the status quo. I imagined many a middle manager squashing a creative and potentially successful idea because they felt threatened. Threatened by the employee(s) who had the idea but mostly threatened by someone’s ability to see a solution that they didn’t. This is part of the resistance to bringing digital in-house. Employees and managers alike are wondering: if digital is the answer, does that make me obsolete?

Perhaps an improved long term strategy would be to start educating your existing staff on the importance that the web and digital hold for the future of the company. Maybe you have a few weekend geeks in your ranks already who would be cheerleaders for bringing this work in-house and who may reveal themselves to be ready for recruitment first.

If you’re serious about investing in digital and pointing your business towards success in the digital space then think about what other areas of the company can benefit from a step towards that goal. Does your accounting department like the idea of a FreshBooks-type product? Allowing them to work from home on Fridays or when the kids are sick? Maybe new iPads for your sales people will get them excited about presenting reports and product demos to potential clients again? The whole company needs to see a benefit from the shift to digital for it to be welcomed and successful.

Recruiting and retaining web professionals is easy when everyone within the company sees the value in what we do. All the items that Boag listed allow you to recruit but it’s a company-wide belief that digital and the web is important, meaningful and should be supported that will keep employees happy and loyal. That and a foosball table of course.

Fix for the slow Open-Save dialog box in OS X Mavericks

Ever since upgrading to Mavericks, Finder would get hung up opening a folder through the Open/Save/Export dialog box. Everything was still responsive but all I got was a progress spinner when clicking on a folder, no files. After 5-10 seconds every thing catches up and all folders and files are again available. That 5-10 seconds was driving me crazy though.

According to OS X Daily it’s caused by the Finder attempting to mount network drives. They have a easy to follow step by step on how to fix the bug which worked perfectly for me. You will need to fire up the Terminal to get this one done though.

IRS provides ability to download past tax returns

I have often needed to show my past tax returns when proving my income. This is really handy for those of us who are self employed and don’t have access to pay stubs or employment verification.

Of course, I haven’t successfully been able to retrieve my past returns as I’m greeted by a Technical Difficulties error every time I log in.