Screen Capture Software

It is a very convenient tool for bloggers. When you write posts on your blog you need to capture and crop images from different sources - this tool is for you. Download Screen Capture Software

Tuesday, September 1, 2009

Using Image in Ajax.Actionlink of ASP.NET MVC

To use image instead of text in Ajax.Actionlink is not possible directly so we have to user indirect method for it.
Using Direct image

< %= Ajax.ActionLink("[Add]", "About", new AjaxOptions { }).Replace("[Add]", "< [img] src = \" ../../Content/add.jpg\ " alt = \"image\" / >" )% >


Using div

[< %=Ajax.ActionLink("[Add]", "About", new AjaxOptions { }).Replace("[Add]", "< class ="\">< /div >")% >]

Monday, August 31, 2009

Checking file type with javascript before uploading

Limit the types of files users can upload
The following JavaScript function can be used to validate that the type of file that a user tries to upload is of a certain format. It does this by checking that the files extention (eg .html) is in an array of allowed extensions that is passed to the function as an argument.

< type="text/JavaScript">
< !-- Begin
function TestFileType( fileName, fileTypes ) {
if (!fileName) return;

dots = fileName.split(".")
//get the part AFTER the LAST period.
fileType = "." + dots[dots.length-1];

return (fileTypes.join(".").indexOf(fileType) != -1) ?
alert('That file is OK!') :
alert("Please only upload files that end in types: \n\n" + (fileTypes.join(" .")) + "\n\nPlease select a new file and try again.");
}
// -- >
< /script >


You can test it using the file upload below which will only accept image files that end in either .gif, .jpg or .png:



You can then call the function from an event like the onClick of the above button, which looks like:

onClick="TestFileType(this.form.uploadfile.value, ['gif', 'jpg', 'png', 'jpeg']);"


or, alternatively, you could put it in the onChange event of the file upload element.

Note that the above example assumes that you know the "name" attribute of the file upload element. In domino R5 you can do this to an upload by putting a name in its HTML attributes. In R4 you cannot do this so you can either create the upload yourself by using the following pass-thru html

Otherwise you would need to loop through all elements on the form looking for any input of type "file" and then validating this. This method is demonstrated here.

Note: This is not entirely foolproof as people can easily change the extension of a file before uploading it, or do some other trickery, as in the case of the "LoveBug" virus.

Sunday, August 30, 2009

Get Dynamic Thumbnail for you site

I implemented a new feature over at my Jenny McCarthy and Hayden Panettiere websites this past week.

I've been posting YouTube videos on both sites for quite some time, but have only been providing text descriptions to go along with the links from the main video pages. I finally decided that I wanted to figure out how to dynamically include thumbnail image previews of the clips, not only to display on the main video pages, but also in web feeds where applicable.

First I got all fancy and was sending in YouTube API requests to get at the information. The youtube.videos.get_details function provides thumbnail information in its node.

However, once I had implemented a preliminary approach using that method, I quickly realized there was a very obvious pattern to the thumbnail URLs being returned with each call:

http://img.youtube.com/vi/LiIboq6XCOg/2.jpg

The only portion of the above URL that seems to change is the video ID between the fourth and fifth forward slashes.

So rather than calling the API multiple times to get thumbnails for all the videos presented on the page, I decided to keep all function calls local, opting to create my own internal function for extracting the YouTube video ID from my XHTML-compliant embed code using a regular expression and then inserting that between the http://img.youtube.com/vi/ and /2.jpg portions of the static thumbnail URL.

The result is much faster and works like a charm.

Saturday, June 6, 2009

National Language Support (NLS) API Reference

This link has all the Culture Name and related data for user with Multi language support in your application.

Tuesday, May 19, 2009

Wednesday, February 18, 2009

Creating branch in SVN

