How To Add Time In Excel Or Numbers

June 19th, 2009

This one had be going for a while the other day. I had a cell with a time in it, and just wanted to add 15 minutes to it and place it in the cell next to it. Anyway, the way to do this is to add (or subtract) #Minutes/1440.

For example, if cell A1 has the time 6:15 in it, and you want to add 15 minutes to it for cell A2 simply set it =A1+(15/1440).

The reason for this is that Excel (and Numbers, and.. most likely any other spreadsheet software out there) keeps track of dates, not time - so if you have a date of 6/19/2009, and in the next cell you want 6/20/2009 - you add 1. Well, there are 1440 minutes in a day, so you simply have to add a fraction of a day equal to the amount of time you want to add. So 15/1440 = 0.0104166667 days.

Jonathan Laliberte Uncategorized

Restore Previous Display Window Positions AppleScript

February 4th, 2009

This AppleScript is sort of a hack to restore window positions after removing/adding an external display, similar my other script to move all windows to the main screen. You should run it before you disconnect the display, then again when you reconnect it. It’s customized for my environment right now, so you’ll need to look through the code a bit to customize it. I have this saved as an application in my Applications folder for quick launching with Spotlight.

property numFFWindows : 0
property FFPos : {}
property FFSize : {}
property iTunesPos : {}
property iTunesSize : {}
property iCalPos : 0
property iCalSize : 0
property AdiumContactsPos : 0
property AdiumContactsSize : 0
property AdiumIMSize : 0
property AdiumIMPos : 0
property OFPos : 0
property OFSize : 0

display dialog "Set Window Position or Save Window Position?" buttons {"Restore", "Save"} default button "Restore"
set theResult to result

tell application "System Events"
    if (button returned of theResult is "Restore") then
        -- Restore Settings
        if (numFFWindows > 0) then
            tell process "Firefox"
                repeat with i from 1 to numFFWindows
                    set position of window i to (item i of FFPos)
                    set size of window i to (item i of FFSize)
                end repeat
            end tell
        end if
        if (iTunesPos is not {0, 0}) then
            tell process "iTunes"
                set position of window 1 to iTunesPos
                set size of window 1 to iTunesSize
            end tell
        end if
        if (iCalPos is not {0, 0}) then
            tell process "iCal"
                set position of window 1 to iCalPos
                set size of window 1 to iCalSize
            end tell
        end if
        if (OFPos is not {0, 0}) then
            tell process "OmniFocus"
                set position of window 1 to OFPos
                set size of window 1 to OFSize
            end tell
        end if
        if (AdiumContactsPos is not {0, 0}) then
            tell process "Adium"
                set position of window "Contacts" to AdiumContactsPos
                set size of window "Contacts" to AdiumContactsSize
                repeat with i from 1 to (count windows)
                    if ((window i) is not (window "Contacts")) then
                        set position of window i to AdiumIMPos
                        set size of window i to AdiumIMSize
                    end if
                end repeat

            end tell
        end if

    else
        -- Save Settings
        tell process "Firefox"
            set numFFWindows to count windows
            set FFPos to {}
            set FFSize to {}
            repeat with i from 1 to numFFWindows
                set end of FFPos to (position of window i)
                set end of FFSize to (size of window i)
            end repeat
        end tell
        tell process "iTunes"
            set iTunesPos to position of window 1
            set iTunesSize to size of window 1
        end tell
        tell process "iCal"
            set iCalPos to position of window 1
            set iCalSize to size of window 1
        end tell
        tell process "OmniFocus"
            set OFPos to position of window 1
            set OFSize to size of window 1
        end tell
        tell process "Adium"
            set AdiumContactsPos to position of window "Contacts"
            set AdiumContactsSize to size of window "Contacts"
            set AdiumIMPos to {}
            set AdiumIMSize to {}
            repeat with i from 1 to (count windows)
                if ((window i) is not (window "Contacts")) then
                    set AdiumIMPos to (position of window i)
                    set AdiumIMSize to (size of window i)
                end if
            end repeat
        end tell
    end if
end tell

Jonathan Laliberte Apple, Hacks, Mac OS X, Scripts

