Hi, I'm Paul Rehkugler

... and this is my blog. When I'm not hacking away at a project, I play in the band Ship Wrecks.

Home | About | Projects | Twitter | Blog | GitHub


    Advanced Java Enums

    Using Java enums can provide more than just its surface benefits (i.e. type-safety, etc.). Enums can be used in a way to make your code more intuitive and legible.

    One of my favorite aspects of enums is using enum constructors and member-variables. For example, if you need to write code that handles different types of file processing, the most common approach would be to write code like this:

    However, a better way to write the same thing would be to use the enum constructor (private FileType()) like this to polymorphically decide which FileProcesser to use:

    3 months ago  Notes (0)

    I made this today because sometimes I get the key symbols mixed up. If you have Photoshop, make your own (psd file - 1.2 MB).

    I made this today because sometimes I get the key symbols mixed up. If you have Photoshop, make your own (psd file - 1.2 MB).

    1 year ago  Notes (0)

    Why I Don’t Work at Apple

    About a year ago, I had the opportunity to interview onsite with Apple for a QA Engineer Position. From what I understand, even though I wasn’t hired, that means I’m somewhere in the top 5-10% of graduating Computer Science students last year. They didn’t make me sign any non-disclosure agreements or anything, so here is my account of the process.

    Submitted my application and resume. My resume looked similar then to how it looks now (if you subtract the new stuff).

    About two months later I got a call and email from the recruiter at Apple, asking me if I had the time to do a quick phone screen with the manager I’d be working for. We set that up to happen a few days later.

    The phone screen was basically a 45 minute chat about my experience in college, what I’d learned, a few data structures questions. The most interesting part of the interview was a simulated troubleshooting session with the manager. He asked me what I would do if I was going to test iChat between two computers that were connected to the internet, but for some reason the iChat wasn’t working. Our simulation went something like this:

    Me: Start by testing the internet connection; load google.com.

    Him: Google.com loads fine for that computer.

    Me: Test the other one.

    Him: It works there too.

    Me: Verify that the iChat servers are running; if they are hosting any HTML pages, try to load an HTML page.

    Him: Those servers are dedicated, they don’t have any HTML pages.

    Me: Try to contact the admins of that server to see if there are any problems.

    Him: They aren’t owned by Apple, so there is no way of knowing whether they are up or down.

    Me: Use a packet sniffer to examine the packets leaving your computer to ensure that iChat is sending packets.

    Him: The packet sniffer shows that iChat is sending packets.

    Me: Consult the documentation to ensure that the packets are well-formed.

    Him: The libraries we use aren’t Apple-maintained; we have no way of knowing how the packets are supposed to look.

    Me: Well, I’m stumped.

    Him:  Yeah, I wouldn’t really know where to go from there either.

    After that, I went on to a second phone screen with someone who would be my eventual co-worker (a QA engineer). She asked similar questions to the manager, primarily data structures and algorithms. Here is a question that took up most of the focus of the interview:

    Her: Suppose you have to write a function that accepts an array of integers and a number; it returns true or false for whether any two numbers in that array add up to equal the number passed in. How would you do it?

    Me: I guess there’s a fast way and an easy way; the only thing that comes to mind at the moment is the slow way which is to do a nested loop and try all possible addition combinations.

    Her: Okay, so what would be the runtime complexity for that?

    Me: O(n^2)

    Her: So are there any ways you can think to optimize it?

    Me: I guess you could short circuit processing and quit as soon as the first pair was found; then O(n^2) would only be the worst-case processing time.

    Her: Anything else?

    Me: (pause) If you sort the array, you don’t have to loop through all of the numbers; you can just calculate the number you need (based on the first number and the sum you are looking for) and then search to see if it exists.

    Her: How would you sort it?

    Me: In ascending order. I would use a sort that is fast; something that has log(n) time, maybe bubble sort?

    Her: You mean quick sort?

    Me: Yup. And then use a binary search to see if the second number exists.

    Her: So what would be the runtime complexity for something like that?

    Me: Hmm… That’s a bit harder. (pause) I guess it would be O(log(n)) for the sort, then O(n*log(n)) for the search. So O(n*log(n)).

    Her: Are there any other optimizations you can think of?

    Me: Nope.

    Her: Well you could use a hash table to make it O(n).

    Me: Oh, I either didn’t learn that or forgot it.

    After that I got an offer from my current job, so I contacted the recruiter. He called me back an hour later to ask if I was still interested in the Apple position; I said I was, so he said he would talk to the team that interviewed me to see if he could speed things up.

    Apparently my second phone screen was sufficient, because Apple was willing to fly me out for an interview three days later. I told them I had school things I couldn’t miss, so we rescheduled for ten days later.

    This was my first time on a plane (it was more fun and less terrifying than I expected), and I made it to San Jose Airport around 10:30PM (Pacific Time). By the time I picked up my rental car and drove to my hotel, it was about 12:30AM. And for some reason, my body was still on Eastern Time so I woke up at 5:30AM - probably due to anticipation-induced adrenaline.

    Here is the car Apple rented for me, in the parking lot of the hotel:

    Apple Rental - Lime Green Ford Fusion

    I got to 1 Infinite Loop around 9:30; my interview was at 10. Parking was horrible. They have a receptionist whose job is basically to tell everyone to sign in using one of the computers in the lobby.

    Here is the sticker that the computer printed for me:

    Apple Visitor Sticker

    The format for the day was that I would interview with 12 people in groups of 2 for 45 minutes each from 10AM to 4PM, with a lunch break from 12:15 to 1. Intense stuff!

    The first group was with my potential manager and someone was a Software Engineer in the group. They basically asked me about stuff from school and to explain one of the biggest projects I’ve worked on.

    The second group was with that manager’s manager’s manager (two or three steps down from Steve Jobs) and the project manager in charge of the project I’d be working on. They asked me about my preferred management style, and then gave me a programming challenge. I was supposed to think out loud as I worked on the solution, so they could see how my brain worked. Here was the problem:

    Write a function that takes two integers; one represents an hour hand and one represents a minute hand on a clock. The function returns the smallest angle between the two hands.

    The solution isn’t terribly difficult if you realize these things:

    1. There are 12 hours on a clock face, and 360 degrees on a clock face. You can calculate the angle for a particular hour by taking the hour * (360/12).
    2. There are 60 minutes on a clock face and 360 degrees on a clock face. You can calculate the angle for a particular minute by taking the minute * (360/60).
    3. The hour hand moves between hours as the minutes tick by. You can calculate the degree offset per minute of the hour hand by taking the minutes * ((360/12)/60).

    After that, it’s basically a geometry problem to make sure you have the smallest angle, and a programming problem to make sure you define that angle as something in the range [0, 360).

    I don’t remember much from the other sets of people; some of them treaded over the same ground, but for the most part it seemed as though the interview was very well planned out: each person asked about certain types of things. I got stumped a bit on a few QA-related questions, which is most likely why I didn’t get hired; I thought I fared pretty well for most of the interview.

    However, I do remember that the lunch was absolutely amazing. Apple has an excellent cafeteria (and free apples, duh - I thought that was funny). I thoroughly recommend it. Also, their campus is really cool and well manicured. The manager told me that all their landscaping is done at night; that seems to fit the Steve Jobs persona I have envisioned in my head.

    My interview ended right around 4PM with a chat with the recruiter; he asked me basic recruiter-type stuff and told me that he’d be in touch really soon (possibly that day) with a response.

    I headed back to my hotel, called my parents and girlfriend to tell them how cool California was, and fell asleep around 8PM.

    I woke up, ate some food, drove route 101 in rush hour (Bay Area rush hour is absolutely insane), and flew home.

    Here is a picture of me eating a bagel before my treacherous rush hour journey:

    Paul Eating A Bagel

    I didn’t hear a definite answer back from the recruiter for a couple days; he responded that the team was meeting and discussing my interview a few times. I like to think they were on the fence about me for a while.

    I found out I didn’t get the job and I took my other offer. MUMPS sucks. Moral of the story: don’t accept a job doing MUMPS programming because you didn’t get hired at Apple.

    1 year ago  Notes (1)

    Setting Up my new MacBook Pro

    So I learned a few interesting things while setting up my new MacBook Pro today. The main problem that I have with Apple’s automatic copying is that sometimes I don’t want to copy all the junk off my old computer; I just want the important stuff (iCal, Mail, iTunes).

    I figured out how to copy only those things; this can be pretty handy, so I thought I’d share. Just as a precursor to this post, if you don’t feel comfortable messing around with preference files or if you’ve never looked inside the /Users/username/Library directory, you might want to think twice before you try this. Also, it should be known that I was using OS 10.7 for both machines. I don’t know the implications of trying this between operating systems; some preference files or directory structures could change.

    First, it almost seems too intuitive, but connecting your two computers together with a cat 5 cable will allow them to interact as though they were on a local network; the computers show up as network machines. I expected I would have to go through a router, but that is not necessary.

    Getting all of my iCal calendars to sync via iCloud wasn’t working properly; only a few of them were showing up. To copy my iCal calendars, I closed iCal, deleted ~/Library/Calendars off my new computer, and copied over ~/Library/Calendars from my old computer to the new one. I also replaced the following files in ~/Library/Preferences:

    Then I opened up iCal and all my old calendars were there - magic!

    I didn’t even try to get Mail to work; I just went straight to the copying approach. The following folders looked relevant:

    I deleted those folders off my new computer, and copied over the folders from my old computer. I also replaced the following files from ~/Library/Preferences:

    All of the mail in my inbox was there when I opened up Mail; the only problem I had (and it’s not really a problem) was that my email passwords weren’t in the OS X Keychain. I just had to provide the password for my various email accounts.

    I managed to get iTunes to work by simply replacing the contents of my ~/Music folder. iTunes will verify the library when you open it up. If you have any devices that sync with your iTunes wirelessly (I have my iPhone), you need to plug them into your new computer in order to set up wireless syncing.

    Okay - that should be all you need to copy over the essentials to your new Mac.

    1 year ago  Notes (0)

    Since everyone keeps asking. This is Paul covering Album of the Year by the Good Life.

    1 year ago  Notes (2)

    Better EP - Pay What You Want

    shipwrecksmusic:

    We wrote this EP during an effort to strengthen ourselves emotionally and improve ourselves personally. This time of year, many people make resolutions to make this year better than the last; we hope this EP can have the same effect on your life, and possibly intervene in a time when you are thinking of giving up on those resolutions. That’s why we’re now offering it as a pay-what-you-want download. Get better.

    My band, for free. Get it.

    1 year ago  Notes (2)

    ‘11 Top Ten

    1. Bon Iver, Bon Iver - Bon Iver
    2. The People’s Key - Bright Eyes
    3. Parting the Sea Between Brightness and Me - Touché Amore
    4. Civilian - Wye Oak
    5. Empty Days & Sleepless Nights - Defeater
    6. Ghost Town - Owen
    7. Helplessness Blues - Fleet Foxes
    8. Between the Concrete and Clouds - Kevin Devine
    9. CAMP - Childish Gambino
    10. Proper - Into It. Over It.

    1 year ago  Notes (0)

    jesuisperdu:

    Bon IverBeth/Rest (piano version)

    This is so good.

    (via fuckyeahemo)

    1 year ago  Notes (453)

    Finally up and running!

    Finally up and running!

    1 year ago  Notes (4)

    I’ve been getting this any time I install anything… I’m gonna keep thinking it’s benign.

    I’ve been getting this any time I install anything… I’m gonna keep thinking it’s benign.

    1 year ago  Notes (1)

    Let’s hope this installation of Xcode 4.4.1 works this time…
I just did one of these: sudo /Developer/Library/uninstall-devtools —mode=all
And re-installed using “Install Xcode” from LaunchPad… Who uses LaunchPad anyway? (Quicksilver is better)

    Let’s hope this installation of Xcode 4.4.1 works this time…

    I just did one of these: sudo /Developer/Library/uninstall-devtools —mode=all

    And re-installed using “Install Xcode” from LaunchPad… Who uses LaunchPad anyway? (Quicksilver is better)

    1 year ago  Notes (1)

    fuckyeahemo:

Nerd genius

aw… = cos b… rad

    fuckyeahemo:

    Nerd genius

    aw… = cos b… rad

    1 year ago  Notes (3998)

    ← Older   1/13