Convert SQL Server Database to a SQLite Database

Recently, I wanted to resurrect an old project of mine I worked on in my spare time originally designed to work on .Net technologies. Naturally, I backed it against a SQL Server 2005 Database which turned out to be a bad idea because it made portability of that data a bit of a nightmare.

So it was with great happiness that I found this tool (mirrored here) by liron.levi who posted an article on CodeProject on how to accomplish this task. You still need a Windows machine and an install of SQL Server (Express Edition with Advanced Tools is alright) but it got the job done just fine for me.

If you want a no-fuss easy way to convert your databases into a format easier to deal with and a lot more portable to-boot.

‘File not found: lib’ Error installing Rails Gem

I recently had a problem trying to install Rails 3 on my MacBook with a fresh OSX Snow Leopard:

sudo gem install rails
Password: {entered}
Successfully installed rails-3.0.7
1 gem installed
Installing ri documentation for rails-3.0.7...
File not found: lib

Turns out this is a somewhat common problem.  But it seems that the solution is easy, just manually reinstall RDoc. To do this run these 3 commands:

sudo gem install rdoc-data
sudo rdoc-data --install
sudo gem rdoc --all --overwrite

The last line in particular will re-generate all the documentation for your installed gems (including Rails) and can take a while, but you should be able to confirm the fix by reissuing the Rails gem install command:

sudo gem install rails

shows that rails now installs properly and says that it has installed both ri and RDoc documentation without issue.

Optimizing Apache 2 Configuration for Smaller VPS Instances

I recently down-scaled the server which hosts this blog (one among a few). Being a Ubuntu server, it was trivial to install the LAMP stack, including Apache 2. However, I quickly discovered a problem with the default configuration on a server with a lesser amount of memory (in this case 512MB). The server would work just fine for a short while and then grind to a near halt, where even a SSH session becomes unusable. When I eventually got into the server, I listed the processes and found the ‘apache2’ process running several dozen times!

The default configuration for the Pre-fork MBM (Multi-Processing Module) reads as follows:

# prefork MPM

   StartServers          16
   MinSpareServers       16
   MaxSpareServers       32
   ServerLimit           400
   MaxClients            400
   MaxRequestsPerChild   10000

To something more reasonable to a server with limited memory, such as:

# prefork MPM

   StartServers         4
   MinSpareServers      4
   MaxSpareServers      8
   MaxClients           35
   MaxRequestsPerChild  10000

I found this has made my server much more stable – and I’ve not noticed any performance decrease from the new configuration.

High Performance & Multi-threaded SCP Using RSYNC

Recently, I had the somewhat laborious job to backup a stack of websites and blogs from my remote web server.  Initially I tried do it with a simple SCP command; but after letting it run for about an hour, it was obvious that it was just too slow and taking too long downloading each file one at a time.

After talking complaining to a friend he suggested using the RSYNC command. Surprisingly it was incredibly very easy to get it working, you simply issue:

 rsync -avz -e ssh remoteuser@remotehost:/remote/dir /this/dir/

Obviously changing the appropriate parts for your case.

I found it to be at least 10 fold faster (or more) than SCP on it’s own, and better still, RSYNC will resume when SCP wont!  Try it and see for yourself.

Windows 7 Drivers for Apple’s USB Ethernet Adapter

Listen up, all you Boot Camp’in Mac users … Can’t find Windows drivers for the Apple USB Ethernet adapter? Want to use use the adapter on another Windows machine? Are you crazy?  Well, it turns out it CAN be done, with a little bit of trickery.

There is a lot to be said for Apple’s simplicity of design.  Even their adapters and cables look as if they were pain stakingly and lovingly hand crafted by an eccentric, gay, Swedish man. Everything just looks better.

Recently, after the onboard NIC died in my Acer Aspire L3600 (which runs Windows 7 x64, and I use as a dedicated Windows Media Centre).  After flashing the BIOS and jumping through several hoops with no avail, I needed to go looking for another way to get a wired >=100Mbit/s network interface into the machine.  Since its ultra-compact form factor makes an internal PCI option impossible, I needed to go looking for an external (USB) option.  It didn’t take long to realise that my options were going to be extremely limited and after checking out my nearby computer retailers, I had only two options.  A reasonably generic SWANN adapter, or Apple’s USB Ethernet Adapter – both were in stock at my local Dick Smith Powerhouse.  The problem with the SWANN adapter, is that its a single solid block, and since my Media Centre lives very close to the wall, it wasn’t desirable, while The Apple adapter can be flexed to a right angle.

