How to shrink MS SQL database log file

USE [$(databasename)]
GO

-- Drop old transactions log data (just mark for deletion)
BACKUP LOG [$(databasename)] WITH NO_LOG -- TO DISK='D:BackupSQLServer$(databasename)_log.trn'
GO

-- Physically shrinks the log file
DBCC SHRINKFILE($(databasename)_log, NOTRUNCATE)

Free testing & deployment automatization tools

Accept tests

  • Selenium (Web app. – Firefox plugin)
    Selenium Remote Control – for automatization
    Selenium Grid – for integration tests on separate machine
  • Watin
  • Cucumber
    Selenium + Cucumber – human readable tests

Performance tests

  • httperf (doesn support ASPX due viewstate issue)
  • YSlow (Yahoo) – web page load optimization

Unit tests

  • JUnit
  • NUnit
  • utPLSQL
  • RSpec

Accessibility monitoring

  • Hobbit
  • Monit
  • God

Build

  • Ant, Maven, NAnt

Fast integration

  • Bamboo + NAnt

Performance monitoring

  • Cacti
  • New Rehc RPM (Rubby only)

Administration automatization

  • PUPPET

Installing, deployment

  • Capistrano

SQL Express DB performance – auto-close evil

A quote from the original post:

By default, Express Edition creates databases with the Auto Close option enabled. This option allows SQL Server to close the physical operating system files for the database when all connections to the database are closed. The advantage here is that individual workstation installations can have database files copied around as easily as document files. This is not so advantageous in a server setup, as the overhead of opening the files and starting up the database can cause poor response times.

To check this setting for an individual database, right click the database in Management Studio, choose Properties, go to the Options page, and verify the state of the Auto Close option (it should be at the top of the list). You’ll almost certainly want to set this to False for every database on a dedicated server, with the possible exception of extremely seldom used databases.

See the original post here.

JavaScript Timer Sample

<html>
<head>
<script> 
var nMiliSec = 0
var timerId = null;
function StartTimer() {
  StopTimer();
  var nMins = parseFloat(document.counter.mins.value); 
  var nSecs = parseFloat(document.counter.secs.value); 
  nMins = nMins + nSecs/60;
  nMiliSec = nMins*60*1000;    
  timerId = setTimeout(“Display()”,10);
}
function StopTimer() {
  nMiliSec = 0;
  if (timerId) {
    clearTimeout(timerId);
  }  
}
function Display() {
 var oRes = document.forms.counter.result;
  if (nMiliSec > 0) {
    nMiliSec -= 10;
    var cRes    
    var nMins = parseInt(nMiliSec/60/1000);
    if (nMins < 10) {
      if (nMins > 0) {
        cRes = “0”+nMins.toString();
      } else {
        cRes = “00”;
      }
    } else {
      cRes = nMins.toString();
    }
    cRes += “:”;
    var nSecs = parseInt((nMiliSec/1000)%60);
    if (nSecs > 0) {
      if (nSecs < 10) {
        cRes += “0”+nSecs.toString();
      } else {
        cRes += nSecs.toString();
      }
    } else {
      cRes += “00”;
    }
    cRes += “:”;
    var nMili = parseInt(nMiliSec-(nSecs*1000)-(nMins*60*1000))/10
    if (nMili > 0) {
      if (nMili < 10) {
        cRes += “0”+nMili.toString();
      } else {
        cRes += nMili.toString();
      }
    } else {
      cRes += “00”;
    }    
    oRes.value = cRes;
    timerId = setTimeout(“Display()”,10)
  } else {
    MyBeep();
  }
}
function MyBeep() {
  document.writeln(“<bgsound src=’Freestyler.wav’>”);
}
</script> 
</head>
<body>
<table style=”height:100%;width:100%”><tr><td align=”center” valign=”middle” style=”height:100%;width:100%;”>
<form name=”counter”>
  Minūtes/Sekundes <input type=”text” size=”2″ name=”mins” value=”18″><input type=”text” size=”2″ name=”secs” value=”0″>
  Laiks: <input type=”text” size=”8″ name=”result”>&nbsp;
  <input type=”button” value=”Sākt” onClick=”StartTimer()”>&nbsp;
  <input type=”button” value=”Apturēt” onClick=”StopTimer()”>
</form>
</td></tr></table>
</body>
</html>
Posted in JS. Tags: . Leave a Comment »

MSBuild and TFSBuild links

Workflow Tracking DB Monitor

A sample console application that lists workflows information from the WorkflowTracking database:

Workflow Tracking DB Monitor Project

Using SharpBITS to transfer (download) file

1. Add a reference to the SharpBITS.dll on your project (download from SharpBITS.NET).
2. Add multi-line TextBox named “output” to your form.
3. Add following piece of code to your form code:

public partial class BITStester : Form
{

BitsManager manager = null;
object jobTransferredSync = new object();
object jobFailedSync = new object();
const string fromURL = @"http://localhost/download/test.txt";
const string fileTo = @"c:/temp/test.txt";

private void BITStester_Load(object sender, EventArgs e)
{
	manager = new BitsManager();
	manager.OnJobTransferred += new EventHandler(OnJobTransferred);
	manager.OnJobError += new EventHandler(OnJobError);
	manager.EnumJobs(JobOwner.AllUsers);	

	FileInfo file = new FileInfo(fileTo);

	BitsJob job = manager.CreateJob(file.Name, JobType.Download);

	job.NotificationFlags = NotificationFlags.JobTransferred;

	// The default retry delay was 600 seconds (10 minutes).
	job.MinimumRetryDelay = 60; // 1 min
	job.Priority = JobPriority.High;
	job.Description = "Created by BITStester";
	job.AddFile(fromURL, fileTo);
	job.Resume();

	AddToOutput("File {0} added to BITS pool", file.Name);
}

private void OnJobTransferred(object sender, NotificationEventArgs e)
{
	lock (jobTransferredSync)
	{
		BitsJob job = e.Job;
		job.Complete();
		AddToOutputHelper(string.Format("File {0} downloaded", job.DisplayName));
	}
}

private void OnJobError(object sender, NotificationEventArgs e)
{
	lock (jobFailedSync)
	{
		BitsJob job = e.Job;
		string errorMessage = string.IsNullOrEmpty(job.Description) ? 
				"Error description not provided" : job.Error.Description;

		AddToOutputHelper(string.Format("File download {0} failed: {1}", 
				job.DisplayName, errorMessage));
		job.Cancel();
	}
}

#region Output

private delegate void UpdateOutputHandler(string line);

// To call also from another thread
private void AddToOutputHelper(string line)
{
	if (output.InvokeRequired)
	{
		output.Invoke(new UpdateOutputHandler(AddToOutput), line);
	}
	else
	{
		AddToOutput(line);
	}
}

private void AddToOutput(string line)
{
	output.AppendText(line + Environment.NewLine);
}

private void AddToOutput(string line, params object[] param)
{
	output.AppendText(string.Format(line, param) + Environment.NewLine);
}

#endregion Output
} // class

 

Useful links when using BITS technology:

Posted in BITS, C#. Tags: , , , , . Leave a Comment »