Ubuntu on a MacBook Pro

This time a native install, allocating disk space for the Linux host, transferring all data and emulating the guest Windows system (for business purposes)
Step -1: backup everything on an external disk, Apple’s Time Machine is a good tool for this
Step 0: boot into OS X and make sure all your applications are running and data is intact
Step 1: install rEFIt from Sourceforge, it’s pretty straightforward
Step 2: disable journaling on the OS X partition
diskutil disableJournal /Volumes/Macintosh\ HD
(run that twice, just to be sure you see the message “already disabled”)
Step 3: delete as much useless data as possible to make room for the new partition
Step 3: (try to) defragment the OS X partition, iDefrag does a reasonable job
Step 0
Step 4: read carefully the parted manual, it applies changes immediately and will happily fuck up the drive if you mistype a single letter
Step 4: boot any recent Linux live cd, parted, select /dev/sda, resize 2 (1 is the EFI FAT partition), DO NOT try to move the partition, only shrink it!, mkpart primary ext2, reboot
Step 5: enter the rEFIt partitioning menu, apply whatever it says must be applied
Step 0
Step 6: boot the Ubuntu install media, follow the usual steps, making sure you select the bootloader to be Grub (LILO cannot handle EFI) and install it on the Linux partition (I assume it’s /dev/sda3 or hd(0,2)), NOT in the MBR – I don’t think there even is a MBR on the Macs
Step 0
Step 7: boot the shiny new Ubuntu, 8.04 has the minimal hardware support needed to show you a graphical desktop

Continue reading “Ubuntu on a MacBook Pro”

DVD copying

Yes, I duplicate my DVDs. All of them. Or at least I try to. I’m not talking about ISO images grabbed from the peer-to-peer repository du jour, but stuff I liked enough to buy. The round plastic disk distribution thingie has a very nasty side-effect: it fucks my laptop’s reader. It won’t happen immediately, but after a few dozen movies and just enough time beyond the one year warranty the unit starts mis-behaving – blocking the system, spinning like crazy, overheating etc. The main reasons for this behaviour are simple:
1. poor quality physical media
2. intentionally added errors
Both of the above have been introduced as copyright protection measures. Now my DVD reader does not cost $20 (the usual no-name PC desktop unit price) but $200, US. Since I don’t live in the US of A, a hardware failure might cost me $400 and one month for delivery. So I fear original disks. And I immediately try to convert them into .iso on a more reliable storage medium. Hints:
1. For the PC – Nero (Pro, if you have the money, not the OEM version) and Xilisoft’s suite of tools
2. For the Mac: Roxio Popcorn (very good, no trial version available unfortunately), DVD Backup (open source, I think, link to Softpedia as I don’t know the author), Apple’s own Disk Utility
3. For Linux: dd conv=noerror if=/dev/cdrom of=image.iso

Edit: just discovered MacTheRipper (dig around, you’ll find a working mirror) – so far it’s done a perfect job with all the disks which Nero couldn’t and Popcorn wouldn’t handle.

Cannot install SQL 2005 (server and/or client)

Again the astoundingly complex Microsoft installer lost me several hours for an otherwise simple task. Things that can go wrong (and they all went wrong, under different circumstances, on several systems):
1. “Unexpected error occurred” – if you copy the contents of the two installation CDs, make sure one is in a subfolder called “Servers” the other “Tools”.
2. If you want to install just the client connectivity and management options, start the installer from the “Servers” not the “Tools” subfolder.
These two were the main reason of this post, being so infuriatingly stupid.
3. “Failed to compile the Managed Object Format (MOF) file” – WMI (Windows Management Instrumentation) database is broken for whatever reason, you must delete and rebuild it:
net stop winmgmt
cd %windir%\System32\Wbem\
ren Repository Repository_bad
XP: rundll32 wbemupgd, UpgradeRepository
2003: rundll32 wbemupgd, RepairWMISetup
Vista: winmgmt /salvagerepository
net start winmgmt

4. Uninstall any trace of the Express Edition Toolkit, and reboot, before attempting to install the Management Studio. The paid and free versions of the client components don’t seem to play well with eachother.