Problem is, the Apple adapter says (on the back) that it can ONLY be used with an Apple MacBook.  But the adapter’s drivers ARE included as part of BootCamp, which means it can function when running Windows on a MacBook. So with a little trickery, you can get it working on any old Windows 7 or Vista PC (32 or 64bit editions).

  1. First, you need to download the driver for the adapter, either the 32bit or 64bit version.
  2. Next, extract the zip file and locate the file Ax88722.inf.  It needs to be altered in order to get the device drivers to be installed.  In order to simplify the process, I’ve simply got the tweaked version here, for you to download. Just replace the original Ax88722.inf file with this one inside this zip file.
  3. Next, attach your USB ethernet if you have not done so. Launch device manager (right-click on “computer” and select “Manage”). Locate the lonely unknown device “Apple USB Ethernet” and right-click it to select “Update Driver Software”.
  4. Select “Browse my computer for driver software” and in the file browser dialog select the folder of your recently modified .INI file and continue the wizard. This should bring your Apple USB ethernet to life!

Apparently there are drivers for 32bit versions of Windows XP, put together by the BootCamp community, if you’re an XP user and feeling lucky you can try your luck with this link (but like the rest of this post, use it at your own risk).

Download Microsoft .NET Framework 3.5 SP1 Standalone Full Redistributable Setup Installer

Many applications uses Microsoft .NET Framework 3.5 as development platform, and thus requires .NET Framework to be installed beforehand, else the installation will request to download and install .NET Framework from Internet. On offline system without Internet access or online server with slow downloading speed, the requirement to download setup files through web may hit the wall – a no go.

kamagra shipping

Microsoft initially just provides a minimal size dotnetfx35setup.exe download which is a bootstrapper that will still need to download more files via Internet. For users who prefer to perform offline installation or install .NET Framework 3.5 SP1 without waiting for download to complete will have to download and save a copy of full complete standalone or redistributable Microsoft .NET Framework 3.5 SP1 setup installer, which is finally published by Microsoft.

Microsoft .NET Framework 3.5 SP1 (Service Pack 1) is a full cumulative update that contains many new features building incrementally upon .NET Framework 2.0, 3.0, 3.5, and includes cumulative servicing updates to the .NET Framework 2.0 and .NET Framework 3.0 subcomponents. See KB951847 for list of changes and fixed issues in the .NET Framework 3.5 Service Pack 1.

Download full package of Microsoft .NET Framework 3.5 SP1: dotnetfx35.exe (231 MB)

For known issues and release notes, refer to Microsoft .NET Framework 3.5 SP1 Readme.

Has Your Windows Mobile 6.1 QuickGPS Stopped Working?

A few months ago, I had a very sudden and strange thing happen to the QuickGPS app on my Windows Mobile HTC Touch Cruise smartphone.  My GPS signal would take forever to get a signal and when I opened QuickGPS and clicked Download now I got the error “Connection failed. Please try again later”.  Needless to say, later didn’t help. It also said:

Download time: Not yet downloaded
Valid time: Expired

It happened if I was connected over 3G, GPRS, or through USB/ActiveSync. All other data networking is fine.  But nothing worked.   After many hours of googling I found this page. Basically, for some reason one or more of the phone’s registry settings are busted and need to be fixed (at least it was in my case).  I grabbed an application that let you edit the registry on the phone and then verified these registry settings – and my problem was fixed!

[HKEY_LOCAL_MACHINE\Software\HTC\QuickGPS]
"RemindTime"="02151010034724"
"Bias"=dword:fffffed4
"ExpiredTime"=dword:00002760
"folder"="\Windows\"
"region"="US"
"INIDate"="20060531"
"remind"=dword:00000001
"actSync"=dword:00000001
"auto"=dword:00000000
"NotifyID"=dword:00001960
"INIFile"=""
"path"=""
"EEFile"="xtra.bin"
"curRegion"=dword:00000000
"curIP"=dword:00000000
"pwd"="1"
"authname"="1"

If editing the registry doesn’t sound like your kind of thing, someone in the forum of the above link has a cab file that makes the changes for you.

How To Install Phusion Passenger on a CentOS/cPanel Box

The Usual Disclaimer
Please beware that even if these instructions work, that they may break your setup.  While these worked fine for me, you should take extreme care applying them to your situation.  Follow these instructions at your own risk. They work fine for me on a CentOS 4.6 box with cPanel 11.23.4-R26138 and WHM 11.23.2.

First off, Phusion Passenger only works with Apache 2.x so if your server doesn’t have that thats the next thing you’ll have to do.  T o upgrade Apache, go to your main control panel at https://server.ip.address:2087/ and click the “Apache Update” link on the left.  If given the option, I highly recommend that you choose Apache 2.2 instead of 2.0.

