Archive

Archive for the ‘Computers’ Category

Syncing Gmail Contacts Birthdays and Events with Google Calendar

May 10th, 2011 No comments

I am horrible with other people’s important dates, e.g., birthdays, anniversaries, date you got your appendix removed, etc.

I just realized I should put all that info into my Gmail Contacts, and then it will appear on my Google Calendar automatically. Oh wait… It doesn’t show up. Damn. Why doesn’t it work?

Turns out, this obviously valued feature is not turned on by default, but it is available.  To get your contacts’ birthdays and other events to show up, simply perform the following in Google Calendar:

Click Settings (the little gear icon in the upper right corner of the screen), then Calendars (link just under the "Calendar Settings" tab), then the Browse Interesting Calendars (lower right) link, then More (under the heading), and finally Subscribe next to the Contacts’ birthdays and events.

Fantastic!  Now you, and more importantly, I should have no reason to forget to remind our friends and family a Happy Birthday.

Code Review Does Not Have to Suck

February 24th, 2011 No comments

I have been using this saying for the last 6 years, “Code Review Does Not Have to Suck”.  I just saw today that SmartBear, who makes the wonderful CodeCollaborator peer code review tool, which I also use, released a quick 3-minute video explaining this.

Peer code review is a critical milestone step in any good development process; especially with distributed teams.  CodeCollaborator, Crucible, and Kiln are all great tools for facilitating peer code review without having to go through all the headache of gathering files, scheduling meetings, pissing off your co-workers, etc.

Check out the video.  It’s worth the 3-minutes.

Dell 3115cn Multi-Function Color Laser Toner

February 22nd, 2011 No comments

