Customize different Eclipse installations with custom name and application logo

I have two separated installations of Eclipse on my mac, one is configured for Java development and one for Python. Technically I could use only one installation for both by installing all the required plugins, but I prefer to have two speparated apps! I don’t use OSX dock to gather my applications, instead I usually launch apps using Spotlight (in this way I’m able to open whatever program I need without moving my fingers from the keyboard). The “problem” is that in this way when I type “Ec…” in order to search the app to launch, is very hard to understand which is the Java configured one and which the Python one.
So, since on OSX every .app file is merely a folder containing a series of files like: the real executable program, a .plist containing application settings an .icns file and so on, it’s possible to just rename the .app file from to for example and the app will still work.
This solve the problem of Spotlight listing, but using command+tab to switch among applications would force me to move over each app in order to know its name and then choose the right one… the only effective solution is to replace the original Eclipse logo with a custom one. Fortunately this is very simple, these are the necessary steps:

  1. Use Google images to find a logo to use and download it (In my case I searched for “python logo” specifying “large” in the search option)
  2. Use the free online converter here: to turn the downloaded image into a .icns file:

    • upload the downloaded image
    • click on “options” and check only “Convert to icns icons (Mac OS X)” and “Convert to 32-bit icons” options)
    • download the generated file
  3. Use the generated file as the app icon:

    • locate your
    • right click and choose “show package content”
    • switch to Contents/Resources and place the generated .icns file here
    • switch to Contents/MacOS and in the eclipse.ini file change “-Xdock:icon=” in order to use the .icns of your choice
    • switch to Contents/ and in the Info.plist under “Icon file” do the same
    • make a copy of (command+C/command+V) to force OSX cache refresh
    • you should see “Eclipse” with the new icon and “” with the old icon
    • delete the orignal
    • rename the copy as you like
    • finish!

(if you don’t care about original icon you can simply replace it with the generated one without updating the configurations files!)
(this trick can be used to customize any mac application)

The image above is a sample screenshot showing how I have customized my Eclipse icons (the Star Wars death star is used for Java configured eclipse, the python logo for PyDev installation):


Dates and time difference in Python

The problem: you have to calculate difference between dates (days, hours, minutes, seconds or whatever) using Python.
Solution: import and use datetime and timedelta like the example below:

from datetime import datetime, timedelta

# create a new date (January 6, 2013 - 20:30)
myDate = datetime(2013, 1, 6, 20, 30)

# ok... a little date "introspection":
print('year: ' + myDate.year) # (prints "2013")
print('month: ' + myDate.month) # (prints "1")
print('day: ' + # (prints "6")
print('hours: ' + myDate.hour) # (prints "20")
print('minutes: ' + myDate.minute) # (prints "30")

# go 12 hours back from "myDate"
twelveHoursBefore = myDate - timedelta(hours=12)

# twelveHoursBefore is equal to myDate, but "hour" prints "8"
print('12 hours before, hours were: ' + twelveHoursBefore.hour) 

# go 20 minutes after "myDate"
twentyMinAfter = myDate + timedelta(minutes=20)

# twentyMinAfter is equal to myDate, but "minute" prints "50" (30 + 20)
print('20 minutes after, minutes are: ' + twentyMinAfter.minute) 

As you can see, time travel is easier in Python than in a Delorean :)

Enable custom submit button styling in Safari mobile

If you want to style a form submit button with custom size and border radius you have to “nullify” the default Safari mobile style, since differently it will be somehow “unrewritable”. I discovered that there is an handy CSS property called “appearance” which is used for native-style display of elements. With this property is possible to display special search box, cursors and so on… the reference for Safari can be found here, that one for Mozilla can be found here.
In order to remove native style is possible to set “appearance” to none, thus to enable complete custom styling of our submit buttons we can write the following CSS statement:

   -webkit-appearance: none;
   -moz-appearance: none;
   appearance: none;  

Some notes:
– vendors-specific declarations (-webkit, -moz) may be removed
– do not reset appearance for all the HTML elements (ie: “*”) or you will have to work hard to restyling complex components like select!