Next, download Passenger. Assuming you already have Ruby and RubyGems installed on your server, simply run (as root) gem install passenger. This will pull the passenger library and code down to the server and place it with your other RubyGems.  It’s important to know that this does not install Passenger into Apache, so obviously its non-operational.  If you don’t have Ruby and RubyGems, you’re way too far down the line with reading this article and need to get up to speed with actually getting those on to your box.  Google can help with that!

At this point it’s probably useful to have the Passenger User Guide up on screen, just for reference.

Third, you need to compile and install the Passenger module within Apache. This sounds worse than it is, but before you do it, it is important to set a couple of environment variables to make it work properly.  In your SSH console type thrse two commands into it:

export APXS2=/usr/local/apache/bin/apxs
export APR_CONFIG=/usr/local/apache/bin/apr-1-config

Next, run:

passenger-install-apache2-module

It might take a few minutes, but if everything goes well you’ll eventually end up with Passenger telling you to add a few lines to your Apache configuration file (the code you get may differ slightly):

LoadModule passenger_module /usr/local/lib/ruby/gems/1.8/gems/passenger-2.0.2/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/ruby/gems/1.8/gems/passenger-2.0.2
PassengerRuby /usr/local/bin/ruby

However, despite what it tells you, do not put it in the httpd.conf file – cPanel can rewrite that file and your changes can be lost breaking your passenger configuration and virtual site.  Instead, add it to /usr/local/apache/conf/includes/pre_virtualhost_global.conf – this file might not exist until you make it, but that’s okay.

Lastly restart Apache and if you didnt get any critial errors, you should be in business.  I have had issue on other servers where the Rails app failed to load because the RubyGems version was too old, so keep your eye on the error_log file if Apache starts but it still doesn’t work.  Also refer to the Passenger User Guide for further configuration and usage information.

How to recover from Windows Server 2003 Event IDs 1168 and 1003

Recently at the office we had a brown-out with devastating consequences.  All our servers are managed by UPSes and on this particular occasion, at the precise moment of this brownout the UPS failed and server lost power abruptly.  This caused some error in Directory Services, becasue after the boot the Windows Server 2003 (and primary domain controller) showed a message during bootup (but after logon) saying “The Active Directory is rebuilding indices”, just before network connection preparations. It hadn’t done this before.

After several hours waiting for this to go away (the server seemed responsive during the process so we left it) nothing changed.  We forcibly reboot the machine and it booted into Safe Mode automatically.

After several reboots and a scheduled CHKDSK /f on bootup, nothing changed, so we booted into Directory Services Repare mode to investigate further.  Now, looking through the event log showed that even more things were going wrong including the computer name being missing the domain being all messed up and an array of other issues, the most worring being several Event Id’s 1168 and 1003.

After a bit of googling I found this page, and based on my own knowledge condensed and modified the solution to work in my case:

  • First, boot the machine into Directory Services Repair Mode
  • Next, open a command window.
  • Then, type the command: cd %SystemRoot%\Ntds
  • Execute the command: Esentutl.exe /p Ntds.dit for me this took 8.3 seconds to execute.

Basically, the esentutl.exe is a utility used to perform various administrative actions on any databases using  Microsoft Proprietary Database format.  The Directory Services Database uses this format.  The ‘/p’ argument tells the utility to perform a “repair” on the second argument, which obviously is the database file.

Warning: The Ntds.dit file is the heart and soul of Active Directory on your domain.  Take extreme care with this file because if you don’t have an adequate backup of the system state on the domain controller, you may irrecoverably corrupt your domain.  This would be bad.

In my case, everything went smoothly, and the domain was back up after a reboot back into “normal” mode.  Obviously, we changed the UPS with a working one.  Who says network admins never get a happy ending?

Windows 7 Freezes During Network File Copying

My workstation at work is a great little computer. It’s running Windows 7 and its very reliable and does what I need it to do. However, periodically, usually during periods of large quanities of network traffic, it will freeze. No BSOD, no warning, just frozen.

After some googling, it seems that the on-board Atheros L1 Gigabit Ethernet adpater on the ASUS motherboard has a known issue with Windows Vista, and apparently Windows 7 as well:

Install a new driver The problem may be especially prominent with the Atheros L1 Gigabit Ethernet 10/100/1000Base-T Controller used on ASUS p5k motherboards. This driver (FTP Link), intended for Windows Vista, has been reported to solve this issue under Windows 7 in a variety of cases.

I downloaded the driver from here, and installed it on top of the generic Windows driver for the NIC and not a single freeze or lock-up since.

If you have an ASUS P5K series motherboard, I highly recommend that you upgrade this driver (even if you’re not having these problems as the performance seems better on these drivers).