We have a Dell 3115cn color laser printer at work.  The color toner cartridges are individual, and we buy them in these multipack deals (Dell Part #4BC3115).  The problem is that inside the box are four cartridges wrapped in that silver foil packaging and are not marked as to which color is inside.   You never have to replace all four cartridges at once, so it becomes a lottery scratcher to find the cartridge you need.

Each cartridge does have a unique part number on it, but Dell’s website has nothing, nor Google, nor Bing, and Wolfram Alpha politely told me to piss off.  For future reference, I am writing down the individual codes and the color cartridge it corresponds to.  Hopefully the search bots will pick up this post and save other owners of the 3115cn the same hassle.

I did figure out after decomposing the product numbers, that the important part is after the ‘CN-0′ bit at the beginning.  For example, if you Google PF028, you should get a link to Staples website for the Black cartridge.  Using the corresponding string section from the other cartridges yields the correct results as well.

Black: CN-0PF028-71971-958-3080

Yellow: CN-0NF555-71971-95D-7143

Magenta: CN-0MF790-71971-95D-1978

Cyan: CN-0RF012-71971-95D-8088

How to Design a Good API and Why It Matters

February 4th, 2011 No comments

I am starting to design a new API for an application that will need to integrate with other applications.

Before doing so, I always make it a point to re-watch and re-read this presentation given by Joshua Bloch from Google.  Joshua does a fantastic job going over the DOs and DON’Ts of good API design.

 

Joshua Bloch Presentation on API Design

 

You can also download the slides here.

To root, or not to root

December 6th, 2010 No comments

To root, or not to root: that is the question:

Whether ’tis nobler in the mind to suffer

The crap of HTC is not outrageous fortune,

Or to take arms against a sea of useless apps,

And by opposing end them? To root, to be free;

No more; and by freedom to say we end

The heart-ache and the thousand worthless apps

That cannot be uninstalled, ‘tis unavailable option

Devoutly to be wish’d. To root, to be free:

To freedom, perchance to control: ay, there’s the rub:

For that freedom of rooting what mistakes may come

When we have removed the controls in place that make us mortal,

Must give us pause; there’s the respect

That makes calamity of superuser privs;

For who would bear the segfaults and core dumps of time,

The oppressor’s wrong, the geek’s contumely,

The prags of despised garbage-ware, the sudo’s delay,

The insolence of Footprints and the Peep

That patient merit of the unworthy takes,

When he himself might his rm –rf make

With a bare sudo? Who would fardels bear?

To grunt and swear under a weary life,

But that the dread of something after root,

The undiscover’d access from whose bourn

No n00b returns, puzzles the will

And makes us rather bear those typos we have

Than make other that we know not of?

Thus conscience does make cowards of us all;

And thus the native hue of resolution

Is sicklied o’er with the pale cast of thought,

And enterprises of great pith and moment

With this regard their currents turn awry,

And lose the stability of my phone. – root you now!

The fair Incredible! Fantastic, in thy orisons

Be all my sudo remember’d.

(from Hamlet 3/1 – slightly altered by Eric Silva)

iTunes Ping

September 16th, 2010 No comments

I just recently started using iTunes Ping, and my first impression was ‘Facebook/Twitter for Music’; pretty neat.  If you have friends on Ping, then you can follow them, and see what they are listening to and/or interested in.  Finding your ‘actual’ friends is pretty easy, since you know there name and often times e-mail, but finding the ‘real’ artists is another matter.  Apple apparently didn’t learn or pay attention to the problem Twitter had a few years ago when it started: fake accounts.  Another neat feature of Ping, is for actual artists to promote other artists.  If you like Trent Reznor or Paul van Dyk, you might want to follow them and see what they are listening to.  But in the event you pick the wrong account, or perhaps the artist doesn’t even have an ‘official’ Ping account, then all you end up doing is following some asshat douchebag who thought he would create an account using the name of an actual artist.

I think the ‘verified’ or ‘official’ account identifier that Twitter put in place should be Enhancement #1 on the Ping backlog.  I’m still liking the service, and will continue to use it, but I’ll stay away from following artists until this gets resolved.

Really Slick OpenGL Screen Savers

July 15th, 2010 No comments

Tired of the boring screen savers that come with Windows and haven’t changed since Windows 3.1?  Take a look at Really Slick Screensavers for some cool OpenGL savers available for Windows, Linux, Solaris, or Mac OS X.

Greenshot – free screenshot tool

July 13th, 2010 No comments

After using SnagIt for several years with my old company, I was in need of an open source replacement.  After using everyone’s favorite research assistant, I found Greenshot.  It doesn’t have all the bells and whistles that SnagIt has, but it has the basics which is what you use 80% of the time anyway.

So far, so good.  If you are need of a good screenshot/capture tool, and don’t feel like forking over $50 for a SnagIt license, check out Greenshot.

Simple Calendar Control for Web Application

March 19th, 2010 No comments

I originally did this back in 2007, but did not want to lose the content, so I decided to put it up here.

I found a robust and relatively simple calendar control to use for web UIs. It can use a pop-up window or a floating <div> tag. I prefer the latter as it makes the page look good and avoids a pop-up.

To use the control simply put the CalendarPopup.js file in your application’s “scripts” directory and be sure to include it in your JSP. (I used this in a Java app, but you can apply it to any language.)

Download the and put it in your images directory.

Add the following lines to your application’s JavaScript file (or include on the same page if you don’t have an external JS file):

// Set up Calendar control
var calObj = new CalendarPopup("calDiv");
calObj.showNavigationDropdowns();
calObj.setMonthNames('JAN','FEB','MAR','APR','MAY','JUN','JUL','AUG','SEP','OCT','NOV','DEC');

// Handle the Calendar control
function doCalendar(destObjId, srcObj) {
    calObj.select(document.getElementById(destObjId),srcObj.id,'dd-MMM-yyyy');
}

Then add the following lines to your JSP:

<script>document.write(getCalendarStyles());</script>

In your JSP, add the following HTML code where you want your date field and calendar control:

<input id="dateField" style="width: auto;" maxlength="11" name="actualDate" size="25" type="text" />
<img id="imgCal" onclick="doCalendar('dateField',this);return false;" src="cal.gif" border="0" alt="" />

That’s it!

In order to workaround IE 6′s inability to recognize the z-index attribute on the tag, I made some modifications to the original JavaScript code. You will need to pass the an ID value to be used for the hidden that will overlay the box.

var calObj = new CalendarPopup("calDiv", "calFrame");

You will also need to specify the following styles in a stylesheet. The ID values in the stylesheet must match the names of your DIV and IFRAME IDs on your page.

div#calDiv {
    position:absolute; visibility:hidden;
    background-color:white;
    layer-background-color:white;
}
.select-free {
    position:absolute; z-index:10;/*any value*/
    overflow:hidden;/*must have*/
    width:152px;/*do not change value for calendar control */;
}
.select-free iframe#calFrame {
    display:none;/*sorry for IE5*/
    display:block;/*sorry for IE5*/
    position:absolute;/*must have*/
    top:0;/*must have*/
    left:0;/*must have*/
    z-index:-1;/*must have*/
    filter:mask();/*must have*/
    width:3000px;/*must have for any big value*/
    height:3000px/*must have for any big value*/;
}

