luminousmonkey.org

MYOB ODBC with Ruby

Monday 10 August 2009, 16:54 WST

I have previously written on how I was working on automating the invoice system between the sales database I wrote and MYOB.  I do have something written up, however it’s not code that I would want anyone to see, because I know it’s not high quality.

Anyway, the statements MYOB prints, are, in a word, crap. So I wanted to write a system that would take the information out of MYOB and generate my own format of statements for either mailing or e-mailing.

Now the problem with MYOB and Rails, or to be correct, the problem with MYOB and ActiveRecord is that MYOB is not a vaild SQL database.  This problem is compounded by the fact that ActiveRecord expects the database schema to be a specific way (this can be changed). ActiveRecord can be nice to work with, however there are cases where it can be a bit of a pain, and this is one of those.

I’ve had a little play with Sinatra and Sequel and this looked like a good chance to give Sequel a try. The statement generator I’m writing is just something to run, once or twice a month, so it doesn’t need a web interface.

JRuby is currently my Ruby VM of choice, because I’ve found the Java integration very useful for printing and faxing for our internal sales application, so I’ve stuck with that, which, when it comes to MYOB is a good thing.  Why?

As mentioned in my previous post, I had found information on getting MYOB and Rails/Activerecord talking to each other at Pat Allan’s site, Freelancing Gods.  The problem is the Rails ODBC driver doesn’t support MYOB (and I’m sure MYOB doesn’t have a 100% correct implementation), so you have to patch some files to get support.

However, JRuby allows you to use JDBC, so I figured that I could use the Java JDBC to connect to the MYOB ODBC driver.  It works, with no patching involved.

Ok, enough of the length explanation, how does it work?

First, get and install JRuby.

At the moment I’m using JRuby1.3.1, and I download the jruby-bin-1.3.1.zip file.  I’m going to assume you know how to get JRuby installed, and in your command path.

With that done, start up your command shell (I use Windows Powershell), and install the following gems:

That’s it! Next, you need to set up your MYOB ODBC datasource, again, I’m going to assume if you’re looking up this information then you know how.  There’s one thing however, if, like me, you’re using the 64bit version of Windows Vista, you need to run:

C:\Windows\SysWOW64\odbcad32.exe

Otherwise it will only list the MS SQL OSBC drivers.

With that done, we can then load up jirb and play with the database. Or you can write the following file and run it.

require 'rubygems'
require 'sequel'
 
#Setup the database connection
DB = Sequel.connect( 'jdbc:odbc:MYOBTest' )
 
customer = DB[:customers].all[0]
 
puts customer[:name]
 
DB.disconnect

Don’t forget the disconnect, otherwise JRuby will crash when you exit.

If you’re familar with Sequel, you might wonder why I do the bad thing, and go:

DB[:customers].all[0]

rather than:

DB[:customers].first

This problem is that the MYOB ODBC driver will complain about the SQL statement generated, best I can guess is that it doesn’t support the SQL option LIMIT.

Anyway, that’s it for now.

No Comments »

Coming Soon…

Wednesday 18 March 2009, 15:33 WST

Well, our work OpenSolaris server has been giving me the shits.  After going down mysteriously I had to do a quick swapover job (basically I took the 3 drives out of it and plonked it into the new machine I had ready for the boss (quick note, it worked straight away, I was really surprised.)).

I decided I’ve had enough with building my own servers, seems to be that I had a few problems with hardware recently, in particular, RAM.  The sudden loss of our e-mail server was enough motivation for me to get permission to spend some cash on a proper server.

Since (Open)Solaris is currently my OS interest at the moment, I figured I would check out what they’re offering, basically we’re a small business, we don’t need, and can’t afford something too hardcore.  My choice came down to either the Sun Fire X2200 M2, or the Sun Fire X2250.  They’re the same price (currently AUD $2,350.00), so I basically went with X2250 because it’s faster (I think).

So now I’m waiting for it to arrive (via Sun’s Try & Buy trial offer), when it arrives I’ll try and give a “review”.  I say “review”, but honestly it’s just going to be what I think about it, and this is my first (and probably only) proper server purchase, so don’t actually use it to make a decision.

Of course, if you are deciding on new server hardware, and like myself, this is your first time, keep in mind that these server boxes are pretty deep.  We had to purchase a new rack that was 1000mm deep, as the server is 633mm deep.

No Comments »

Recent thoughts on religion and politics

Friday 27 February 2009, 18:00 WST

