<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Surya's blog &#187; Tutorials</title>
	<atom:link href="http://www.hakc.net/category/all-tutorial-follows-in-here/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hakc.net</link>
	<description></description>
	<lastBuildDate>Sat, 25 Jul 2009 11:39:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>pyS60 Automatic SMS sender</title>
		<link>http://www.hakc.net/2009/03/28/pys60-automatic-sms-sender/</link>
		<comments>http://www.hakc.net/2009/03/28/pys60-automatic-sms-sender/#comments</comments>
		<pubDate>Sat, 28 Mar 2009 11:05:03 +0000</pubDate>
		<dc:creator>Surya</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Automatic SMS]]></category>
		<category><![CDATA[pyS60]]></category>

		<guid isPermaLink="false">http://www.hakc.net/?p=52</guid>
		<description><![CDATA[Ever felt like sending a predefined message to someone automatically after x seconds? Annoy someone ? If you have a smartphone with pyS60 installed it&#8217;s just 13 lines of copy-paste. Code and instructions after the break. The Script : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 [...]]]></description>
			<content:encoded><![CDATA[<p>Ever felt like sending a predefined message to someone automatically after x seconds? Annoy someone ? If you have a smartphone with pyS60 installed it&#8217;s just 13 lines of copy-paste. Code and instructions after the break.</p>
<p><span id="more-52"></span></p>
<p>The Script :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;"># 25/03/2009 -- Surya -  HAKC.NET</span>
<span style="color: #ff7700;font-weight:bold;">import</span> messaging
<span style="color: #ff7700;font-weight:bold;">import</span> appuifw
<span style="color: #ff7700;font-weight:bold;">import</span> e32 <span style="color: #808080; font-style: italic;">#import the modules.</span>
number = <span style="color: #483d8b;">&quot;123456789&quot;</span> <span style="color: #808080; font-style: italic;">#define the recipient phone number here</span>
text = <span style="color: #483d8b;">&quot;Hi :}&quot;</span> <span style="color: #808080; font-style: italic;">#define the message here</span>
i = <span style="color: #ff4500;">0</span> <span style="color: #808080; font-style: italic;">#counter initial value</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">while</span> <span style="color: #008000;">True</span>: <span style="color: #808080; font-style: italic;">#infinte loop</span>
	tex = appuifw.<span style="color: black;">note</span><span style="color: black;">&#40;</span>u<span style="color: #483d8b;">&quot;Sending!&quot;</span><span style="color: black;">&#41;</span> <span style="color: #808080; font-style: italic;">#Throw a dialog box just before the message is sent</span>
	messaging.<span style="color: black;">sms_send</span><span style="color: black;">&#40;</span>number, text<span style="color: black;">&#41;</span> <span style="color: #808080; font-style: italic;">#Send the message</span>
	tex = appuifw.<span style="color: black;">note</span><span style="color: black;">&#40;</span>u<span style="color: #483d8b;">&quot;Sent!&quot;</span><span style="color: black;">&#41;</span> <span style="color: #808080; font-style: italic;">#Throw a dialog box after the message is sent</span>
	<span style="color: #ff7700;font-weight:bold;">print</span> i <span style="color: #808080; font-style: italic;">#Print the counter in Python Console</span>
	i=i+<span style="color: #ff4500;">1</span> <span style="color: #808080; font-style: italic;">#Increment the counter</span>
	e32.<span style="color: black;">ao_sleep</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">300</span><span style="color: black;">&#41;</span> <span style="color: #808080; font-style: italic;">#Wait for 5 minutes (value to be given in seconds) before the next </span>
&nbsp;
<span style="color: #808080; font-style: italic;"># NOTE : You do get charged for every text sent (unless it's free). I don't endorse spamming.</span></pre></td></tr></table></div>

<p>The script is not a biggie. It just sends sends the predefined text to the predefined number in an infinte <em>While</em> loop which sleeps for the defined seconds before the next iteration.</p>
<p>How to execute ? If you don&#8217;t have the Python installed in your <a href="http://www.forum.nokia.com/Resources_and_Information/Explore/Software_Platforms/S60/">Series 60</a> phone, get it <a href="http://sourceforge.net/projects/pys60">here</a>. Just copy the above snippet create a new &#8216;I_am_so_kewl.<strong>py</strong>&#8216; file in your pc, paste and save the above snippet. Then transfer the file to the Python directory in the mem card/phone memory. Open Python shell in the phone (usually in the &#8216;Applications&#8217; folder), Options-&gt;Run Script-&gt; Browser for &#8216;I_am_so_kewl.py&#8217;, execute it and watch the magic happen. <em>Make sure</em> that once you run the sript you don&#8217;t exit the python shell, you can just click the menu button and python will silently run with the evil script in the background. If you&#8217;re just curious to check how many messages have been sent, just open the python shell again and you&#8217;d have the latest counter read printed (add 1 to it; I was too lazy to increment it in the script). More information on pyS60 : <a href="http://wiki.opensource.nokia.com/projects/PyS60">Nokia Wiki</a>,  <a href="http://croozeus.com/tutorials.htm">Croozeus</a> and <a href="http://www.mobilenin.com/pys60/menu.htm">Mobilenin</a>.</p>
<p>Special thanks goes to my first victim for being the guinea pig and the inspiration behind this. Some might look at the code, the other way and might put this into work for evil purpose; I don&#8217;t endorse that.</p>
<p><img id="smallDivTip" style="border: 1px solid blue; z-index: 90; opacity: 1; position: absolute; left: 25px; top: 145px;" src="chrome://dictionarytip/skin/book.png" alt="" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hakc.net/2009/03/28/pys60-automatic-sms-sender/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>The &#8220;Hello World&#8221; AJAX script</title>
		<link>http://www.hakc.net/2007/02/15/the-hello-world-ajax-script/</link>
		<comments>http://www.hakc.net/2007/02/15/the-hello-world-ajax-script/#comments</comments>
		<pubDate>Thu, 15 Feb 2007 17:36:16 +0000</pubDate>
		<dc:creator>Surya</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.hakc.net/2007/02/15/the-hello-world-ajax-script/</guid>
		<description><![CDATA[I just made this quick ajax tutorial for people who&#8217;re starting out there and want to learn AJAX. The following tutorial will teach on how to submit a simple form through php and get the stuff printed out by using AJAX. The first sect will be plain simple to just print a input string and [...]]]></description>
			<content:encoded><![CDATA[<p>I just made this quick ajax tutorial for people who&#8217;re starting out there and want to learn AJAX. The following tutorial will teach on how to submit a simple form through php and get the stuff printed out by using AJAX. The first sect will be plain simple to just print a input string and I&#8217;ll add getting some dynamic content after it.</p>
<p>So let&#8217;s get started.<br />
For most of you you may have a local server at your PC or a remote hosting, remember there&#8217;re no special requirements for this tutorial all you need is a php installed server. If you&#8217;re right starting away you can install <a href="http://www.apachefriends.org/en/xampp.html" target="_blank">XAMPP</a> which will install all defauly modules on your PC directly. I&#8217;ll be getting a good tutorial on this if I get enough requests.</p>
<p>Click below for continuing the tutorial &#8230;.</p>
<p><span id="more-11"></span><br />
For the first part we&#8217;ll do our job using two files,</p>
<blockquote><p>1) Index.php</p>
<p>2) ajax.js (The AJAX framework)</p>
<p>3) Style.css (stylesheet)</p>
<p>4) form.php (To process the submitted data)</p></blockquote>
<p>So let&#8217;s first get started with ajax.js, I&#8217;ll explain this particular framework part by part.</p>
<p>We create a new file name &#8220;ajax&#8221; with &#8220;.js&#8221; extension.</p>
<p>Open up the file in your favourite text editor anf follow the instructions that follow.<br />
We first create 4 new variables -&gt;</p>
<blockquote><p>var xml = makeXML();<br />
var form;<br />
var loading;<br />
var results;</p></blockquote>
<p><strong>xml &#8211; for creating the xml request,<br />
form &#8211; which gives the name of the form we&#8217;re going to use,<br />
loading &#8211; The div tag where the &#8220;loading&#8221; message will appear.<br />
results &#8211; The div tag where the output from the server will be shown.</strong></p>
<p>Now let&#8217;s create a XMLHttpRequest object depending on the browser the user uses. Remember Firefox owns the world! So let&#8217;s add some couple of more lines to the code.. I&#8217;ll be explaining each part by adding the comment tags corresponding to the respective lines.</p>
<blockquote><p>function makeXML () {<br />
if (typeof XMLHttpRequest == &#8216;undefined&#8217;) { // CHECK FOR IE<br />
objects = Array(<br />
&#8216;Microsoft.XmlHttp&#8217;,<br />
&#8216;MSXML2.XmlHttp&#8217;,<br />
&#8216;MSXML2.XmlHttp.3.0&#8242;,<br />
&#8216;MSXML2.XmlHttp.4.0&#8242;,<br />
&#8216;MSXML2.XmlHttp.5.0&#8242;<br />
);<br />
for (i = 0; i &lt; objects.length; i++) {<br />
try {<br />
return new ActiveXObject(objects[i]); // CREATE ACTIVEX IF IE<br />
} catch (e) {}<br />
}<br />
} else { // Else if other browser create their respective request.<br />
return new XMLHttpRequest();<br />
}<br />
}</p></blockquote>
<p>Now get&#8217;s the real part which has the vital information, but before that let&#8217;s see how does the current &#8220;ajax.js&#8221; file looks so far&#8230;</p>
<blockquote><p>var xml = makeXML();<br />
var form;<br />
var loading;<br />
var results;<br />
function makeXML () {<br />
if (typeof XMLHttpRequest == &#8216;undefined&#8217;) {<br />
objects = Array(<br />
&#8216;Microsoft.XmlHttp&#8217;,<br />
&#8216;MSXML2.XmlHttp&#8217;,<br />
&#8216;MSXML2.XmlHttp.3.0&#8242;,<br />
&#8216;MSXML2.XmlHttp.4.0&#8242;,<br />
&#8216;MSXML2.XmlHttp.5.0&#8242;<br />
);<br />
for (i = 0; i &lt; objects.length; i++) {<br />
try {<br />
return new ActiveXObject(objects[i]);<br />
} catch (e) {}<br />
}<br />
} else {<br />
return new XMLHttpRequest();<br />
}<br />
}</p></blockquote>
<p>Ok Now We&#8217;ll be adding some more lines, this time I&#8217;ll break each of them so that you understand clearly.</p>
<blockquote><p> window.onload = function () {<br />
form = document.getElementById(&#8216;form&#8217;);<br />
loading = document.getElementById(&#8216;loading&#8217;);<br />
results = document.getElementById(&#8216;results&#8217;);
</p></blockquote>
<p>Now let&#8217;s break it in parts and see how it works.</p>
<p><code>window.onload = function () {</code> -&gt; <strong>We load a function as soon as the page is called upon.<br />
</strong><br />
<code>form = document.getElementById('form');<br />
loading = document.getElementById('loading');<br />
results = document.getElementById('results');</code><br />
<strong>Remember the variables we declared at start ? now it&#8217;s time to give them some value</strong>.<br />
we give form = document.getElementById(&#8216;form&#8217;); which means to get the element names &#8220;form&#8221;.</p>
<p>Similarly loading and results are too stored.<br />
Now let&#8217;s look further more.</p>
<blockquote><p>form.onsubmit = function () {<br />
results.style.display = &#8216;none&#8217;; // Set the Display STYLE of results to &#8220;none&#8221;<br />
results.innerHTML = &#8221;; // Fill up results with NULL (Nothing)<br />
loading.style.display = &#8216;inline&#8217;; // Set the Display STYLE of loading to show up, so that whenever the user clicks a loading text/image shows up.</p></blockquote>
<p>form.onsubmit = function () { -&gt;   <strong>When the form is submitted perform the function</strong><br />
results.style.display = &#8216;none&#8217;; -&gt; <strong>Set the Display STYLE of results to &#8220;none&#8221;</strong><br />
results.innerHTML = &#8221;; -&gt; <strong>Fill up results with NULL (Nothing)</strong></p>
<p>Now let&#8217;s proceed further.</p>
<blockquote><p>xml.open(&#8216;get&#8217;, &#8216;./form.php?name=&#8217; + escape(this.name.value))</p></blockquote>
<p><strong>open the file through xml using header &#8220;get&#8221; that is form.php and we pass on the variables asked by the php file.</strong></p>
<p><strong>Observe carefully we call upon a file <strong>form.php</strong> which wants the data for it&#8217;s variable &#8220;<strong>name</strong>&#8220;.<br />
We assign the value to the variable as &#8220;<strong>this.name.value</strong>&#8220;, notice something there ? the part in the middle &#8220;<strong>name</strong>&#8221; tells the javascript to give the value of form name which has &#8216;name&#8217;.</strong></p>
<p>You maybe puzzled there, let me explain in plain words we give form.php to assign a value to the variable &#8220;name&#8221; with the form which has the id as &#8220;name&#8221; this may still be confusing but note this It&#8217;ll be cleared soon when we start the php form.</p>
<p>ok let&#8217;s go ahead and see the next few lines.</p>
<blockquote><p>xml.onreadystatechange = function () {<br />
if (xml.readyState == 4 &amp;&amp; xml.status == 200) {</p></blockquote>
<p>xml.onreadystatechange = function () { -&gt; <strong>when the data is received perform the further action.</strong></p>
<p>if (xml.readyState == 4 &amp;&amp; xml.status == 200) { -&gt; <strong>When ReadyState property is 4 and Status is 200, do the next stuff inside the loop.</strong></p>
<p>Now you may ask me about these properties let&#8217;s see -&gt;<br />
<a href="http://www.w3schools.com/ajax/ajax_xmlhttprequest.asp">Check W3&#8242;s clear explanation on these AJAX properties</a></p>
<p>Now when we have the positive response from the server let&#8217;s perform the main function.</p>
<blockquote><p>results.style.display = &#8216;block&#8217;;<br />
results.innerHTML = xml.responseText;<br />
loading.style.display = &#8216;none&#8217;;<br />
}<br />
}</p></blockquote>
<p>Let&#8217;s break &#8216;em too<br />
results.style.display = &#8216;block&#8217;; -&gt; <strong>Open up the results block</strong><br />
results.innerHTML = xml.responseText; -&gt; <strong>Paste the SERVER&#8217;s response in the div tag results.</strong><br />
loading.style.display = &#8216;none&#8217;; -&gt; <strong>Remember we set a loading tag on to display ? now when we got the data let&#8217;s switch of the loading stuff.</strong></p>
<p>Now the last part of this nasty javascript&#8230;</p>
<blockquote><p>xml.send(null); // if no data is sent, replace the results with NULL.<br />
return false;<br />
}<br />
} // Loop closed.</p></blockquote>
<p>OK <strong>AJAX.JS</strong> is complete, let me give you the complete code.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>http://hakc.net/ajax/ajax.js</p>
<p>There you go, hope I didn&#8217;t mess the stuff up yet.<br />
Now let&#8217;s move over to the main PHP Stuff.</p>
<p>I&#8217;m converting the html to special chars, till then please refer the URL below.</p>
<p>Now the index.php will be done the code is here, remember to change the extension to .php</p>
<p>http://www.hakc.net/ajax/index.txt</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>now you maybe buzzing around that won&#8217;t the loading page displayed regardless of the user submits the form or not right ? That&#8217;s why we have linked a <strong>stylesheet</strong> into it. We&#8217;ll define a property to the &#8220;loading&#8221; tag which will hide the loading tag so that it&#8217;s not executed when the page is displayed, instead when teh user submits teh form the <strong>javascript OVERRIDES the stylesheet property</strong> and displays it again.</p>
<p>Lets look over at teh stylesheet.css</p>
<blockquote><p>#loading {<br />
display: none; // It&#8217;s pretty simple it just hides it!<br />
}</p></blockquote>
<p>Here is the stylesheet, again remember to change the extension to <strong>css</strong>.</p>
<p>http://www.hakc.net/ajax/stylesheet.txt</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>Now last but not the least let&#8217;s go with the last php file which processes the data and prints us out!</p>
<p>This is pretty simple!</p>
<blockquote><p> &lt;?php<br />
$printdata=$_GET['name']; // Get the &#8220;name&#8221; data and store it in &#8220;printdata&#8221;.<br />
echo $printdata; // print the stuff stored in printdata.<br />
?&gt;</p></blockquote>
<p>Ok so there it goes the final stuff, the php code. (PS again change the ext to <strong>php</strong>)</p>
<p>http://www.hakc.net/ajax/form.txt</p>
<p><strong>Ok so here I finish this sweet tutorials, remember to reply any comments/bugs/mistakes/improvements/feedbacks. Hope everyone liked this tutorial.</strong></p>
<p><strong>PS : Yeah this is again my biggest tutorials I&#8217;ve written yet!</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hakc.net/2007/02/15/the-hello-world-ajax-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
