Monday, December 19, 2011

Science for Kids - Refraction of Light – Spoon in glass experiment

Thanks to all kids and their parents who responded heavily to me for my first science article on Ice on a string. Today I am going to take you through another interesting experiment and some cool science concepts. Here we go!!!
Spoon!!! Spoon is made of very hard material - Steel. It is difficult or not possible to break spoon with hands. What if I break spoon first and bring it back to its original straight shape? Believe me it is very easy. The experiment we are going to understand today will teach you how to break spoon and bring it back to its original shape.
Take one glass and fill water to the half of glass. Put one steel spoon in glass and watch. What do you see? Spoon in a glass is broken. Now take out the spoon. What do you see? Spoon is back to its original and it is not broken.

Tuesday, December 13, 2011

Science for Kids - Ice on a String – Pick Ice cube using thread experiment

If I tell you to pick up an Ice cube using thread what would be your reaction? Of course the condition is, you should not tie a knot to Ice cube using thread. I know some of you must be started thinking me as fool.
Ok, before thinking hard, let’s try the experiment. So our today’s Science project with Ice will require following things – One Ice cube, one thread about 1 feet length, Salt, small cup of water.
Things mentioned above are easily available. Ok here we go, take a thread and insert it into a cup of water. Let the thread be immersed in water until it becomes completely wet. Then lay the string or thread onto ice cube. Make sure that at least an inch of thread is touching the Ice surface. Now sprinkle salt on thread area which is touching the Ice surface. Wait for at least 30 seconds and then pick the thread. You will be amazed to see that, Ice cube also gets picked up by thread.
How come Ice got picked by thread even if I did not tie Ice to thread?
Science Fact –
Let’s understand the facts. If we mix saline substance to other substance and it gets dissolved in the other substance then melting point of that other substance get reduced.
What is melting point – The melting point of a solid substance is the temperature at which it changes the state from solid to liquid. For example, the temperature at which Ice turns into water again is called as melting point of Ice. The normal melting point of Ice is 0 degrees or 0degrees is the temperature at which Ice turns back to water.
Salt (or scientific name – NaCl – Sodium Chloride) is saline substance. When we sprinkle salt on Ice then melting point of Ice is reduced. Means Ice will not turn to water at 0 degrees rather below the 0 degrees temperature. Hence melting point of Ice is reduced because of salt.
When you lay wet string on Ice and sprinkled salt, Ice cube started melting at temperature much below than 0 degrees.  That is temperature of Ice cube surface which is in contact with salt dropped and turned into water.  When the temperature of water regains its original temperature, melted water freezes back to Ice. Thread becomes the part of Ice and Ice cube lifts up easily.
If we mix saline liquid with other substances, then melting point reduced because mixed saline resists crystallization of other substance. More the salinated liquid, more reduction in the melting point. Pure solid state substance will always have high melting point as compared to impure solid state substances.
If you live in a place that has lot of snow, this is the reason why salt is sprinkled on snow during winter on roads by highway departments. This reduces melting point of snow and roads become free of snow and traffic can continue.

If you use Ice and salt in correct ratio then you can lower temperature to -23 degree Celsius. This mixture is widely used in many industries and of course to prepare everyone’s favorite – IceCream.
Hope above experiment was good learning experience for you and you did not get bored.

Stay tuned for more in coming days…
Cheers…

Happy Salting!!!

Click here to go Back to experiments list…

Science for kids

Today I have decided to share my knowledge of science experiments with you. The experiments that I am going to demonstrate are very basic and most suitable for kids in age range 7 to 16.
In these experiments I will tell few concepts, the reasoning behind behavior of matters and of course few images demonstrating the experiments.

It was fantastic experience for me to conduct those experiments on my own. I hope you will also gain some knowledge from these experiments which will help you in your career and will definitely shape your learning curve. I will make sure that you enjoy a wide range of information and science facts that are sure to surprise and amaze you.

Here is the list of topics. Click on the links to visit the particular experiment –

Ice on a String – Wow, Pick Ice cube using thread…

Refraction of light - Breaking sppon in glass of water...

Stay tuned for more…

Monday, December 12, 2011

Uploading large file to Azure blob storage and httpRuntime maxRequestLength