Creating brach with command prompt
creating the branch
1. Note the current head revision:
svn info svn://server.com/svn/repository/trunk grep Revision
2. Make a clean, remote copy of trunk into the branches folder. Name it something. We’ll call it your_branch:
svn cp svn://server.com/svn/repository/trunk \
svn://server.com/svn/repository/branches/your_branch \
-m "Branching from trunk to your_branch at HEAD_REVISION"
Replace HEAD_REVISION with the revision number you noted in step 1.
Note that a backslash (\) means that the command continues onto the next line.
3. switch your local checkout to point to the new branch (this will not overwrite your changes):
svn switch --relocate \
svn://server.com/svn/repository/trunk \
svn://server.com/svn/repository/branches/your_branch
You don’t really need the --relocate svn://server.com/svn/repository/trunk bit, but I’m in the habit of being explicit about it.
4. Check that your local checkout is definitely now your_branch, and that you can update ok:
svn info grep URL
svn up
5. commit your new changes.
(These steps will work even if you had already made local changes on trunk, but decided you wanted them on your_branch instead. If your trunk checkout was unmodified, just skip step 5.)
updating the branch
You’ve been developing for a while on your_branch, and so have other people on trunk, and now you have to add their changes to your_branch.
1. First, update your branch checkout and commit any outstanding changes.
2. Search the Subversion log to see at what revision number you last merged the changes (or when the original branch was made, if you’ve never merged). This is critical for making a successful merge:
svn log --limit 500 grep -B 3 your_branch
3. Also note the current head revision:
svn info svn://server.com/svn/repository/trunk grep Revision
4. Merge the difference of the last merged revision on trunk and the head revision on trunk into the your_branch working copy:
svn merge -r LAST_MERGED_REVISION:HEAD_REVISION \
svn://server.com/svn/repository/trunk .
Replace LAST_MERGED_REVISION with the revision number you noted in step 2, and HEAD_REVISION with the revision number you noted in step 3.
Now look for errors in the output. Could all files be found? Did things get deleted that shouldn’t have been? Maybe you did it wrong. If you need to revert, run svn revert -R *.
5. Otherwise, if things seem ok, check for conflicts:
svn status egrep '^C^.C'
Resolve any conflicts. Make sure the application starts and the tests pass.
6. commit your merge.
svn ci -m "Merged changes from trunk to your_branch: COMMAND"
Replace COMMAND with the exact command contents from step 4.
Phew.
folding the branch back into trunk
Hey, your_branch is done! Now it has to become trunk, so everyone will use it and see how awesome it is.
This only happens once per branch.
1. First, follow every step in the previous section (“updating the branch”) so that your_branch is in sync with any recent changes on trunk.
2. Delete trunk completely:
svn del svn://server.com/svn/repository/trunk
3. Move your_branch onto the old trunk location:
svn mv svn://server.com/svn/repository/branches/your_branch \
svn://server.com/svn/repository/trunk
4. Relocate your working copy back to trunk:
svn switch --relocate \
svn://server.com/svn/repository/branches/your_branch \
svn://server.com/svn/repository/trunk

Creating branch visually with VisualSVN
- select "VisualSVN->Branch" in the Visual Studio main menu, - enter URL like https://myserver/svn/myproject/branches/new-feature - check "Switch working copy" at the bottom and click OK, - commit your unfinished changes to the branch
- select "VisualSVN->Switch" in the Visual Studio main menu, - enter URL of the trunk folder (https://myserver/svn/myproject/trunk) - implement urgent fix and commit it to the trunk,
- select "VisualSVN->Switch" in the Visual Studio main menu, - enter URL of your branch (https://myserver/svn/myproject/branches/new-feature) - continue working and committing subsequent changes to the same branch,
When the work is finished: - select VisualSVN->Switch in the Visual Studio main menu, - enter URL of the trunk folder like https://myserver/svn/myproject/trunk and click OK, - select VisualSVN->Merge in the Visual Studio main menu, - select "Reintegrate a branch" - enter URL of your branch and click Next, Merge - after merge is completed you might want to review your changes, - commit merged changes to the trunk.
Origional Post

Saturday, January 3, 2009