Highlight

2012-03-27

Quick & easy navigation.

String sql = "select name, address, zip, city, country, phone, url"
+ " from retailer"
+ " where latitude is not null and longitude is not null"
+ " order by pow(lat-lat2, 2) + pow(2 * min(abs(lon-lon2), 360-abs(lon-lon2)), 2) asc limit 10";
stmt = con.prepareStatement(sql);
stmt.setDouble(1, Double.parseDouble(request.getParameter("lat")));
stmt.setDouble(2, Double.parseDouble(request.getParameter("lng")));
Honolulu to Los Angeles and San Fransisco in Python:
>>> lat, long = (21.3069444, -157.8583333)
>>> lat2, lon2 = (34.0522342, -118.2436849)
>>> pow(lat-lat2, 2) + pow(2 * min(abs(lon-lon2), 360-abs(lon-lon2)), 2)
33839.327855007934
>>> lat2, lon2 = (37.7749295, -122.4194155)
>>> pow(lat-lat2, 2) + pow(2 * min(abs(lon-lon2), 360-abs(lon-lon2)), 2)
30952.629658700374
2 * lon is ok for latitude 45 or -45, but 1/cos(radians(lat)) is better.

2012-03-19

Hunting bugs

1. Get Sysinternals Suite.
2. Start Process Explorer and/or Process Monitor.
3. Go to Options, Configure Symbols...

DbgHelp.dll path (version 6.0 or later, not in system32; the version of DbgHelp that ships in Windows has reduced functionality from the other releases-- specifically, it lacks support for Symbol Server and Source Server.):
C:\Windows\system32\dbghelp.dll
C:\Program Files\Debugging Tools for Windows (x64)\dbghelp.dll

Symbols path(s):
SRV*I:\symbols*http://msdl.microsoft.com/download/symbols;SRV*I:\symbols*http://symbols.mozilla.org/firefox

"I:\symbols" is the location of my symbols cache; yours may differ.

2012-03-08

Making Redmine suck less

Problem: Issue importance and status are hard to see.

Solution: Install this theme and add a custom CSS rule to strike-through resolved issues. I might have a Facebook entry with more details, but can't find it.


Problem: Gantt charts should be sorted by start date instead of issue id.

Culprit: C:\Program Files\BitNami Redmine Stack\apps\redmine\lib\redmine\helpers\gantt.rb

Solution:

      # TODO: top level issues should be sorted by start date
      def gantt_issue_compare(x, y, issues)
        # Edit by Cees on 8mar12 by http://www.redmine.org/issues/7335
        [(x.root.start_date or x.start_date or Date.new()), x.root_id, (x.start_date or Date.new()), x.lft] <=> [(y.root.start_date or y.start_date or Date.new()), y.root_id, (y.start_date or Date.new()), y.lft]
        #if x.root_id == y.root_id
        #  x.lft <=> y.lft
        #else
        #  x.root_id <=> y.root_id
        #end
      end


Problem: I don't know how to restart Redmine.

Solution: Choose the applicable one here. If you use Windows and Bitnami with Redmine 1.1.2, save this text as "restart Redmine.bat" and run as Administrator:

net stop redmineMongrel1
net start redmineMongrel1
net stop redmineMongrel2
net start redmineMongrel2
pause

2012-03-02

Resizing a vmdk disk image using Oracle VM VirtualBox 4

My work PC has a small disk, thus i made a 4 GB virtual machine. After getting an external harddrive, it turned out to be hard to resize. I spent too much time to find a solution there, so i'm noting all steps here:

First power off the VMs that use the vmdk.

>"C:\Program Files\Oracle\VirtualBox\vboxmanage.exe" clonehd -format vdi "I:\VMs\X_dev\X-disk1.vmdk" "I:\VMs\X_dev\X-disk1.vdi"
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Clone hard disk created in format 'vdi'. UUID: [...]

>"C:\Program Files\Oracle\VirtualBox\vboxmanage.exe" modifyhd --resize 16000 "I:\VMs\X_dev\X-disk1.vdi"
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%