Wednesday, 5 June 2013

Creating a simple app [textweb]

Text web

In simple,it is internet on sms. The idea behind this is simple,suppose a person X is in some important work and he cannot watch tv,but he wants to know the cricket score in 4-5 seconds.Guess what ! then you think of textweb's @cricinfo or @whatsontv for knowing tv programmes. :-) 

How it Works ?  

Developer chooses a website he wants.Using scripting language preferably PHP(easy and simple) the website is scraped into texts and then the scraped PHP file is hosted in some free web hosting sites.Developer has to choose a tag in txtweb's developer website.So,using textweb's number a user sends a request to the textweb server and using the tag the user gives it redirects to the developers page from where the text is extracted and given back to the user. Isn't is easy and simple? Go build your own apps :-)

How to Develop a textweb app?

Step 1 : register as a developer here http://developer.txtweb.com/ 

Step 2: After login go to dashboard. There click on "create new service" . Have a look at the image below for reference.


Step 3: Block your service name. Check for the availability.Click save and next.Scroll down and click Go to Dashboard which is prefixed with do this later.

Step 4: Think of a useful idea and a good website which views your idea.

Step 5: Now register with a free web hosting service, you can find it in google. I use freewebhostingarea.com as it has a latest version of php.You can find a lot out there ! .

Step 6: You can test your php code either in Xampp or Lamp or Wamp by using localhost or  you can directly write your scripts in free web hosting sites and check. Choice is your's.

Step 7: First check whether you are getting the webpage by copy pasting the below code with your own website url. Replace the $url with whichever link you want to scrap !
 

<html>
<head>
</head>
<body>
<?php
$url= "http://www.gsmarena.com/nokia_lumia_925-5451.php"
$content = file_get_contents("$url");
echo $content;
?>
</body>
</html>

Note: you can learn php from here http://www.php.net/manual/en/index.php

Step 8: View the source page of the website by right click -> View source page.

Step 9: Am referring the url http://www.gsmarena.com/nokia_lumia_925-5451.php so in 201th line you can find this <div id="specs-list">.
I need only the specs of the mobile when i choose a phone in the list developer provides me.Anyone who views this first can build the app for gsmarena :-p as no one has created one :-)
Now, i need to scrap the website from 201th line 

Note: text web does not support images,it is only for text 

Step 10 : As you can observe in the source page that the whole specs is in a table and each spec is in a row so how do i pick only certain rows? "Split it up".
like the code below
<html>
<head>
</head>
<body>
<?php
$msg=$_GET['txtweb-message'];
if($msg==NULL)
{
$array=null;
$content=file_get_contents("$url");
$first=strpos($content,'<div id="specs-list">');
$last=strpos($content,'</div>',$first+1);
for($i=$first;$i<$last;$i++)
{ 
$array=$array.$content[$i];
}
echo $array;
?>
</body>
</html>

$_GET is used to get a input from the user . While a user access a text web app he just types @whatsontv to 9266592665 so whatever scrapped website @whatsontv is linked to will be sent . suppose after that the service requires a input from the user say to choose 1.hindi 2.english blah blah! so user has to type @whatsontv 1 to 9266592665 to get the service so that 1 which is given as input is accessed by this $_GET['txtweb-message'];

Now a question for you ! how would u access multiple inputs? 
Hint: to use strip_tags function in php ! try yourself ! logic is tell the user to input by seperating with a comma or a full stop or a blank space.Use Strip_tags function reference  http://php.net/manual/en/function.strip-tags.php 

strpos() is used to tell that the string starts from here ! strpos(' ',' ',' ') totally 3 parameters ! now observe that in the $first there is only 2 parameters ! y? because the 1st parameter is for from where that is whole website nothing but $content in the above code then 2nd parameter is from where that is <div> tag coz the specs start from there ! then is the reference parameter it is null for $first coz there is no reference as it is the first string! for $last $first is the reference ! hope u got it :-) 

Step 11 : After hosting scrapping and everything is done go to dashboard in txtweb website there note down the service key and add it like the code shown below to your php script.below i have added my own service key use your own service key to get access to your service !
<head>
<meta name="txtweb-appkey" content="f760a7df-105b-4d96-bb41-ad1d6d2e14cc"/>
</head>

Step 12 : Click on the blocked service you created and provide the link of your script wherever it is hosted and proceed next -> next.

Step 13: You can check your service with the emulator in the website ! happy textwebbing !

Step 14 :   Now get familiar with the php function and you are all set to develop apps !

Please comment and share this ! 