Recently I was told to write a code for uploading large size files to Azure Blob storage from an aspx page. I asked for specifications of size of files. I was told that file to be uploaded will vary from 1MB to anything.
When I had actually implemented a code for file upload, things were working smoothly for the file up to 4MB. For all other files having size more than 4MB, I was receiving many errors.
Those errors included, time out errors, maxRequestLength exceeded, operation could not be completed, and my favorite error – “Internet explorer cannot display the web page”.
I had used normal asp.net file upload control in my web role and a very standard code to upload file to Azure Blob storage. After tweaking some code segments it finally worked. Following is the code segment used for uploading big files on a button click to Azure Blob storage from web role or web site page.
First read all the configuration values from project. I am here using web role project therefore my code to read configuration values will be as follows. If you are using simple asp.net web site project then your code to read configuration values will be different.
protected void btnUpload_Click(object sender, EventArgs e)
{
//using some local variables
string packageFilePath = string.Empty;
string packageFileName = string.Empty;
string referenceFileName = string.Empty;
string packageFileURL = string.Empty;
#region read required configuration values
            Container = RoleEnvironment.GetConfigurationSettingValue("ContainerName");
            AccountName = RoleEnvironment.GetConfigurationSettingValue("AccountName");
            SharedKey = RoleEnvironment.GetConfigurationSettingValue("SharedKey");
            blobEndPoint = RoleEnvironment.GetConfigurationSettingValue("BlobStorageEndpoint");
            tableEndpint = RoleEnvironment.GetConfigurationSettingValue("TableStorageEndpoint");
            #endregion

//create cloud blob client
CloudBlobClient blobClient = new CloudBlobClient(blobEndPoint, new StorageCredentialsAccountAndKey(AccountName, SharedKey));

// For large file copies you need to set up a custom timeout period and using parallel settings appears to spread the copy across multiple threads
// if you have big bandwidth you can increase the thread number below because Azure accepts blobs broken into blocks in any order of arrival.
blobClient.Timeout = new System.TimeSpan(1, 0, 0);
blobClient.ParallelOperationThreadCount = 2;

//get container reference           
CloudBlobContainer container = blobClient.GetContainerReference(Container);

//setup permission on container to be public
var permissions = new BlobContainerPermissions();
permissions.PublicAccess = BlobContainerPublicAccessType.Container;
container.SetPermissions(permissions);

//retrieving file details. uploadCSPKG is the name of my file upload control              
if (uploadCSPKG.HasFile)
{
try
{
                  packageFileName = Path.GetFileName(uploadCSPKG.FileName);

//attaching application name before file name so as to create hierarchy in blob. txtApplicationName is my text box where in user provides sname for logical folder in blob under which file will be uploaded.
referenceFileName = txtApplicationName.Text + "/" + packageFileName;

                  uploadCSPKG.SaveAs(Server.MapPath("~/") + packageFileName);
                  packageFilePath = Server.MapPath("~/") + packageFileName;
            }
            catch (Exception ex)
            {
                throw ex;
            }
      }

//open the stream and upload package file to blob
using (FileStream fs = File.OpenRead(packageFilePath))
{
CloudBlob blob = container.GetBlobReference(referenceFileName);
      blob.UploadFromStream(fs);
      packageFileURL = blob.Uri.AbsoluteUri;
}
}

The above is the complete code required to perform a file upload to Azure blob. Apart from this, you will need to do one more configuration related to ASP.NET runtime setting using httpRuntime tag in web.config of your application.
Add following line in web.config under <system.web> -
<httpRuntime maxRequestLength="51200" enable ="true" executionTimeout="45"/>

Here I assume that, my file size will never exceed the value provided in maxRequestLength attribute. If you feel the size of file to be uploaded can exceed above value then you can change the value as per your need. So with the above setting of maxRequestLength, you should be able to upload file upto sizes of 50MB. If you wish to upload file of size more than 50MB then increase the value under maxRequestLength attribute.
maxRequestLength  - Indicates the maximum file upload size supported by ASP.NET. The size specified is in kilobytes. The default is 4096 KB (4 MB).
Therefore I was able to add 4MB file previously without any difficulty whereas file sizes more than 4MB was failing with various errors. The above code segment resolved the issue.
Hope this helps.
Cheers…
Happy Programming!!!