College Ramblings…

December 31st, 2008
My Bachelors Degree in Computer Science

My Bachelors Degree in Computer Science

(I have a bunch of posts I have started but not finished. So I’m going to start posting them. Some of them may not best, but I’d like to get them cleared out. Here’s my oldest post - draft dated 10/16/2007, finishing it up today.)
Please Note: This is a rambling.

So I have my Bachelors degree in Computer Science. This is great, but my thoughts about it really boil down to this: big deal. I have learned a decent amount throughout college in regard to my major, no doubt about it. But I believe I have missed many more opportunities in the process such as:

  • (Indie) Software development
  • Other Business - this is sort of a big list

I really have not progressed in my knowledge of OS X specific development, even though I finished my BS 1.5 years ago. I can blame many, many things for this, and a post about this is coming up soon. The biggest loss here I think is lost experience-time on the platform. If I am not able to make it on my own with OS X software development, I’d at least like to work for a Mac software company. I have done some development on Windows, but at school and at EMC I work exclusively on Linux. In terms of business development, I’ve made only moderate gains where I believe larger gains should be possible, as well as let a few entire business ideas not see the light of day because “I don’t have time”.

My biggest gains from going to college:

  • Friends/Contacts
  • Ideas
  • Some maturation(I’ve been told this is disputable though)
  • It was fun… Lots of fun
  • I learned a few things too
  • I don’t plan to expand on this too much. I am happy I went to college, and to have earned my degree. That being said, I just sometimes wish I had been able to spend my time on other things. I believe many of the required courses outside of my major were a HUGE waste of my time. You can give me the “it makes you a well rounded person” BS all you want, but I believe a dedicated course on “Software Engineering” or “Debugging and Performance Optimization”, beats out “Philosophy in Film” in terms of usefulness by a nearly infinite amount. Or how about a course I would have loved: “Mac OS X Software Development” - I tried to do this as a directed study for a project sequence in late 2007, alas the proposal fell on deaf ears and I instead went with “Internet and Web Systems” (read: HTML, CSS, and JavaScript, you know things I had been doing since I was 13).

    Yada, Yada, Yada

    The experiences and friends gained throughout my college years are priceless to me (Should I count the student loans?) - and having the degree looks good on the resume if I need it. I hope I don’t though, I don’t believe that I am meant to be a 40+hr/week worker. I love running my own business(es) and hope to continue to do so. I look forward to sharing my escapades in starting a few new ones with everyone this year. Here’s to 2009.

Jonathan Laliberte Education, Life, Mac OS X, Personal, Rambling

Just A Heads Up

November 17th, 2008

Photo 63.jpg

I have a few draft posts getting finished up over the next few weeks. I’m considering switching this domain to mainly personal material, but with some tech commentary. Furthermore I may launch a new blog with the goal of keeping up with some other projects I’ve been working on. That is really here-nor-there for now, I just felt like posting.

Jonathan Laliberte Personal

OS X Memory Issues

October 13th, 2008

With Activity Monitor and the Finder open, and, a few background apps (Remote Buddy, Proxi, and PTHPasteboard). I had just closed all other apps: Mail, FireFox, iTunes, PandoraBoy, Adium, iCal, probably a few others.

With 3GB Physical RAM in this system, I was left with 750MB free:
memoryleaks.png

This, is no good.

Update (12/29/09): I finally googled this, no idea why I waited so long. Anyway, Mac OS X: Reading system memory usage in Activity Monitor.

Jonathan Laliberte Bugs, Mac OS X

MacBook Pro Riser

October 11th, 2008

For about $8 I made the equivalent to the Griffin iCurve/Elevator with PVC pipe.

Original idea was from Instructables. I adjusted for size of the MacBook Pro, and used 1/2″ instead of 3/4″ PVC. 3/4″ seemed far too heavy duty for this.

If you want to make one for your 15″ MacBook Pro I recommend using 1/2″ PVC.

You’ll need the following pieces:

  • 2x 11″
  • 4x 5 1/2″
  • 2x 3″
  • 4x Elbow Joints
  • 4x T-Joints

