Monday, 19 December 2011

Guardian: Voices of Finance article

http://m.guardian.co.uk/commentisfree/2011/dec/12/voices-of-finance-it-consultant-developer?cat=commentisfree&type=article

The environment described by this developer sounds very familiar to
anyone who's worked practically *anywhere*. :(

Wednesday, 9 November 2011

Senseless corporate doublespeak sample #001

Original text:

"Through these discussions, we have also identified opportunities to
change the role of PC&S in ways that will better support the execution
of the IT strategy. By specifically leveraging the discipline and
framework of the SMO, as well as accelerating the decision to combine
this function with the PMO function, we can focus on our sourcing
strategy and continue the emphasis on agile roll out and our people
leadership program."

What I think it means:

This role will be abolished. Some of its functions will be done by someone else.

Wednesday, 19 October 2011

Steve Jobs on customer experience (WWDC 97)



(the quote starts from 1:55)


You've got to start with the customer experience and work backwards to the technology. You can't start with the technology and try to figure out where you're gonna try to sell it.
...
It started with "What incredible benefits can we give the customer? Where can we take the customer"? Not starting with "Let's sit down with the engineers and figure out what awesome technology we have and how are we gonna market that?" And I think that's the right path to take.



Thursday, 13 October 2011

Note to self when using java regex - always call Matcher.matches() so that text matching actually happens

The general pattern of usage is:

1. regexString = [REGEX]
2. final Pattern p = Pattern.compile(regexString);
3. final Matcher matcher = p.matcher(text_to_match);
4. matcher.matches() 


DO NOT FORGET to call Matcher.matches().

Otherwise you will get messages like:

java.lang.IllegalStateException: No match found
at java.util.regex.Matcher.group(Matcher.java:468)

and you'll be wondering why because you have confirmed that the regex itself is correct. (http://www.fileformat.info/tool/regex.htm and http://rubular.com/ are useful tools for doing this quickly)

REMEMBER: call .matches() so that our Matcher actually performs the matching!

Just wasted 10 minutes wondering what I was doing wrong.


Tuesday, 13 September 2011

Use Windows path separators if you're using the JDK keytool in Windows - backslash "\" not forwardslash "/"

This error "keytool error: java.io.IOException: Keystore was tampered
with, or password was incorrect" may not really mean a password or
keystore problem.

Here's my story:

Kept trying various passwords to add a certificate to my JRE CA using
this command:

./keytool.exe -v -alias certalias -import -file <DomainRootCA>.crt
-keystore ../jre/lib/security/cacerts

And I kept getting

keytool error: java.io.IOException: Keystore was tampered with, or
password was incorrect
java.io.IOException: Keystore was tampered with, or password was incorrect
at sun.security.provider.JavaKeyStore.engineLoad(JavaKeyStore.java:771)
at sun.security.provider.JavaKeyStore$JKS.engineLoad(JavaKeyStore.java:38)
at java.security.KeyStore.load(KeyStore.java:1185)
at sun.security.tools.KeyTool.doCommands(KeyTool.java:715)
at sun.security.tools.KeyTool.run(KeyTool.java:172)
at sun.security.tools.KeyTool.main(KeyTool.java:166)
Caused by: java.security.UnrecoverableKeyException: Password verification failed
at sun.security.provider.JavaKeyStore.engineLoad(JavaKeyStore.java:769)
... 5 more

I tried various passwords. My usual default passwords. "changeit" -
which is usually default for these certs. Nothing worked.

Then remembering how bad these java exceptions are, I changed the
keystore parameter, to see if it would complain about not seeing the
file.

Just remove the "s" from "cacerts"

[everything to the left of this is still the same] -keystore
../jre/lib/security/cacert

And still got the same error. Bloody JDK! So maybe it was failing
because it couldn't find the file, but it wasn't being shown in the
error message.

So I changed my path references to backlash "\" instead of "/", even
though I was doing all these under cygwin bash shell.

./keytool.exe -v -alias certalias -import -file <DomainRootCA>.crt
-keystore ..\jre\lib\security\cacerts

Using the first password I tried, "changeit"

And it worked.

The lesson:

1. JDK error messages suck!
2. When using keytool.exe on Windows, make sure your path separators
are "\" and not "/". The fact you're running under bash shell doesn't
affect it.
Remember: Use Windows-based path separators if you're using the JDK
keytool in Windows

Saturday, 10 September 2011

Are you using iPhoto by *its* rules? Make sure your understanding of iPhoto terms is correct.

AAARGH!! Almost buggered up my iPhoto library. Was using "Flagged
photos" to mark favourite photos. Then accidentally selected "Create
Event From Flagged Photos" while trying to split an Event.

