Răzvan Cosma's scratchpad

random scripts of random value

DVD copying

Comments off

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.

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.

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'

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);

Use Ghostscript. There is no Mac package, but a ./configure --without-x && make && sudo make install will do. Ghostscript offers a wealth of functions to generate or manipulate existing PDFs, check http://pages.cs.wisc.edu/~ghost/doc/cvs/Use.htm#Options for details.
So, to concatenate: gs -q -sPAPERSIZE=a4 -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=out.pdf in1.pdf in2.pdf ...

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

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

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();
rep1.DataSource = ds.Tables["somename"];

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
set @a=(Select Min(theindexfield) from thetable Where theindexfield>@a)
If @a is null
delete from #rp
insert into #rp exec random_password 8,'simple'
update thetable set thepassfield=(select p from #rp) where id=@a

the random_password procedure is something found on the ‘Net, thanks to the dude who wrote it. Full listing below:
continue reading...

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.

From Larry Wall himself:
$op = shift or die "Usage: rename expr [files]\n";
chomp(@ARGV = <STDIN>) unless @ARGV;
for ( @ARGV )
$was = $_;
eval $op;
die $@ if $@;
rename ( $was, $_ ) unless $was eq $_;

You can’t. The HTML keyword ‘class’ might be misleading, but it has nothing to do with inheritance, encapsulation, etc. In CSS, any definition can overwrite anything else, no matter where it’s placed in the DOM, and to make things worse, all browsers accept a “quirks” rendering mode that tolerates syntax errors and tries to make up for them in whatever way the programmer saw fit. All DOM element properties can also be re-defined dynamically with JavaScript, on events like Load, MouseOver, Blur, with timers, etc. Browsers also accept user-defined style sheets, and most of the time the user won’t even know he/she has defined one while installing a ‘skin’, ‘theme’ or simply changing the default operating system fonts. The bottom line is: you don’t have a fucking clue where you are in a document, and how the container you are referring to looks like.

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