Wednesday, 17 August 2011

Google steps into the MUSIC Arena...

Google has a new feature it hopes will keep Music beta users tuned in.


The Web giant today launched Google Magnifier, a new feature to help users of its online music storage service discover and obtain new music. In addition to free music tracks, the site has videos of live performances, artist interviews, and a chance to explore different musical genres.
The move is an effort by Google to distinguish its Music Beta service from competitors such as Amazon' Cloud Music and Apple's forthcoming iCloud service, which is expected to launch in the fall.

The music-storage service, which launched in May, lets users upload their music libraries and replay them on PCs and mobile devices.





Google is kicking off the service by giving away two tracks by Grammy-nominated indie rock band My Morning Jacket to Music Beta users

Google Magnifier(Check it out here)

Fetch HTML source of a web page in c#.net


I am working with my team-members on a project of Web- Crawling.
The very first step of the project, deals with extracting the HTML code of the web page.
So, let's see how we can do it:
We need two extra namespaces than usual, they are:
using System.Net;
using System.IO;

and the code is:

HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://lpu.in");
request.UserAgent = "LPU Crawler";
WebResponse response = request.GetResponse();
Stream stream = response.GetResponseStream();
StreamReader reader = new StreamReader(stream);
string httptxt = reader.ReadToEnd();

U can change the url as u wish, and the name of the user agent too. "HttpWebRequest" belongs to the namespace "System.Net" and "Stream" to "System.IO"
"httptxt" now has html source of the webpage, play with it as you want to.

Thursday, 11 August 2011

Special Post about U.S. Debt Crisis, to give an insight into causes of recession, inflation and global bankruptcy.


