stackemedia

The Garden Project

This was posted in General on June 23rd, 2009

Since we moved into our new house, our gardens been ovegrown and difficult to manage. I’ve started to tackle it and am hoping to have the garden complete in a few months.

The gallery will show the projects progress as I remove more and more unwanted plants and weeds.

[album id=2 template=extend]

The aim of the project is to create a visually appealing garden that is suitable for children – on a budget. Unfortunately no expensive Japanese bonsai tree rock gardens for me :-)

New plants added so far:

  • Calluna vulgaris - Heather
  • Fuchsia Magellanica
  • Arundinaria Murielae – Bamboo
  • Lavandula Stoechas - French Lavender
  • Buddleja
  • Potentilla Abbotswood (white flower)

Plants damaged by Ethan my 21 month old son: 2 3

Plants I would like to include in the garden:

  • Acer Japanese Maple

Web enabled feedback form

This was posted in Development, MOSS/Infopath on June 19th, 2009

You may want to include a feedback form or questionnaire on your Share Point site. Not every one will have the InfoPath client installed on their local machine, so the best way to ensure that everyone can access the form is to web enable it.

Enabling the form for use within a web browser is fairly simple: the only drawback being that you will be fairly limited during design as to what controls and functionality you might use. Saying that, for a simple survey, you won’t need anything beyond the basics.

To start off it would be best to setup your site and document libraries first. (I will presume that you do not have a site setup already so we will start from there). Once the site and libraries have been setup, we will create the form in InfoPath.

Read the rest of this entry »

Get first day of current month (VB)

This was posted in Visual Basic on June 17th, 2009

The following code will return the first day in the month as a string.

=DATESERIAL( YEAR(TODAY()), MONTH(TODAY()),1 )

Get whether a given date is on a weekend or not (VB)

This was posted in Visual Basic on June 17th, 2009

Function returns false if the passed date is a weekend and true if the date is on a working day.

Function GetWeekDay(ByVal raisedDate As Date) As Boolean
Dim passedDayNumber As Integer
passedDayNumber = DatePart(“w”, raisedDate)
If passedDayNumber = 7 Or passedDayNumber = 1 Then
return false
Else
return true
End If
End Function

Re-seeding a table id (SQL)

This was posted in SQL on June 17th, 2009

Use the code below if you want to restart the id column of a table from 0.
This is most useful if you have cleared a table and want to have the automatic generation of the id field to start at zero again.

DBCC CHECKIDENT(‘yourTable’, RESEED, 0) ;

Check if a column exists and delete it (SQL)

This was posted in SQL on June 17th, 2009

Exactly what the title says, checks if a column exists and then deletes it.

IF exists(SELECT id FROM syscolumns WHERE name LIKE ‘yourColumn’)
ALTER TABLE yourTable DROP COLUMN yourColumn

Get the day of the week (SQL)

This was posted in SQL on June 17th, 2009

Use to find the day of the week and return an integer.

SELECT TOP(5) DatePart(WEEKDAY, [EnquiryRaisedDate]) AS ‘DayOfWeek’, [EnquiryRaisedDate] FROM [vEnquiry]

To find the named day of the week, use:

SELECT TOP(5) DateName(WEEKDAY, [EnquiryRaisedDate]) AS ‘DayOfWeek’, [EnquiryRaisedDate] FROM [vEnquiry]

Create a JavaScript tooltip

This was posted in JavaScript on June 17th, 2009

Use the following code to create a JavaScript tooltip. Click here to view an example.

First add html to your page to create the popup:

<div id=”FloatBox” class=”hideFloatBox”>Hello World!</div>

Then add the following CSS to your style sheet (between the < head> tags (or you could use a CSS style sheet):

<style type=”text/css”>
.hideFloatBox
{
display: none;
}

.displayFloatBox
{
position: fixed;
_position: absolute;
z-index:200;
}

#FloatBox
{
padding: 5px;
width: 200px;
height: 20px;
border: solid 1px #cecece;
background-color: #ffffff;
}
</style>

Now add your JavaScript to the page (also between the <head> tags:

<script language=”javascript” type=”text/javascript”>
var floatBox;
var boxVisible = false;
var nav = (navigator.appName == “Netscape”);
var Xoffset = -5;
var mouseX;
var mouseY;

if(nav)document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = getMouse;

///< summary>
/// Gets the mouse position on screen.
///< /summary>
function getMouse(e)
{

mouseX = (nav) ?e.pageX : event.x;
mouseY = (nav) ?e.pageY : event.y;

if(boxVisible)
{
moveFloatBox(mouseX, mouseY);
}
}

///<summary>
/// Moves the floating box.
///</summary>
function moveFloatBox(x, y)
{
floatBox.style.left = (x + Xoffset) + “px”;
floatBox.style.top = (document.body.scrollTop + y + 20) + “px”;
}

///< summary>
/// Displays the floating box.
///< /summary>
function showFloatBox()
{
floatBox = document.getElementById(“FloatBox”);
floatBox.className = “displayFloatBox”;
boxVisible = true ;
}

///< summary>
/// Hides the floating box.
///< /summary>
function hideFloatBox()
{
floatBox.className = “hideFloatBox”;
}

</script>

Checking for valid Email (C#)

This was posted in C#.NET on June 17th, 2009

Check for valid email using REGEX expression.

// check to see if it is a valid email
if( txtEmailAddress.Text != “Enter Email” && !Regex.IsMatch(txtEmailAddress.Text, @”^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$”) )
{
lvalEmail.Visible = true;
lidPage = false;
}
else
{
lvalEmail.Visible = false;
}

Randomly generate two unique numbers (C#)

This was posted in C#.NET on June 17th, 2009

Generate two unique random numbers and returns them in an array.

private static int[] RandomNumbers()
{
int[] randomNumber = new int[2];
Random randomGenie = new Random();
for (int x = 0; x < 2; x++)
{
// makes sure that there are no duplicate numbers.
do
{
randomNumber[x] = randomGenie.Next(1, 5);
}
while (randomNumber[0] == randomNumber[1]);
}
return randomNumber;
}

Tested browsers: firefox, chrome, IE8