.                                                                                         

Thursday, 9 May 2013

How college or company computer networks work ?

My college or company has LAN and each computer should be having an IP ,but is this the same IP seen by others in the internet ? How is this happening ? what is that which is making this changes ? How exactly is this network working ? All these are the common questions that would have been haunting you.
   Well,This post is to explain in detail how this works and what are the flaws in it and a detailed explanation of how it works.

All this is done through a simpler approach to address allocation by "NAT"[network address translation ].considering a fact that there are hundreds of computers connected and all are using some same address space example : 10.0.0.0/24 . computers within that network can send packets to each other using 10.0.0.0/24 addressing. However, packets forwarded beyond the home network into large global Internet clearly cannot use these addresses(as either source or a destination address) because there are different other companies or colleges using this block of addresses.That is, the 10.0.0.0/24 addresses only have meaning within the given  home network.But if private addresses only have meaning within a given network,how is addressing handled when packets are sent to or received from the global internet,where addresses are necessarily unique ? the answer lies in understanding NAT.

The NAT enabled router doesn't look like a router to the outside world.Instead the NAT router behaves to the outside world as a single device with a single IP address.In figure, all traffic leaving the home router for the larger Internet has a source IP address of 138.76.29.7, and all traffic entering the home router must have a destination address of 138.76.29.7 . In essence, the NAT-enabled router is hiding the details of the home network from the outside world.(As an inside, you might wonder where the home network computers get their addresses and where the router gets its single IP address..often, the answer is the same - DHCP aka dynamic host configuration protocol , The router gets its addresses to computers within the NAT-DHCP-router -controlled home network's address space. )

If all datagrams arriving at the NAT router from the WAN have the same destination IP address, then how does the router know the internal host to which it should forward a given datagram ? the trick used is NAT translation table at the NAT router, and to include port numbers as well as IP addresses in the table entries.
   Consider the example in figure, Suppose  a user sitting in a home network behind host 10.0.0.1 requests a Web page on some web server (port 80) with IP address 128.119.40.186. The host 10.0.0.1 assigns the (arbitrary) source port number 3345 and sends the datagram into the LAN. The NAT router receives the datagram,generates a new source port number 5001 for the datagram, replaces the original source port number 3345 with the new source port number 5001. When generating a new source port number, the NAT router can select any source port number that is not currently in the NAT translation table. NAT in the router also adds an entry to its NAT translation table.The web server, blissfully not aware that the arriving datagram containing the HTTP request has been manipulated by the NAT router,responds with the datagram whose destination address is the IP address of the NAT router,and whose destination port number is 5001. When this datagram arrives at the NAT router,the router indexes the NAT translation table using the destination IP address and destination port number to obtain the appropriate IP address (10.0.0.1) and port number(3345)  for the browser in the home network. The router then rewrites the datagram's destination address and destination port number, and forwards the datagram into the home network.

The only problem with NAT is a method of hack called "connection reversal".Hope you loved the post.

Wednesday, 17 April 2013


MRAM - Future MEMORY

MRAM is a next-generation memory technology, based on electron spin rather then its charge. Often referred to as the "holy-grail of memory", MRAM is fast, high-density and non-volatile and can replace all kinds of memories used today in a single chip.

Not understanding ? lets take a step by step analysis of what memory is and get back to this .

Today i'm gonna tell you about the arising technology in Memory which is the most important thing in a computer without which it wouldn't have existed !! Lets see what is the present technology ! what is the RAM's we have in our laptop's and Desktop's.How it works ? Keep reading ...

RAM, or Random Access Memory, is your computer’s short term memory. If your computer needs information and does not find the RAM, it then needs to journey to the hard drive to try and retrieve the data.
There are 2 types of RAM presently and they are : 

Dynamic RAM is the most common type of memory in use today. Inside a dynamic RAM chip, each memory cell holds one bit of information and is made up of two parts: a transistor and a capacitor. These are, of course, extremely small transistors and capacitors so that millions of them can fit on a single memory chip. The capacitor holds the bit of information -- a 0 or a 1.The transistor acts as a switch that lets the control circuitry on the memory chip read the capacitor or change its state.

Static RAM uses a completely different technology. In static RAM, a form of flip-flop holds each bit of memory.A flip-flop for a memory cell takes 4 or 6 transistors along with some wiring, but never has to be refreshed. This makes static RAM significantly faster than dynamic RAM. However, because it has more parts, a static memory cell takes a lot more space on a chip than a dynamic memory cell. Therefore you get less memory per chip, and that makes static RAM a lot more expensive.