Result? An event containing 1000 photos from 2008 to today. And good
thing I Googled it first, because an event is actually like a folder
of photos. So deleting an event would have deleted all the photos in
it. All my favourite photos from my entire library, going back to
2008. Dammit.

But thank <deity> that "Edit -> Undo" can also reverse that operation.

Be careful of "Create Event From Flagged Photos" if you're treating a
"Flagged photo" to indicate a Favourite photo. This is not really what
it's for. Flagging a photo is probably meant for short-term
operations, in the context of creating an event or album going across
multiple windows of photos.

This is where following the rules and reading a bit more would have
helped. The model I *think* I should have been following was:

Event - Physical directory of photos.
Album - Virtual collection of photos.
Album - can have photo from any events
Smart Album - can have photos based on search criteria
Folder - a collection of Albums or Smart Albums

Remember:

Deleting an Event will delete the photos.
Deleting an Album will not delete the photos.

You should only Flag a photo to maintain a temporary list before
either moving them to an Event or Album. Normally I should put them in
an Album, since I like to keep photos grouped by date on the
filesystem. When I was on Windows using Picasa my workflow was to
first rename any new photos in a photo_upload directory using the
program "jhead" then running a Ruby script to move them into
date-based folders using each photo's EXIF metadata.

Don't keep them for longer than that, lest you mistakenly create an
Event and shove photos from different times into the same folder. If
that happens make sure to go to Edit -> Undo before doing anything
else.

This link cleared things up for me:

http://docs.info.apple.com/article.html?path=iPhoto/8.0/en/6443.html

Friday, 26 August 2011

Just discovered SVN switch command - switch to a different branch instead of doing a full checkout

I've been doing complete checkouts whenever our branches get renamed,
instead of using "svn switch". Not a small pain considering it takes 8
minutes to do a full checkout. Good thing this doesn't happen that
often (and probably the reason I haven't discovered the command. not
painful enough). How embarrassing!


Quick example of using SVN's "switch" command

$ cd calc

$ svn info | grep URL
URL: http://svn.example.com/repos/calc/trunk

$ svn switch http://svn.example.com/repos/calc/branches/my-calc-branch
U integer.c
U button.c
U Makefile
Updated to revision 341.

$ svn info | grep URL
URL: http://svn.example.com/repos/calc/branches/my-calc-branch

Only fewer files need to be updated. More time to read Hacker News. =)

REF: http://www.linxit.de/svnbook/en/1.1/ch04s05.html

Changes to Macbook Pro - installing Homebrew, RVM, Ruby 1.9.2, Rails, MySQL

I've been meaning to try out Rails 3.0 for a while, and finally got
around to installing it, but I wanted to use Homebrew for managing
packages and RVM so I could easily make use of multiple versions of
Ruby, since Snow Leopard default is Ruby 1.8.7

Every now and then I still have nightmares of what I went through with
getting Ruby to work on Tiger on my Powerbook. I didn't need to do as
much Googling this time around and getting into various dead-ends. And
with the i7 CPU compilation is way quicker than before. =)


1. Installed Homebrew:

/usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"

2. Install Git and Wget

brew install git

brew install wget

3. Installed RVM

bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)

reloaded .bash_profile:

> source .bash_profile

4. Check that RVM is running

rvm notes

5. Install Ruby 1.9.2

rvm install 1.9.2

6. Install Rails

gem install rails

7. brew install mysql