Your JSP now needs the following line:

<div id="calDiv" class="select-free"></div>

Primality Test v2.0

December 14th, 2009 No comments

After feedback from some friends of mine, and doing a little bit of background research, I am writing this update to my original post last week.  As it turns out, by checking all the numbers in the form 6k ± 1 \scriptstyle{}\leq\sqrt n instead of checking each number up to the input value, I have increased the speed by 7 times! determineIsPrime3 (line 48 below) is the fastest algorithm so far.  determineIsPrime2, a simple comparision against the \scriptstyle\sqrt n, was twice as fast as the original algorithm.

For now, I am putting this one to bed.  It was a fun exercise, but I have got what I need from it.

'''
Checks the specified value to determine if it is a prime number.
If it is not prime the divisor will be returned instead.

@author: Eric Silva
'''

import math, time

#Change this value to whatever value you want to test for prime.
#testValue = 65027
#testValue = 155188329701
testValue = 99194853094755497
#testValue = 10888869450418352160768000001
print 'Testing %d...' % testValue

def determineIsPrime(testPrime):
    if testPrime % 2 == 0:
        return 'Divisible by 2'
    if testPrime % 3 == 0:
        return 'Divisible by 3'
    testNum = 7
    testLimit = testPrime
    while testLimit >= testNum:
        if testPrime % testNum == 0:
           return 'Divisible by %d' % testNum
        testLimit = testPrime/testNum

        testNum = testNum + 2

    return '%d is prime!' % testPrime

def determineIsPrime2(testPrime):
    if testPrime % 2 == 0:
        return 'Divisible by 2'
    if testPrime % 3 == 0:
        return 'Divisible by 3'
    testNum = 5
    sqrt = math.sqrt(testPrime)
    while testNum <= sqrt:
        if testPrime % testNum == 0:
           return 'Divisible by %d' % testNum

        testNum = testNum + 2

    return '%d is prime!' % testPrime

def determineIsPrime3(testPrime):
    if testPrime % 2 == 0:
        return 'Divisible by 2'
    if testPrime % 3 == 0:
        return 'Divisible by 3'
    testNum = 7
    sqrt = math.sqrt(testPrime)
    while ((6 * testNum) + 1 <= sqrt) or ((6 * testNum) - 1 <= sqrt):
        if testPrime % testNum == 0:
           return 'Divisible by %d' % testNum

        testNum = testNum + 2

    return '%d is prime!' % testPrime

startTime = time.time()
result = determineIsPrime(testValue)
endTime = time.time()

print result
print '1. Calculation took %f s\n' % (endTime - startTime)

startTime = time.time()
result = determineIsPrime2(testValue)
endTime = time.time()

print result
print '2. Calculation took %f s\n' % (endTime - startTime)

startTime = time.time()
result = determineIsPrime3(testValue)
endTime = time.time()

print result
print '3. Calculation took %f s\n' % (endTime - startTime)

Results:

Testing 99194853094755497...
99194853094755497 is prime!
1. Calculation took 202.609000 s

99194853094755497 is prime!
2. Calculation took 114.813000 s

99194853094755497 is prime!
3. Calculation took 28.781000 s