Okay, now you may be having a question,What is this DDR2 or DDR3 which i see in my laptop config.Well let me explain that in detail.
The term “DDR” stands for Double Data Rate RAM.Double Data Rate RAM was capable of two data transfers per clock cycle, giving it twice the theoretical peak bandwidth of previous SDRAM while running at the same clock speed.
DDR2 and DDR3 are improvements on the same technology and further increase the number of data transfers per clock cycle. DDR2 RAM provides 4 data transfers per cycle, while DDR3 increases the number to 8. Assuming a base clock speed of 100Mhz, DDR RAM will provide 1600 MB/s of Bandwidth, DDR2 provides 3200 MB/s, and DDR3 provides 6400 MB/s. More is always better!

So now you know about your RAM.Now lets see what are the scientists upto?
Magnetoresistive random-access memory (MRAM) , Yes This is what i wanted to talk about..
Wikipedia Says "data in MRAM is not stored as electric charge or current flows, but by magnetic storage elements.The simplest method of reading is accomplished by measuring the electrical resistance of the cell. A particular cell is (typically) selected by powering an associated transistor that switches current from a supply line through the cell to ground. Due to the magnetic tunnel effect, the electrical resistance of the cell changes due to the orientation of the fields in the two plates. By measuring the resulting current, the resistance inside any particular cell can be determined, and from this the polarity of the writable plate. Typically if the two plates have the same polarity this is considered to mean "1", while if the two plates are of opposite polarity the resistance will be higher and this means "0". For more ...

"Carbon nanotubes grow randomly and it is not possible to control either their position or direction. Therefore I have applied an electrical field to guide the tubes as they grow," says Johannes Svensson.

Just imagine transistors being replaced by nanotubes with MRAM.how efficient,faster computers would be.Moreover the main advantage would be Battery life. As the size of the transistors is reduced in order to increase their speed, problems arise that lead to, among other things, increased energy consumption and large variation in the transistor properties.Hence laptops with GB's of RAM and TB's of hardisk with around 15hrs battery backup with faster clock speed processors,these are all just a year far away.

One more info in the research field about MRAM is about 3D spin MRAM -
Researchers from the University of Cambridge in the UK have developed the world's first 3D microchip, based on Spintronics technology. The chip basically uses atoms to store and transfer the data - and not electronic transistors. This may lead to 3D MRAM chips that have a large memory density - thousands of times larger than what's available today.To create this chip they used sputtering - effectively making a sandwich on a silicon chip of cobalt, platinum and ruthenium atoms. The cobalt and platinum atoms store the digital information in a similar way to how a hard disk drive stores data. The ruthenium atoms act as messengers, communicating that information between neighboring layers of cobalt and platinum. Each of the layers is only a few atoms thick.

This is just a software information box:
CPU-Z is a freeware that gathers information on some of the main devices of your system.
Download link : http://www.cpuid.com/downloads/cpu-z/1.63-setup-en.exe

I would Say "God of Computer Languages"

C++ (pronounced "see plus plus") is regarded as an intermediate-level language, as it comprises both high-level and low-level language features.Developed by Bjarne Stroustrup ,C++ was originally named C with Classes, adding object oriented features, such as classes, and other enhancements to the C programming language

So this is about the history. You can find a lot about it in Wikipedia .I am not dealing with any theory stuff because there is a lot about it in internet.Google is the best friend.

Wat is that different thing i want to talk about C++ is that about STL (standard template library) . You can always practice improving your skills in coding by referring to this web pages :
this is the same websites i referred in my previous post.If  you gone through you can skip this part. 

CodeChef

In 2009, Turakhia started and spearheaded the CodeChef initiative which is a non-commercial coding and programming competition to challenge and engage the developer community in India.

SPOJ 
(Sphere Online Judge) is an online judge system with over 100,000 registered users and over 10000 problems. The solution to problems can be submitted in over 40 languages including C, C++, Java, Python, C#, Go, Haskell, OCaml, and F#, Ruby, Icon, Intercal,Pike. SPOJ has a rapidly growing problem set/tasks available for practice 24 hours/day, including many original tasks prepared by the community of expert problem setters associated with the project.

I personally suggest this to be like the best and ultimate of all.I suggest you that its always a good job to go in the order of websites i have suggested.

