22 October 2010

Problem in KeyBinding constructor in WPF

Basically Implementation#01 and Implementation#02 should be same. But Implementation sometimes gets exception if modifiers = ModifierKeys.None.


//Implementation # 01:
KeyBinding k = new KeyBinding(command, key, modifiers);

//Implementation # 02:
KeyBinding keyBinding = new KeyBinding();
keyBinding.Command = command;
keyBinding.Key = key;
keyBinding.Modifiers = modifiers;


So, use the 2nd way of implementation if required.

07 July 2010

Code : Strip HTML (Remove HTML Tags)

string StripHTML(string htmlString)
{

    //This pattern Matches everything found inside html tags;
    //(.|\n) - > Look for any character or a new line
    // *?  -> 0 or more occurences, and make a non-greedy search meaning
    //That the match will stop at the 1st available '>' it sees, and not at the last one
    //(if it stopped at the last one we could have overlooked
    //nested HTML tags inside a bigger HTML tag..)
   
    string pattern = @"<(.|\n)*?>";
    return Regex.Replace(htmlString, pattern, string.Empty);
   
}

Beginner's Unit Testing in C# using NUnit

C# .NET 2.0 Test Driven Development


The above website is helpful for a beginner though some steps could have been clearer.

Code : Download a web page

/// Returns the content of a given web adress as string.
///
///
URL of the webpage
/// Website content
public static string DownloadWebPage(string Url)
{
    // Open a connection
    HttpWebRequest WebRequestObject = (HttpWebRequest)HttpWebRequest.Create(Url);

    // You can also specify additional header values like
    // the user agent or the referer:
    WebRequestObject.UserAgent = ".NET Framework/2.0";
    WebRequestObject.Referer = "http://www.example.com/";

    // Request response:
    WebResponse Response = WebRequestObject.GetResponse();

    // Open data stream:
    Stream WebStream = Response.GetResponseStream();

    // Create reader object:
    StreamReader Reader = new StreamReader(WebStream);

    // Read the entire stream content:
    string PageContent = Reader.ReadToEnd();

    // Cleanup
    Reader.Close();
    WebStream.Close();
    Response.Close();

    return PageContent;
}

26 May 2010

CSS for printing


I'm feeling excited knowing that we can have different css styles for normal web-view and for printing. Say, in your website there is an image which you don't want to be available for printing. You can do so simply adding some css style (display:none) for printing (media="print"). Here is the example

<html>
<head>
<style type="text/css" media="print">
.noPrint{
display: none;
}
</style>
</head>

<body>
Here is the image: <img class="noPrint" src="myPicture.jpg" />
</body>
</html>



Inline css is like below

@media print {
.noPrint{
display:none;
}
}

02 May 2010

How to integrate SVN with Visual Studio using AnkhSVN

Download




Enable AnkhSVN for source control

  • In Visual Studio, select Tools > Options.
  • In the Options window, select "Plug-in Selection" under "Source Control".
  • Select "AnkhSVN - Subversion Support for Visual Studio" for "Current source control plug-in".



Connect a project to AnkhSVN

  • Open the project in Solution Explorer.
  • From the File menu in Visual Studio, select Subversion > Change Source Control .
  • In the Change Source Control window, select the row containing your project or solution, and click Connect.
  • Click Ok



Add a solution to a repository

  • Open your solution in the Solution Explorer
  • Right-click your solution and select "Add Solution to Subversion". To add specific projects rather than the containing solution, you can select "Add Selected Projects to Subversion" instead. The "Add to Subversion" dialog appears.
  • Specify the URL to your Subversion repository.
  • To add the solution to a new subdirectory, select the "Create Folder" option, and enter a directory name and log message.
  • Select File > Subversion > Pending Changes. select the files you want to commit, write log message and click on Commit.



For more info: http://help.collab.net/index.jsp?topic=/com.collabnet.doc.anksvn_001/action/ankh_getting_started.html

15 March 2010

Google Groups Bug: Set a banned member to manager

I have found a critical bug in Google Groups!

In google groups, if you set a banned member's membership to manager, then it seems that that user becomes a non-member manager. Then it becomes impossible to change his/her membership type. You cannot even delete / invite that person again. It's a bug and it's from Google!!

There is a remedy though. You have to use firebug.

  • In management task, select 'manage members'. Navigate to the user. You'll find that the checkbox beside that user is disabled.
  • Using firebug, find the html of that checkbox and remove the disabled attribute [disabled=""]
  • Then check the checkbox.
  • Set membership to "regular member" and click corresponding ok.

06 March 2010

How to extract rar file in ubuntu?

sudo apt-get install unrar

 

© 2007 t!ps n tr!cks: 2010



Template unik dari rohman


---[[ Skip to top ]]---