Assembly is pretty simple. I actually did it right in Home Depot in about 10 minutes.

IMG_1030.jpg

IMG_1031.jpg

Jonathan Laliberte Hacks

Make Everyday The Middle Of The Week in iCal

September 8th, 2008

I prefer using iCal in “Weekly” view mode. My problem with this mode though is that once you get towards the end of the week, you will not see what is coming up the next day(s) without explicitly switching to the next week - surely we can fix this?

What I wanted was to be able to see today, maybe the day before, and the next 5 days. After all, the past 6 days is seldom useful, but it’s nice to know what is happening the next 3-5 days.

This script will do this for you. It does so by changing the “Start Week On” preference in iCal everyday at midnight.

To reiterate, my preferred setting is to have the SECOND day of the week be TODAY. If you’d prefer another day, change the number 5 in the script below(4 = 1st day, 5 = 2nd day, etc).

The Applescript to perform this is:

-- Quit iCal if it is open
tell application "System Events" to set isiCalOpen to count ¬
	(every process whose creator type is "wrbt")
if (isiCalOpen is 1) then tell application "iCal" to quit

-- Make the change
do shell script ¬
	"defaults write com.apple.ical \"first day of week\" -int " & ((((weekday of (current date)) as integer) + 5) mod 7)
delay 2
-- Open iCal
tell application "iCal" to activate

Open in Script Editor

If you’d like to have this script run everyday, you may want to check out the excellent Launchd editor, Lingon. My LaunchAgent file can be downloaded here: iCal LaunchAgent.

Jonathan Laliberte Mac OS X, Scripts, iCal

‘batch’ broken in Mac OS 10.5 (Leopard)

May 14th, 2008

Give it a try and let me know if you agree… Quick test:
$ batch now
> ls
[control-d]
job 1 at Wed May 14 14:02:27 2008

$ atq
778240 Fri Jan 18 09:03:00 2002

———-

$ batch 17:00
> ls
[control-d]
job 5 at Wed May 14 17:00:00 2008
$ atq
778240 Sat Jul 17 12:39:44 1993

Update: 10.5.3
This doesn’t seem to happen anymore in 10.5.3, but it doesn’t quite seem to work either:

$ at 3:00
> touch /TEST.TEST
job 10 at Sun Jun 1 03:00:00 2008

This was ran at 2:59:30(or so) and as of 3:45:
$ atq
10 Sun Jun 1 03:00:00 2008

Yet, the command did not execute.

Jonathan Laliberte Apple, Bugs, Mac OS X

Calculating Actual Hard Disk Space…

December 18th, 2007

If under 1TB in size simply calculate: (Advertised size in GB) * 0.931
Or, to be exact: (Advertised size in GB * 10^9)/1024^3 should do the trick…

Over one TB you can not just assume 1TB = 1,000GB since the advertising calculation is in base 10, and this crazy device in front of you prefers base 2… So:
Over 1TB calculate: (Advertised size in TB) * 0.909
Once again, to be precise: (Advertised size in TB * 10^12)/1024^4.

Jonathan Laliberte Clarifications, Storage

Move All Windows To Your Main Screen…

October 19th, 2007

ApplescriptSo, you’ve got more than one screen? Life is good with all that wonderful screen real estate, then BAM… You end up back with just your main screen, but your applications have left their windows on those other displays, far out of your reach…

Let’s fix that. This little script simply goes and tells all of your applications to get their act together, to move their window’s to the main display.

You’ll need access for assistive devices turned on, which you can do by going in to System Preferences, Universal Access. At the bottom check the box for “Enable access for assistive devices”.

As it is, the script will tell all applications currently running, that if they have a window that is entirely on the main display - to move it to the top left of the screen.

You may have some applications which keep windows off screen on purpose, if you experience any strange behavior with these applications you can exclude them from the applications which get checked by adding their name to the “processesToIgnore” list at the top of the script. There is an example to show how the list should look in the comment right above it. Be sure to use the exact name of the application.

Lastly, if you have more then one display attached when this script is ran it will basically do the same thing, but windows on other screens will not be moved to the main display, only windows outside the range of all current displays.

Jonathan Laliberte Scripts