development blog for the wicked stuff we encounter

Sunday, after working all day long on the powerbook, I suddenly heard the hard disk doing silly noises, then the mp3 playback stopped and the system halted. I've restarted, but it could'n start the OS. I booted the installation DVD in Rescue mode, and in the Disk utility application, the following error message welcomed me: Invalid Volume Header Checking HFS Plus volume… Checking Extends Overflow file… Invalid node structure The volume Thora could not be repaired after 3 attempts.Error: The underlying task reported failure on exit 1 HFS volume checked 1 volume could not be repaired because of an error Repair attempted on 1 volume 1 volume could not be repaired Holy fuck! All my 55+ gigabytes of data is lost?! I called my friend immediately, and he handed a DiskWarrior CD, but I no longer trusted the original HDD, so I bought a new one - a Samsung 5400/8Mb cached 80G - to replace the old 60G 4700/2Mb one. I also bought a Firewire/USB craddle, and an LG DVD-RAM/DVDRW+ writer. I successfully restored the system with DiskWarrior, and after I CCC-d (a copy application using ditto and psync) the whole old drive to the new one. Afterwards, I booted from the firewire disk, and nothing happened. Sweet Jesus, I spent 90+ minutes for nothing? A complete reinstall would only cost 30... Then I realized the following: 1) The FW connection mysteriously lost in the copy process at 90%, and the symlink under /Volumes/ (/Volumes/FW-backup) reverted to a single folder (!) instead of a link to /dev/sdisk3, so I just copied over from one directory to another... 2) The CCC was unable to copy all kernel files from the root folder. mac.sym mach_kernel were missing, so I needed to copy them manually. After the restart, everything worked as expected, so I was ready for the operation :) I opened and disassembled the Powerbook (as I did several times before) and now I'm writing this article onto the new drive. The old one will be used as another HDD in the Intel-laptop (the current host of Windows Vista and Ubuntu) and the laptop's old drive will function as an external HDD via a 2,5" $10 usb-craddle. (I'm still planing to upgrade my iPod, indeed - see the previous article :))

You see the error as well when trying to migrate from a Mono.Net project to an MS.Net project? The key is in the web.config file (one retard thinks he can change everything to make it more 'compatible'): < ?xml version="1.0" encoding="utf-8" ?> <configuration> [...] <system .web> <compilation defaultLanguage="c#" debug="true"> <compilers> <compiler language="cs;c#;csharp" extension=".cs" warningLevel="1" compilerOptions="/codepage:65001" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> </compilers> [..] </compilation> </system> </configuration> The codepage:utf8 is not valid, it must be a number: 65001. Or you can simply omit this whole line...

Today I found a fascinating problem, how to manage an access to a remote Oracle database via dotnet and with a program written in C#. There are mainly two ways to connect to a database: using a pre-built SqlClient module, or to use the good old ODBC one. Microsoft implemented the System.Data.OracleClient module for the ms.net framework, so did the Mono guys. However, this mono implementation is NOT managed code, so you can imagine. Oracle provided it's own dotnet classes for the developers, but it mainly focuses on the 10x version, and it has no release for mono. I have never managed Oracle before (just used in a huge application framework, but never developed on it), so first of all, I needed to figure out what tools do I need to create a connection. I found a cool RPM-based guide on the Oracle Technet. You need to say apt-get install alien first, to be able to install RPMs on Ubuntu. Then you can grab and install the two files, i usually download them with wget. I advise you to place the tnsnames.ora file directly under /etc, so it will always be on the path! To test it, type sqlplus scott/tiger@[the_server] I've installed the unixODBC package from the hoary universe, and to make it usable with Oracle, I've downloaded the proper Easysoft.com Oracle driver. It has a very nice install shell, and after it creates a text file with a machine number, you need to submit it via the website or email, and you'll receive a licence id (you need to place it under /usr/local/easysoft/licences BUT you need to delete the LICD: chars... it took me 5 minutes to figure out :) Now you need to set the variables: ORACLE_HOME=/usr/lib/oracle/10.1.0.4/client export ORACLE_HOME LD_LIBRARY_PATH=/usr/lib/oracle/10.1.0.4/client/lib/ export LD_LIBRARY_PATH (the best solution is to add these variables to the /etc/environment without the exports) if you get to this point, you can check the connection with the isql tool, located under /usr/local/easysoft/unixODBC/bin/: /usr/local/easysoft/unixODBC/bin/isql -v ORACLE (ORACLE is the DSN name in /etc/odbc.ini) It will reply with an sql shell, type: select * from scott.emp; to test it. I advise you to always grab the latest mono, at the time of writing this is 1.1.9, I've installed it by selecting the Fedora RPM repository, downloading all necessary files with wget and aliened them. I used the following odbc.cs program to test the connection (updated go-mono.com example) using System; using System.Data; using System.Data.Odbc; class OracleTest2 { public static void Main() { string connectionString = "DSN=ORACLE;UID=scott;PWD=tiger"; IDbConnection dbcon = new OdbcConnection(connectionString); dbcon.Open(); IDbCommand dbcmd = dbcon.CreateCommand(); string sql = "SELECT ename, job FROM scott.emp"; dbcmd.CommandText = sql; IDataReader reader = dbcmd.ExecuteReader(); while(reader.Read()) { string EmpName = (string) reader["ename"]; string EmpJob = (string) reader["job"]; Console.WriteLine("EmpName: " + EmpName + " Job: " + EmpJob); } reader.Close(); reader = null; dbcmd.Dispose(); dbcmd = null; dbcon.Close(); dbcon = null; } } To compile and run, say: mcs odbc.cs -r:System.Data.dll mono odbc.exe ...and you can see the final results :)