How (the fuck) do I link two instances of SQL Server using the Management Studio?

Never thought I’ll actually miss Enterprise Manager, but the newer one is even more confusing. So – no clue so far how to do such a simple task via the graphical interface, just execute the stuff below:
EXEC master.dbo.sp_addlinkedserver @server = N'server.domain.com\instance,tcport', @srvproduct=N'SQL Server'
EXEC master.dbo.sp_addlinkedsrvlogin N'server.domain.com\instance,tcport', false, null, 'sa', 'thesapassword'

Why can’t I send e-mail from ASP (.Net) anymore?

Things that used to work mighty fine in 2000 server suddenly break in 2003.
1. CDONTS is no longer available, but it works if you copy one dll from a 2000 system and do a regsvr32 %windir%\system32\cdonts.dll
2. Classic ASP using CDO fails with error “cdo.message error 80070005”. Reason: the user IIS runs under (usually Network Service) must have write acces to the Exchange pickup directory (usually C:\Program Files\Exchsrvr\Mailroot\vsi 1\PickUp)
3. ASP.Net scripts also fail with several possible messages, “acces denied” or “cannot access cdo.message object”. Solution: always specify a valid SMTP server address, e.g. in web.config, then
System.Web.Mail.SmtpMail.SmtpServer = System.Configuration.ConfigurationSettings.AppSettings["SmtpServer"]; System.Web.Mail.SmtpMail.Send(msg);

How to connect to a MS SQL database using ASP.Net 1.1?

1. In web.config:
<configuration>
...
<appSettings>
...
<add key="connStr" value="server=server_name_or_ipaddress; Initial Catalog=database_name; User Id=username; Password=password;" />
...
</appSettings>
...
</configuration>

2. In your .aspx file:
<asp:Repeater ID="rep1" runat="server">
<HeaderTemplate><table border="1"></HeaderTemplate>
<ItemTemplate>
<tr>
<td><%# DataBinder.Eval(Container.DataItem, "col1") %></td>
<td><%# DataBinder.Eval(Container.DataItem, "col2") %></td>
</tr>
</ItemTemplate>
<FooterTemplate></table></FooterTemplate>
</asp:Repeater>

3. In your .aspx.cs file:
using System.Data;
using System.Data.SqlClient;
protected Repeater rep1;
private void Page_Load(object sender, System.EventArgs e)
{
SqlConnection cn = new SqlConnection( System.Configuration.ConfigurationSettings.AppSettings["connStr"] );
SqlDataAdapter dap = new SqlDataAdapter("Select col1,col2 from sometable",cn);
Dataset ds = new DataSet();
dap.Fill(ds,"somename");
rep1.DataSource = ds.Tables["somename"];
rep1.DataBind();
}

How to generate passwords for a list of users?

Ugly hack

set nocount on
declare @a int
declare @b varchar(128)
set @a=0
drop table #rp
create table #rp(p varchar(128))
While 1=1
Begin
set @a=(Select Min(theindexfield) from thetable Where theindexfield>@a)
If @a is null
break
else
delete from #rp
insert into #rp exec random_password 8,'simple'
update thetable set thepassfield=(select p from #rp) where id=@a
continue
End

the random_password procedure is something found on the ‘Net, thanks to the dude who wrote it. Full listing below:
Continue reading "How to generate passwords for a list of users?"

The format wars have ended

Unfortunately, Sony won. Warner Bros., Wal-Mart and Netflix have chosen Blu-Ray, and – from an article in an American newspaper (Hollywood Reporter):

“Immediately after the Warner announcement, the HD DVD North American Promotional Group canceled its Consumer Electronics Show presentation. The following week, data collected by the NPD Group revealed Blu-ray took in 93% of all hardware sales for that week”

Snif. HD-DVD, I hardly knew ye. And I really wanted to see “the other guys” win, after a few encounters with such gems as
– intentionally broken CDs
– “we don’t sell laptops in Eastern Europe”
– “buy all your movies again for the PSP, and store them on a disk we will no longer manufacture in a few months”
– the rootkit
and a few other personal peeves, Sony is definitely not in my top fave companies.

Bad Behavior has blocked 85 access attempts in the last 7 days.