Archive for the ‘Technology’ Category

Usually you would like to know last time a database was restored. This is very handy script to show you the details.

WITH LastRestores AS
DatabaseName = [d].[name] ,
[d].[create_date] ,
[d].[compatibility_level] ,
[d].[collation_name] ,
RowNum = ROW_NUMBER() OVER (PARTITION BY d.Name ORDER BY r.[restore_date] DESC)
FROM master.sys.databases d
LEFT OUTER JOIN msdb.dbo.[restorehistory] r ON r.[destination_database_name] = d.Name
FROM [LastRestores]
WHERE [RowNum] = 1

You can simply get the details from dbo.restorehistory from MSDB databases. However, the above script will provide more details.

To resolve the error go to Network Connection and right click on the VPN connection then click on properties:

2016-01-25 10_37_31-WIN7 on HP650HNO - Virtual Machine Connection Go to Security tab and change the Data encryption to Maximum strength encryption:

2016-01-25 10_37_31-WIN7 on HP650HNO - Virtual Machine Connection

Click OK and try again.

SQL Server preformance

Posted: April 11, 2015 in SQL Server

Turn on flag – DBCC TRACEON 1222

Start monitoring the SQL Server Event Logs.

The procedure below only works for Window OS  but the same method  should work for other operating systems.

Start command-line: keyboard shortcut Windows+r then type cmd OK

runas /user:postgres cmd 

You will need to enter postgres user’s password if you are not sure what the password is you should be able to change it through Computer Management under control panel. Please ask if you are not sure.

Once you successfully logged in as postgres user you will need to open Regional and Language settings via the command-line:

control intl.cpl

Make all the required configurations then restart postgresql service.

For this tutorial you would need at least 1GB USB stick and fast internet. The USB stick will be formatted so don’t use a USB stick with your important files or photos stored. Your current operating system should be Windows if you are using other operating systems this will not work.

To start with you would need to get a Linux distribution (they are open source) there are large number of Linux distributions available but easiest and commonly used distribution is Ubuntu the current stable version is 12.04 you can download it from their website.

Once you have the Ubuntu downloaded then you can use Universal USB installer to load the Ubuntu on to the USB. ImageOpen the Universal USB Installer in Step 1: select Ubuntu 12.04 Desktop. Step 2: click the Browse button and find the Ubuntu distribution (ubuntu-12.04.1-desktop.iso) you downloaded before. On Step 3 it is important to select the correct USB drive in the drop down (go to My Computer and see the drive letter for your USB stick). Then click Create to make the live Ubuntu USB stick. It depends on your computer specs and the USB speed on how long would it take but it should never take longer than half an hour.

Once the USB stick is ready you can either install Ubuntu into your computer or just try running your computer via the USB you just created. To start your computer with the USB your computer should have the capability to start from a bootable USB drive.

Nowadays most desktop and laptop computers have the option to allow you select the media you would like to start your computer with by pressing the F12 button on the startup screen. However, if this doesn’t work then you would need to go to the BIOS and set the boot priority.  You can start the BIOS by pressing F2 or DEL button the startup screen. Then go to the Boot Tab on the top and make the USB the first option.

If you successfully configured your computer to start with USB you should see the image below:

ImageClick Try Ubuntu to start Ubuntu without installing or changing anything in your computer. If you would like to install Ubuntu on your computer then choose install and follow the instruction here.

Run the commandline as administrator.


Type cmd on the search box, right click on the cmd icon and Run as administrator.

Then copy and paste command below:

REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\SpecialAccounts\UserList" /v postgres /d 0 /t REG_DWORD /f

original post here.

After setting up the samba make sure you add root

smbpasswd -a root

If you get the above error try this:

smbpasswd -a -m $machinename

(the machine you are trying to join to the domain)

you might get the error the group ‘machines does not exist.

addgroup machines

try again now you should be able to add the machine name and join the doamin.

Look at the /var/log/samba/log.machinename for more details of the errors you get.

Break Mac password

Posted: February 26, 2012 in Mac, Technology
Tags: ,

The following instruction will change any user’s password under Mac OS X. I usually need this when working on the clients’ mac machine and don’t know the password. Remember to tell them what is their new password. I usually put the password as hint if in case I forget to tell them.

Right after the startup sound press the following buttons:


/sbin/fsck -fy
/sbin/mount -uw /
launchctl load /System/Library/LaunchDaemons/
launchctl load /System/Library/LaunchDaemons/ (Mac OS X 10.8 and higher)
dscl . -passwd /Users/whitsongordon newpassword

To disable the yellow connection bar you would need to go to the display tab in the RDP client and uncheck “Display the connection bar when in full screen mode.”
You can also change the setting in the .rdp file. The connection bar will still be visible for 5 seconds when you log on, but then it will automatically slide out of view. Moving your mouse to the top of your desktop will give you the connection bar back.

If you want to get rid of it alltogether, add this registry key to your profile:

HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client
“PinConnectionBar” = REG_DWORD:0

Now the connection bar will not return, even if you move the mouse to the top of the screen.
Clicking the pushpin will change the registry key back to “PinConnectionBar” = REG_DWORD:1.

Usually the error log complains about not being able to read postgresql.conf. If you check postgres directory there is NO data folder created. In order to fix the problem you would need to follow this:


This error is caused by the failure of initdb in creating a DB. It
fails probably due to the locale. To fix the problem:

runas /user:postgres cmd
cd "\Program Files\PostgreSQL\8.3\bin"
initdb -D "c:\Program Files\PostgreSQL\8.3\data" -E UTF8 --locale=English

Don’t for get to add the locale at the end otherwise it will fail.