(during make CPU usage goes way up to 80% and the fan kicks in for the
first time i've seen)

Wednesday, 24 August 2011

How to do a git clone through a NTLM proxy

I've already set up CTNLM - http://cntlm.sourceforge.net/ - and have
already used it with Ruby gems yesterday, so I definitely know it's
working. We now have to configure GIT so it uses this proxy (running
on localhost:3128 by default)

>git config --global http.proxy localhost:3128

I've been looking at how to use workflows in Ruby on Rails recently,
and came across this project:

http://openwferu.rubyforge.org/

And the install instructions are here:
http://openwferu.rubyforge.org/quickstart.html

But looks like the GIT protocol can't be used through our proxy,
because if we try it we get this:

>git clone git://github.com/jmettraux/ruote.git
Cloning into ruote...
fatal: Unable to look up github.com (port 9418) (No such host is known. )


So replace git:// with http:// and see if we can do a git clone

>git clone http://github.com/jmettraux/ruote.git
Cloning into ruote...
remote: Counting objects: 22048, done.
remote: Compressing objects: 100% (5796/5796), done.
remote: Total 22048 (delta 16305), reused 21864 (delta 16134)Receiving objects:

Receiving objects: 100% (22048/22048), 4.04 MiB | 304 KiB/s, done.
Resolving deltas: 100% (16305/16305), done.


Yay, it works!!

Tuesday, 23 August 2011

Ruby gems error: "Could not find a valid gem 'sqlite3' Possible alternatives: sqlite3" WTH?? Gems could be having network issues.

Installed rails and trying to get a test project running:

Created a new project and tried to get it running:

D:\Development\testrails>rails server

Error was:

D:\Development\testrails>rails server
←[31mCould not find gem 'sqlite3 (>= 0)' in any of the gem sources listed in you
r Gemfile.←[0m
←[33mRun `bundle install` to install missing gems.←[0m

Now trying to install sqlite3, based on advise here:

http://ezruby.com/2011/07/how-to-install-ruby-on-rails-on-windows/

But I got:

D:\Development\testrails>gem install sqlite3
ERROR: Could not find a valid gem 'sqlite3' (>= 0) in any repository
ERROR: Possible alternatives: sqlite3


And trying 'sqlite3-ruby' doesn't work either:

D:\Development\testrails>gem install sqlite3-ruby
ERROR: Could not find a valid gem 'sqlite3-ruby' (>= 0) in any repository
ERROR: Possible alternatives: sqlite3-ruby

I came across this:

http://accidentaltechnologist.com/ruby-on-rails/running-rails-3-on-windows/

which advised to download sqlite3 for Windows and copy the file
sqlite3.dll into the directory [RUBY_INSTALL]\bin

No dice, still getting the same error

I also copied the file sqlite3.def to the same location - still
failing! Could it be because my version of sqlite is too new (current
one I downloaded is 3.7.7.1)

Then I realised that I forgot to use the proxy settings. At work, we
go through a Windows proxy, and to get Ruby gems to work, I had to
install CTNLM - which requires username and password - and then
access the proxy like this:

gem install --http-proxy http://localhost:3128 rails

Now it works!!


D:\Development\testrails>gem install --http-proxy http://localhost:3128 sqlite3-
ruby
Fetching: sqlite3-1.3.4-x86-mingw32.gem (100%)
Fetching: sqlite3-ruby-1.3.3.gem (100%)

#######################################################

Hello! The sqlite3-ruby gem has changed it's name to just sqlite3. Rather than
installing `sqlite3-ruby`, you should install `sqlite3`. Please update your
dependencies accordingly.

Thanks from the Ruby sqlite3 team!

<3 <3 <3 <3

#######################################################

Successfully installed sqlite3-1.3.4-x86-mingw32
Successfully installed sqlite3-ruby-1.3.3
2 gems installed
Installing ri documentation for sqlite3-1.3.4-x86-mingw32...
Installing ri documentation for sqlite3-ruby-1.3.3...
Installing RDoc documentation for sqlite3-1.3.4-x86-mingw32...
Installing RDoc documentation for sqlite3-ruby-1.3.3...

And Rails works now:

D:\Development\testrails>rails server
=> Booting WEBrick
=> Rails 3.0.9 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-08-23 16:27:11] INFO WEBrick 1.3.1
[2011-08-23 16:27:11] INFO ruby 1.9.2 (2011-02-18) [i386-mingw32]
[2011-08-23 16:27:11] INFO WEBrick::HTTPServer#start: pid=4908 port=3000


D:\Development\testrails>


So the lesson here is:

When you see a nonsensical error like this

ERROR: Could not find a valid gem 'sqlite3' (>= 0) in any repository
ERROR: Possible alternatives: sqlite3

It could mean that Ruby gems is having network problems, and can't
access *any* repository.


REFS:

http://ezruby.com/2011/07/how-to-install-ruby-on-rails-on-windows/
http://stackoverflow.com/questions/4418/how-do-i-update-ruby-gems-from-behind-a-proxy-isa-ntlm
http://cntlm.sourceforge.net/
http://accidentaltechnologist.com/ruby-on-rails/running-rails-3-on-windows/

Friday, 29 July 2011

Fairfax Subscriber login page FAIL

Trying to get my subscriber number from Fairfax subscriber login and
at the bottom there's a message with a number to call in case you need
help:

"Please contact us at [blank] or [blank]"

Friday, 22 July 2011

I hate HP QC (Quality Centre).

Holy f*. HP QC (Quality Centre) is such a piece of shit. One of our QA
teams is on QC 9.2, so I don't know if this has been fixed in more
recent versions.

So I wanted to update a bug today and had to go through this.

1. Wait for IE to re-download CAB files and got error message about
not being able to download and "Close all connections to server and
try again"

2. Restart IE.

3. Log into QC and open bug.

4. Update Status to "Ready to Test" and reassign to the tester. Tried
to type in Comment area after clicking "Add Comment" but I can't seem
to type in it!

5. Close dialog box, reopen bug and try again. Still not displaying what I type.

6. Looks like the text box for comments in the dialog box doesn't
work. But if you just view the listing of all bugs, and select the bug
you want, you can click on "Add a Comment" on the lower right box and
it accepts text input.

Our company has started using JIRA, but it looks like all the testers
will remain on QC. And there doesn't seem to be a way for QC and JIRA
to communicate both ways. QC can probably create a corresponding bug
in JIRA, but JIRA isn't able to go and update the same test in QC.

Ah, enterprise-y crap.

Friday, 3 June 2011

Hey Google: No love for Opera?

"As of August 1st, we will discontinue support for the following
browsers and their predecessors: Firefox 3.5, Internet Explorer 7, and
Safari 3."

http://gmailblog.blogspot.com/2011/06/our-plans-to-support-modern-browsers.html

"So if it's been a a while since your last update, we encourage you to
get the latest version of your favorite browser. There are many to
choose from:
• Chrome
• Firefox
• Internet Explorer
• Safari
"

I felt a teeny tiny disturbance in the Force... as if all 50 Opera
users suddenly cried out in terror at their favourite browser once
again being ignored and they can't shut up about it.

Randoms adding you on LinkedIn

You gotta wonder - "Bosnia and Herzegovina -
Transportation/Trucking/Railroad" - why would you even think of adding
me as a Friend?

How to export iPhone geolocation data

How to export iphone geolocation data so you can play around with the
data. I tried using some python scripts but they didn't work. Once I
exported the data, tried to use sqlite but the Firefox plugin is
really the best way to deal with sqlite.

* Get iPhone backup extractor from http://supercrazyawesome.com/

* Run backup and export your iOS Files - I had 2 backups and the older
backup was the one with all the geolocation data.

* Using Firefox, install the SQLite Manager plugin. Using this
plugin, open the file /iOS
Files/Library/Caches/locationd/consolidated.db

* Export the data - you can export as CSV, SQL, or XML


Now do an update of iphone to iOS 4.3.3 so it doesn't keep your retain
data anymore! (not too long anyway. they might keep it for a week,
apparently)

Wednesday, 18 May 2011

JSTL not working? Check that you have the correct servlet version in web.xml!!!

This is a pretty silly gotcha, but this normally wouldn't have
happened since most of the time I'm working on updates to existing
deployed webapps running on Tomcat 6.

Anyway, this sucked up about 1 hour of my life, trying to find out why
my JSP 2.0 style tags weren't working. Even things as basic as c:out
weren't working either.

Finally stumbled upon a forum post that pointed to this.

http://www.coderanch.com/how-to/java/ServletsWebXml

Aha!! The webapp I'd created using the Maven archetype
maven-archetype-webapp has Servlet 2.3 declared in it's web.xml. A
version that is pretty bloody old, considering the ref implementation
for that is Tomcat 4! Seriously, an upgrade for the built-in web.xml
wouldn't be that hard to do, Maven plugin people!

Anyway, all's well.

For now.

Wednesday, 23 March 2011

Coding WTF: Throw an exception to trace callers of a method

I found an interesting bit of code at work:


try { // This will allow us to debug future cache reloads
throw new Exception("Issuer Security Cache was Reloaded");
} // Stack Trace gives context to see where it was initiated from
catch(Exception e) {
log.debug(e, e);
}

It was a bit of a WTF, and it probably still is from a performance
point of view, but I can see why they did this.

I guess this was written before they had IDEs that could find out the
callers for a particular method. But couldn't they have just done
that anyway by grepping through the code base? Oh, right, inheritance
4 levels deep can leave you unable to find out which actual class
you're looking at.

Tuesday, 22 February 2011

Gravity

Gravity 
Translator

In your life there's someone waiting,
lost on streets that no one travels
In my dream I see this meeting,
we're a knot that fate unravels

But beyond our shameless sorrow,
catch me if I'm with the wind
We may be the sky tomorrow,
we're a branch that will not bend

The world is spinning through my head
Your gravity won't let me go,
You're holding me together,
No one ever has to know

I'm a dream and you're fading away, 
I'm a dream and you're fading away 

In your face there's someone sleeping,
lost in years that no one's counting
The only way to hear the weeping,
suffering is like a fountain

Everything is far away now,
held beyond our nameless sorrow
Shifting streets that no one wanders,
lose the days, we only borrow



Thursday, 13 January 2011

Coding WTF of the Week

I think I'll start a new segment for this blog, ala - DailyWTF.. hey,
I should submit this...

Task: Get a list of all securities that have prices.

Instead of doing a join between two tables (SECURITY, SECURITY_PRICE),
the developer did this

1. Get all securities.
2. Get all security prices.
3. Loop through all the securities.
4. Inside that loop, loop through all the prices.
5. Where price.securityId = security.id, put them into the container class

Not too big a deal on dev database, but problematic on UAT database
which had 7000 securities and 1000 security prices.

Removing this code and replacing it with code that used a join,
brought down a method call from 50 seconds to 2 seconds.