TOP CODER
Top Coder is a company which administers contests in computer programming. Top Coder hosts fortnightly online competitive programming competitions — known as SRMs or "single round matches" — as well as weekly competitions in design and development. The work in design and development produces useful software which is licensed for profit by Top Coder. Competitors involved in the creation of these components are paid royalties based on these sales. The software resulting from algorithm competitions — and the less-frequent marathon matches — is not usually directly useful, but sponsor companies sometimes provide money to pay the victors. Statistics (including an overall "rating" for each developer) are tracked over time for competitors in each category.
Link : http://www.topcoder.com/

Now getting back to stl , stl is a library where you can find inbuilt functions. It has various functions like sort,map,vector etc.. How can it be useful ? If  you know stl functions you can embed your code with this functions and shorten your code , thus reducing the size . Time of execution can also be reduced by using the proper functions in stl . Again stl is not the only solution and the best too.But what i say is most of the best coders would have used stl before getting in to a stage of professional coding.

Well am not gonna teach you stl here.Again there are lot of websites doing this job.Below is the link where you can always refer to a website which has a wide range of stl functions with examples.
Link : http://www.cplusplus.com/reference/stl/

Compilers :
As mentioned in previous post the same links are provided :

windows : https://www.youtube.com/watch?v=DnXM4lsuy6E
mac : https://www.youtube.com/watch?v=4JPSt7ZIF4M
For linux it has a inbuilt gcc compiler if u still want to use a compiler with GUI you can go for Code Blocks again.You can follow up from this link https://www.youtube.com/watch?v=pSbIEBpI8js .

Sick of Downloading software use online compilers : Ide One

Ah manh ! enough of this Computer Languages , this would be few people's reaction . Lets read about Technologies in the present 0's and 1's world in the next post. Stay tuned !! 

Editing and Compiling C Code

C is what's referred to as a compiled language, meaning you have to use a compiler to turn the code into an executable file before you can run it. The code is written into one or more text files, which you can open, read and edit in any text editor, such as Notepad in Windows, TextEdit on a Mac, and gedit in Linux. An executable file is something the computer can run (execute). The compiler checks the code for errors and, if it seems to be error-free, creates an executable file.

First let’s revise basics , what we write as a programmer its in the high level language and the computer do not understand the high language(C,C++,Java). The only language that the computer understands is the language of 1's and 0′s that is the Binary language.



Now enough of theory ! Lets start seeing about practically how we can write code (Programmes)  and what are the compilers.I am providing tutorial links for the best compilers available now and this is only for c.I will provide information on c++,python,java,c# in upcoming days . 

windows : https://www.youtube.com/watch?v=DnXM4lsuy6E
mac : https://www.youtube.com/watch?v=4JPSt7ZIF4M
For linux it has a inbuilt gcc compiler if u still want to use a compiler with GUI you can go for Code Blocks again.You can follow up from this link https://www.youtube.com/watch?v=pSbIEBpI8js .

Sick of Downloading software use online compilers : Ide One

Now i have something more information for you.U want to be a greatest coder and stand as a better coder among your friends? If Yes, i have this online coding websites where you can develop your coding skills by their wide set of various programming questions.

CodeChef

In 2009, Turakhia started and spearheaded the CodeChef initiative which is a non-commercial coding and programming competition to challenge and engage the developer community in India.

SPOJ 
(Sphere Online Judge) is an online judge system with over 100,000 registered users and over 10000 problems. The solution to problems can be submitted in over 40 languages including C, C++, Java, Python, C#, Go, Haskell, OCaml, and F#, Ruby, Icon, Intercal,Pike. SPOJ has a rapidly growing problem set/tasks available for practice 24 hours/day, including many original tasks prepared by the community of expert problem setters associated with the project.

I personally suggest this to be like the best and ultimate of all.I suggest you that its always a good job to go in the order of websites i have suggested.

TOP CODER
TopCoder is a company which administers contests in computer programming. TopCoder hosts fortnightly online competitive programming competitions — known as SRMs or "single round matches" — as well as weekly competitions in design and development. The work in design and development produces useful software which is licensed for profit by TopCoder. Competitors involved in the creation of these components are paid royalties based on these sales. The software resulting from algorithm competitions — and the less-frequent marathon matches — is not usually directly useful, but sponsor companies sometimes provide money to pay the victors. Statistics (including an overall "rating" for each developer) are tracked over time for competitors in each category.
Link : http://www.topcoder.com/

If anyone interested in reading C language through books or ebooks or pdf's i suggest to read this book
Link : http://www.scribd.com/doc/97499199/c-and-Data-Structures-Balaguruswamy 

In my next post i will be introducing you to the world of c++.stay tuned !