How to create a connection string in Visual Studio (C#.net)

1. In the solution explorer of Visual Studio, open the 'web.config' file
2. Find '<connectionStrings/>' under <configuration> tag and delete it.

3. Now determine the connection string of your database, goto server explorer in visual studio and right click on your database to navigate to its properties. copy the value of field Connection String.

 

4. Now  create a new tag '<connectionStrings>' and write <add name="ANY_NAME" connectionString="PASTE_CONNECTION_STRING_HERE"/>; AND CLOSE IT WITH
'</connectionStrings>'



5. YOU ARE DONE!!!

Wednesday, 10 August 2011

Tic-Tac-Toe JavaScript





 
Player 1
     
      Player 2

Tic-Tac-Toe With JavaScript

<html>
<head>
<title></title>
<style type="text/css">

.style1
{
width: 100%;
}
.style2
{
height: 34px;
}
</style>
<script type="text/javascript" language="javascript" >
var p = 0;
var count = 0;
var player1 = "Player 1";
var player2 = "Player 2";

function enable() {
if (document.getElementById("textBox1").value != "") {
player1 = document.getElementById("textBox1").value;

}
if (document.getElementById("textBox2").value != "") {
player2 = document.getElementById("textBox2").value;
}

var i = 1;
var x = "button";
var y
for (i = 1; i <= 9; i++) {

y = x + i;
document.getElementById(y).disabled = false;
document.getElementById(y).value = "";
p = 0;
count=0;
}
document.getElementById("button10").disabled = true;
document.getElementById("textBox1").disabled = true;
document.getElementById("textBox2").disabled = true;

document.getElementById("play").innerHTML = "<marquee>" + player1 + " your turn!!!" + "</marquee>";


}
function play(textstring) {
document.getElementById(textstring).value = p;
document.getElementById(textstring).disabled = true;
if (p == 0) {
p = 1;

}
else { p = 0;}
count++;
check();
}
function check() {




if ((document.getElementById("button1").value == document.getElementById("button2").value && document.getElementById("button1").value == document.getElementById("button3").value && document.getElementById("button1").value != "") || (document.getElementById("button1").value == document.getElementById("button4").value && document.getElementById("button1").value == document.getElementById("button7").value && document.getElementById("button1").value != "") || (document.getElementById("button1").value == document.getElementById("button5").value && document.getElementById("button1").value == document.getElementById("button9").value && document.getElementById("button1").value != "") || (document.getElementById("button4").value == document.getElementById("button5").value && document.getElementById("button4").value == document.getElementById("button6").value && document.getElementById("button4").value != "") || (document.getElementById("button2").value == document.getElementById("button5").value && document.getElementById("button2").value == document.getElementById("button8").value && document.getElementById("button2").value != "") || (document.getElementById("button3").value == document.getElementById("button6").value && document.getElementById("button3").value == document.getElementById("button9").value && document.getElementById("button3").value != "") || (document.getElementById("button3").value == document.getElementById("button5").value && document.getElementById("button3").value == document.getElementById("button7").value && document.getElementById("button3").value != "") || (document.getElementById("button7").value == document.getElementById("button8").value && document.getElementById("button7").value == document.getElementById("button9").value && document.getElementById("button7").value != "")) {


if (p == 0) {
alert(player2+" is the winner");
document.getElementById("play").innerHTML = "<marquee>" + player2 + " wins!!!" + "</marquee>";
}
else {
alert(player1 + " is the winner");
document.getElementById("play").innerHTML = "<marquee>" + player1 + " wins!!!" + "</marquee>";
}
disable();
document.getElementById("button10").disabled = false;
}
else if (count == 9) {
alert("Sorry, it's a draw");
document.getElementById("play").innerHTML = "<marquee>Sorry, it's a draw</marquee>";
document.getElementById("button10").disabled = false;
}
else {
if (p == 0) {

document.getElementById("play").innerHTML = "<marquee>" + player1 + " your turn!!!" + "</marquee>";
}
else { document.getElementById("play").innerHTML = "<marquee>" + player2 + " your turn!!!" + "</marquee>"; }

}



}
function disable() {


var i = 1;
var x = "button";
var y
for (i = 1; i <= 9; i++) {

y = x + i;
document.getElementById(y).disabled = true;
}
}

</script>
</head>

<body>
<form id="form1" runat="server">
<div>

<table class="style1">
<tr>
<td colspan="3">
<asp:Label ID="label2" runat="server"></asp:Label>
</td>
<td>
<p id="play"></p>&nbsp;</td>
</tr>
<tr>
<td class="style2">
<input id="button1" type="button" onclick="play(form1.button1.id)" disabled="true" />
</td>
<td class="style2">
<input id="button2" type="button" onclick="play(form1.button2.id)" disabled="true" />
</td>
<td class="style2">
<input id="button3" type="button" onclick="play(form1.button3.id)" disabled="true" />
</td>
<td class="style2">
Player 1
</td>
</tr>
<tr>
<td>
&nbsp;</td>
<td>
&nbsp;</td>
<td>
&nbsp;</td>
<td>
<input id="textBox1" type="text"/>
</td>
</tr>
<tr>
<td>
<input id="button4" type="button" onclick="play(form1.button4.id)" disabled="true" />

</td>
<td>
<input id="button5" type="button" onclick="play(form1.button5.id)" disabled="true" />

</td>
<td>
<input id="button6" type="button" onclick="play(form1.button6.id)" disabled="true" />

</td>
<td>
<input id="button10" type="button" value="Start" onclick="enable()" />

</td>
</tr>
<tr>
<td>
&nbsp;</td>
<td>
&nbsp;</td>
<td>
&nbsp;</td>
<td>
Player 2</td>
</tr>
<tr>
<td>
<input id="button7" type="button" onclick="play(form1.button7.id)" disabled="true" />

</td>
<td>
<input id="button8" type="button" onclick="play(form1.button8.id)" disabled="true" />

</td>
<td>
<input id="button9" type="button" onclick="play(form1.button9.id)" disabled="true" />
</td>
<td>
<input id="textBox2" type="text"/>
</td>
</tr>
</table>

</div>
</form>
</body>

</html>