Ask me what my religion was, hmm, say about two months ago.  I would have said “Agnostic”, however, I’ve recently been thinking about my views on religion.  I really can’t remember what made me start thinking about it, I think it was a YouTube clip, anyway, that’s not important.

As a result, I’ve read “The Blind Watchmaker” by Richard Dawkins, followed by “God is NOT Great”, by Christopher Hitchens.  I’ve managed to get hold of “Enemies of Reason”, and “The Root of Evil”, documentatries by Dawkins.  And again, I’ve been following athiest channels on YouTube.

My views have gone from “Agnostic” (which would have been more correct to say that I was an agnostic athiest, as I’ve never really believed in God), to athiest, to anti-thiest.  This is largely due to my reading of Hitchens, a point of view that had recently been firmly resolved by the recent bushfires in Victoria.

How? Simply, because a ministry in Victoria proposed that abortion laws are the reason why God started the bushfires, and recently Fred Phelps has said that the fires are send by God to punish Australia.  These are but two recent examples of how the religious will try to use fear of God as a means to push their agenda.

Now you may think, “These guys are pretty fucked up, but, well, it doesn’t really affect me”, and you may be right, for now.  The thing is, and what I’ve been starting to notice, is that this religious shit does affect us, there is a religious agenda out there that is trying to establish a control on the population.

For example, take the UN, there has been a resolution, that aims to make defamation of religion illegal.  This is pretty old news, from November I think, however I believe at this stage, it’s optional.  Australia voted against it, as they should,  Australia is a secular government.  However, you can see the obvious attack on free speech here, something which you can’t allow a compromise on.  It’s a point that I am, unfortunately, not eloquient enough to present an argument for.  However, again, Hitchens provides a wonderful speech on from June 2007 on free expression.

Unfortunately, I simply do not know how much free speech we have in Australia, but I think that this is something America has right.  All speech should unrestricted, even the fucked up shit like hate speech, because once you make a distinction between what is allowed, and what is not allowed, then you open a door, ever so slightly, for more speech to be policed.

Anyway, here’s some links that I suggest people to check out:

Pharyngula
Refuting Atheistic Naturalism Episode 2 (This kid is like 14!)
 

Check out the videos by these guys on YouTube
Thunderf00t
AronRa
AndromedasWake
DonExodus2
cdk007
patcondell
TheAmazingAthiest
C0ct0pus

No Comments »

New Zealand, part 1

Friday 14 November 2008, 11:41 WST

8th November
Well, the flight was a bit of an endurance.  Starting at about 10pm Friday night (the 7th) and finishing on Saturday at 2pm Christchurch time.  For those (like me) that have to sit down and do the math, that’s about 10 hours, of course, flying took only about 5 hours.  The rest of the time was taken up by waiting, or getting ready to fly out.

We didn’t get to sleep until 8pm, so that means we were up about, hmmm, lets see, 6am Friday to 4pm Saturday, so that’s about 22 hours without sleep.  I was half expecting to see fairys fly off the top of door frames, or non-existant kittens jumping out of peoples laps, thanks to sleep deprevation.  We were saved by my Aunty and Uncle, who, are excellent hosts.

9th November
After a much needed 12 hour kip, we were refreshed and ready to go looking about Christchurch, with my cousin, nothing too major, just a quick look through the markets and a few shops.

No Comments »

OpenSolaris with CIFS and ZFS ACLs

Saturday 01 November 2008, 08:36 WST

If you’re using OpenSolaris and the CIFS server stuff that’s built-in with ZFS, you may have run into a problem where you can’t edit or rename files with Windows, even though you’ve got write permissions on the file.  It’s not the server that’s stopping you, it’s the Windows client.  It’s looking at the ACLs and checking for permission, sees that it doesn’t have it and denying you.

The trick is you have to set the ACLs to what Windows expects.  To do this, make sure you’ve got you path set to use the Solaris ls and chmod utils.

export $PATH=/bin:$PATH

Then set the permissions for all the files, and dirs recursively:

chmod -R A=owner@:rwxpdDaARWcCos:fd:allow,owner@::fd:deny,group@:wp:fd:deny,group@:rx:fd:allow,everyone@:wpAWCo:fd:deny,everyone@:rxaRcs:fd:allow movies

Depending on what you want to do, you will have to change the ACL options, but hopefully this helps a little.

No Comments »

Australian Internet Censorship

Tuesday 28 October 2008, 09:07 WST

The Australian government, in an effort to protect “The Children” are trying to put into effect, Internet censorship at the ISP level.  This is stupid, ignoring the moral, and social reasons for a second (as these are generally very gray areas), you can look at the technical reasons.

For one, it can slow down your Internet connection as much as 80%, not only that, but, well, it won’t really stop anyone from getting to filtered websites.  You could easily get around it by just setting up a VPN, or other proxy service for your connection.  As the saying goes, “Locks only keep honest people out”.

No Comments »

OpenSolaris and no menu screen boot issue

Friday 17 October 2008, 13:44 WST

I like OpenSolaris, ZFS is very cool, and I’ve toyed with zones a little, and I’m yet to really try DTrace.  However, when it comes to ZFS, there’s one thing that’s a bit of a worry, the complete and utter loss of your data.  Now in theory if you’ve got a redundant pool, then your dataloss should be very minimal, however, certain things can happen that you should be careful playing with things that are cutting edge.

What the hell am I on about?

Well, on my home server, all by itself, it decided that it would no longer boot.  GRUB would load, however the menu wouldn’t, no spashimage, no menu selection, just the grub command line.  I really couldn’t be bothered to try and fix it to be honest, and it gave me a chance to document how to get MediaTomb, etc, setup for it.

The problem, is pretty much described in this OpenSolaris forum post.

Anyway, today, I had the same problem with our email server at work, I rebooted, and the machine wouldn’t boot.  Because it wasn’t easier to start from stratch, I had to try and nut the problem out.  Unfortunately I don’t even know what the problem is, I’m just not that good, I had already tried directly entering grub commands to get it to boot (getting the same result as in the forum post).

Luckly, using Google, I found some pointers to get myself sorted.  Actually, this post, they even made a wiki entry for it here.  First time I tried it, it didn’t solve the problem, however, I thought I would also try it on the older boot enviroment… success!!! Sort of….

Initially, I had only done the update on rpool/ROOT/opensolaris-snv_95-1 (it is updated to snv98 despite the name), however, after also doing the procedure on rpool/ROOT/opensolaris-snv_95, I got my grub menu back!! Woohoo! Oh, wait… er… kernel panic….

So after much wailing, thinking, and googling, I really had nothing else to try, but I had noticed that there was a opensolaris-work-2 boot enviroment I had forgot.  So basically I followed the procedure for all three of my boot enviroments, I also just left the zpool imported (I was using a snv98 LiveCD) and rebooted the machine.

Success! So now the server is up and running again, but it’s things like this that really scare me about using OpenSolaris and ZFS.

Update:
I’ve recently found out that the RAM in my home server is faulty, no matter how good a filesystem is, it still can’t stop the hardware from screwing it up.  However, it has to be said that, despite the flakey hardware I’ve only lost one, or two files.

No Comments »

OpenSolaris, ZFS Backups

Thursday 02 October 2008, 16:21 WST

At work, we use ZFS for our file storage (it’s setup to scrub nightly, and takes snapshots every 15 minutes, very useful since I can’t get our radio technicians to use source control, it acts as a useful “undo” feature).  However, backing the data up can be a bit problematic.  At the moment we don’t have a tape drive, or something that I can get to automatically backup the data.

Anyway, to be on the safe side, I’m currently backing up the data, and I thought I’d use an external HD with ZFS.  This gives me nice error checking, plus lets me use the following to backup the files:

zfs send storage/archives@hourly-2008-10-02-15-00-00 | ssh aldredmr@10.0.0.76 pfexec zfs recv backup/archives@2008-10-02-15-00-00

As usual, check Sun’s documentation for the info.

No Comments »

TopGear: Australia

Tuesday 30 September 2008, 12:31 WST

The first episode was disappointing, not necessarily all bad.  Have to keep in mind that TopGear wasn’t brilliant straight away, but hopefully it’ll improve as they continue.  The presenters need improvement, though they are under the shadow of a team that’s been together for a few years.

Hopefully the producers read the FinalGear website and will correct the problems (I think the test track sucks, doesn’t seem to be very interesting).

No Comments »

Linux Desktop Suckage

Friday 26 September 2008, 07:37 WST

Elliott Huges has written a series of blog posts on what’s wrong with the Linux desktop, and I believe he’s spot on.  I really can’t add much more to it than that, because I’ld just be repeating what he said (and I wouldn’t write it anywhere as good).

Desktop Linux Suckage: Index

No Comments »

February 2010
M T W T F S S
« Aug    
1234567
891011121314
15161718192021
22232425262728

Other: