<?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>ADM Blog</title>
	<atom:link href="http://blog.another-d-mention.ro/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.another-d-mention.ro</link>
	<description>No matter how you see things, reality changes when you reach understanding</description>
	<lastBuildDate>Wed, 11 Aug 2010 08:07:27 +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>On typing finished jQuery plugin</title>
		<link>http://blog.another-d-mention.ro/programming/java-script/on-typing-complete-jquery-plugin/</link>
		<comments>http://blog.another-d-mention.ro/programming/java-script/on-typing-complete-jquery-plugin/#comments</comments>
		<pubDate>Wed, 11 Aug 2010 08:06:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Java Script]]></category>
		<category><![CDATA[event]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[input]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[type]]></category>
		<category><![CDATA[validation]]></category>

		<guid isPermaLink="false">http://blog.another-d-mention.ro/?p=832</guid>
		<description><![CDATA[If you are developing a form and you require certain validations; check if username is available or not for example - the way to do that is to listen for the change/focusout DOM events. You can also check it on every keypress but if the validation does some expensive checking in the background that is [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>If you are developing a form and you require certain validations; check if username is available or not for example - the way to do that is to listen for the change/focusout DOM events. You can also check it on every keypress but if the validation does some expensive checking in the background that is out of the question. So here is a really small jQuery plugin that does tell you when a user finished typing inside a text box. The way it does it is to compute the speed the user is typing with and when a delay longer than twice the speed average occurs, the event is triggered and your validation function is called. Simple enough.</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="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  $.<span style="color: #660066;">fn</span>.<span style="color: #660066;">onTypeFinished</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>func<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     <span style="color: #003366; font-weight: bold;">var</span> T <span style="color: #339933;">=</span> undefined<span style="color: #339933;">,</span> S <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> D <span style="color: #339933;">=</span> <span style="color: #CC0000;">1000</span><span style="color: #339933;">;</span>	  
     $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;keypress&quot;</span><span style="color: #339933;">,</span> onKeyPress<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;focusout&quot;</span><span style="color: #339933;">,</span> onTimeOut<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #003366; font-weight: bold;">function</span> onKeyPress<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        clearTimeout<span style="color: #009900;">&#40;</span>T<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>S <span style="color: #339933;">==</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> S <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> D <span style="color: #339933;">=</span> <span style="color: #CC0000;">1000</span><span style="color: #339933;">;</span> T <span style="color: #339933;">=</span> setTimeout<span style="color: #009900;">&#40;</span>onTimeOut<span style="color: #339933;">,</span> <span style="color: #CC0000;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
        <span style="color: #003366; font-weight: bold;">var</span> t <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        D <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>D <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>t <span style="color: #339933;">-</span> S<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">;</span> S <span style="color: #339933;">=</span> t<span style="color: #339933;">;</span> T <span style="color: #339933;">=</span> setTimeout<span style="color: #009900;">&#40;</span>onTimeOut<span style="color: #339933;">,</span> D <span style="color: #339933;">*</span> <span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #009900;">&#125;</span>
&nbsp;
      <span style="color: #003366; font-weight: bold;">function</span> onTimeOut<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
           func.<span style="color: #660066;">apply</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> S <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>	  
      <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>The way to use it:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;input[name='username']&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">onTypeFinished</span><span style="color: #009900;">&#40;</span>myValidationFunction<span style="color: #009900;">&#41;</span></pre></td></tr></table></div>

<p>And here is a small demo:<br />
<iframe src="http://blog.another-d-mention.ro/stuff/jquery/jquerytest.html" border="0" width="100%" height="100"></iframe></p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.another-d-mention.ro/programming/java-script/on-typing-complete-jquery-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Alfresco CIFS shared drive authentication problem</title>
		<link>http://blog.another-d-mention.ro/misc/alfresco-cifs-shared-drive-authentication-problem/</link>
		<comments>http://blog.another-d-mention.ro/misc/alfresco-cifs-shared-drive-authentication-problem/#comments</comments>
		<pubDate>Mon, 28 Jun 2010 16:22:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[alfresco]]></category>
		<category><![CDATA[cifs]]></category>
		<category><![CDATA[cms]]></category>
		<category><![CDATA[drive]]></category>
		<category><![CDATA[problem]]></category>
		<category><![CDATA[shared]]></category>
		<category><![CDATA[windows7]]></category>

		<guid isPermaLink="false">http://blog.another-d-mention.ro/?p=830</guid>
		<description><![CDATA[I'm a newbie in Alfresco and honestly cannot find my way in there. If you are trying to develop a WebScript or some other type of service for Alfresco, you can either upload files one by one using the web interface or you can map the CIFS shared drive (\\workstationA\Alfresco\) and use it as a [...]


Related posts:<ol><li><a href='http://blog.another-d-mention.ro/programming/the-simplest-way-to-parse-xml-in-java/' rel='bookmark' title='Permanent Link: The simplest way to parse XML in Java'>The simplest way to parse XML in Java</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/how-to-run-python-code-in-windows-batch-bat-files/' rel='bookmark' title='Permanent Link: How to run python code in Windows batch (bat) files'>How to run python code in Windows batch (bat) files</a></li>
<li><a href='http://blog.another-d-mention.ro/misc/access-all-files-on-your-hard-disk-from-the-system-tray/' rel='bookmark' title='Permanent Link: Access all files on your hard disk from the system tray'>Access all files on your hard disk from the system tray</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-831" title="Alfresco" src="http://blog.another-d-mention.ro/wp-content/uploads/2010/06/images.jpg" alt="images Alfresco CIFS shared drive authentication problem" width="150" height="43" style="margin: 0px 10px 10px 0px" /> I'm a newbie in <a title="Alfresco content management" href="http://www.alfresco.com/">Alfresco</a> and honestly cannot find my way in there. If you are trying to develop a WebScript or some other type of service for Alfresco, you can either upload files one by one using the web interface or you can map the CIFS shared drive (\\workstationA\Alfresco\) and use it as a file-system. It seems it worked just fine in Windows XP and friends but I have Windows 7 and I simply could not make it work. It requests a user name and a password but then returns a "<strong>Failed to authenticate. Invalid user or password</strong>" message  The hack I found seems really dumb and I'm sure there is a better solution out there but this works for me.</p>
<p>What you have to do is go to your hosts file (Windows\System32\drivers\etc\hosts) and add a new line in there mapping the workstaionA (Where workstationA is your computer name + the letter a) to some unused IP address.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">13<span style="color: #339933;">.</span>13<span style="color: #339933;">.</span>13<span style="color: #339933;">.</span>13 workstationA</pre></div></div>

<p>That's it, now it works and you can map it as a network drive and do your development in peace.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">net use X: \\workstationA\Alfresco <span style="color: #000000; font-weight: bold;">/</span>user:admin admin <span style="color: #000000; font-weight: bold;">/</span>persistent:<span style="color: #c20cb9; font-weight: bold;">yes</span></pre></div></div>

<p><strong>Note</strong>: admin/admin are the Alfresco default username and password, you should change that and use yours.</p>
<p>Happy codding !</p>


<p>Related posts:<ol><li><a href='http://blog.another-d-mention.ro/programming/the-simplest-way-to-parse-xml-in-java/' rel='bookmark' title='Permanent Link: The simplest way to parse XML in Java'>The simplest way to parse XML in Java</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/how-to-run-python-code-in-windows-batch-bat-files/' rel='bookmark' title='Permanent Link: How to run python code in Windows batch (bat) files'>How to run python code in Windows batch (bat) files</a></li>
<li><a href='http://blog.another-d-mention.ro/misc/access-all-files-on-your-hard-disk-from-the-system-tray/' rel='bookmark' title='Permanent Link: Access all files on your hard disk from the system tray'>Access all files on your hard disk from the system tray</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.another-d-mention.ro/misc/alfresco-cifs-shared-drive-authentication-problem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to run python code in Windows batch (bat) files</title>
		<link>http://blog.another-d-mention.ro/programming/how-to-run-python-code-in-windows-batch-bat-files/</link>
		<comments>http://blog.another-d-mention.ro/programming/how-to-run-python-code-in-windows-batch-bat-files/#comments</comments>
		<pubDate>Wed, 23 Jun 2010 12:58:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[bat]]></category>
		<category><![CDATA[batch]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[py]]></category>
		<category><![CDATA[window]]></category>

		<guid isPermaLink="false">http://blog.another-d-mention.ro/?p=829</guid>
		<description><![CDATA[Here’s the bit of tricky batch file magic that does it: 1 2 3 @setlocal enabledelayedexpansion &#38;&#38; python -x &#34;%~f0&#34; %* &#38; exit /b !ERRORLEVEL! #start python code here print &#34;hello world&#34; The way it works is that the first line of the file does two different things. 1. starts python interpreter passing the name [...]


Related posts:<ol><li><a href='http://blog.another-d-mention.ro/programming/sudoku-solver-in-python/' rel='bookmark' title='Permanent Link: Sudoku solver in python'>Sudoku solver in python</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/python/quick-python-script-explanation/' rel='bookmark' title='Permanent Link: Quick Python Script Explanation'>Quick Python Script Explanation</a></li>
<li><a href='http://blog.another-d-mention.ro/misc/view-hidden-files-with-a-keyboard-shortcut/' rel='bookmark' title='Permanent Link: View hidden files with a keyboard shortcut'>View hidden files with a keyboard shortcut</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Here’s the bit of tricky batch file magic that does it:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="python" style="font-family:monospace;">@setlocal enabledelayedexpansion <span style="color: #66cc66;">&amp;&amp;</span> python -x <span style="color: #483d8b;">&quot;%~f0&quot;</span> <span style="color: #66cc66;">%*</span> <span style="color: #66cc66;">&amp;</span> exit /b <span style="color: #66cc66;">!</span>ERRORLEVEL<span style="color: #66cc66;">!</span>
<span style="color: #808080; font-style: italic;">#start python code here</span>
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;hello world&quot;</span></pre></td></tr></table></div>

<p>The way it works is that the first line of the file does two different things.</p>
<p>1. starts python interpreter passing the name of the file in, and the -x option will tell it to skip the first line (containing .bat file code)<br />
2. When python finishes the script exits.</p>
<p>This nifty trick makes it much nicer for writing admin scripts with python on Windows. </p>


<p>Related posts:<ol><li><a href='http://blog.another-d-mention.ro/programming/sudoku-solver-in-python/' rel='bookmark' title='Permanent Link: Sudoku solver in python'>Sudoku solver in python</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/python/quick-python-script-explanation/' rel='bookmark' title='Permanent Link: Quick Python Script Explanation'>Quick Python Script Explanation</a></li>
<li><a href='http://blog.another-d-mention.ro/misc/view-hidden-files-with-a-keyboard-shortcut/' rel='bookmark' title='Permanent Link: View hidden files with a keyboard shortcut'>View hidden files with a keyboard shortcut</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.another-d-mention.ro/programming/how-to-run-python-code-in-windows-batch-bat-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FlashBuilder network issue</title>
		<link>http://blog.another-d-mention.ro/programming/flashbuilder-network-issue/</link>
		<comments>http://blog.another-d-mention.ro/programming/flashbuilder-network-issue/#comments</comments>
		<pubDate>Fri, 21 May 2010 20:54:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Flex / ActionScript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[amfphp]]></category>
		<category><![CDATA[flash builder]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[monitor]]></category>
		<category><![CDATA[network]]></category>

		<guid isPermaLink="false">http://blog.another-d-mention.ro/?p=822</guid>
		<description><![CDATA[Like most of my articles here, I try to post solutions for unusual problems I encounter now and then that may help someone someday. And this one almost made me scream. So here's the story. My DEV environment (http://dev/) is a Virtual Host mapped in the Windows host file to point to a sandboxed directory [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-thumbnail wp-image-823" style="margin-right: 10px; margin-bottom: 10px;" title="ARGHHHHHHHHHHHH" src="http://blog.another-d-mention.ro/wp-content/uploads/2010/05/girl-scream-150x150.jpg" alt="girl scream 150x150 FlashBuilder network issue" width="150" height="150" />Like most of my articles here, I try to post solutions for unusual problems I encounter now and then that may help someone someday. And this one almost made me scream.</p>
<p>So here's the story. My DEV environment (http://dev/) is a Virtual Host mapped in the Windows host file to point to a sandboxed directory somewhere on my hard drive. The Flex project I'm building uses a RemoteObject and tries to communicate with a AMFPHP gateway to do it's stuff. All good till here.</p>
<p>The weird part is that when I try to run the app, even though my flash is coming from the DEV host and the path to the gateway points to the same DEV host, the AMF calls either failed with a security exception or if they worked, they were extremely slow. The delay between a service call and a response/error was somewhere between 6 and 10 seconds.</p>
<p>Why oh why !? The AMFPHP Browser app that comes with the package works just fine so my app was at fault somehow. Tried some investigations and thanks to Firebug I found the vital clue.</p>
<p>It seems that my app was trying to make the connection to the gateway through <strong>http://localhost:37813/</strong>. WTF ?? I didn't had any reference to 'localhost' in my code, yet the app was trying to connect using that address for some reason. And quite often, the crossdomain.xml failed to load resulting in a security error.</p>
<p>So what in the world is the problem then ? Well, Flash Builder seems to be the problem (and me for not RTFM).</p>
<p>It seems that if you compile your swf with<strong> Network Monitor</strong> active, which you may not realize, especially if the window is not even opened, you have just told your swf to redirect all traffic to localhost:37813. It will compile the redirect info into your flash. Traffic may work if you have Flash Builder debugger running but try to deploy that somewhere. Heh.</p>
<p>All you have to do is turn network monitor off. Recompile your swf. Redeploy.</p>
<p>Ta da !</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.another-d-mention.ro/programming/flashbuilder-network-issue/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Zen Coding</title>
		<link>http://blog.another-d-mention.ro/misc/software/html-zen-coding/</link>
		<comments>http://blog.another-d-mention.ro/misc/software/html-zen-coding/#comments</comments>
		<pubDate>Tue, 11 May 2010 20:00:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[editor]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[zen]]></category>

		<guid isPermaLink="false">http://blog.another-d-mention.ro/?p=820</guid>
		<description><![CDATA[If you write HTML for a living, and you don't know Zen Coding yet, you are missing out big time. Zen Coding is build as a plugin for commonly used editors (including Notepad++, yey!) that allows you to write HTML, CSS and XML code 20 time faster. So writing: 1 html:xt&#62;div#header&#62;div#logo+ul#nav&#62;li.item-$*5&#62;a with a keystroke converts [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>If you write HTML for a living, and you don't know <a href="http://code.google.com/p/zen-coding/">Zen Coding</a> yet, you are missing out big time.</p>
<p>Zen Coding is build as a plugin for commonly used editors (including Notepad++, yey!) that allows you to write HTML, CSS and XML code 20 time faster. So writing:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">html<span style="color: #339933;">:</span>xt<span style="color: #339933;">&gt;</span>div#header<span style="color: #339933;">&gt;</span>div#logo<span style="color: #339933;">+</span>ul#nav<span style="color: #339933;">&gt;</span>li.<span style="color: #006633;">item</span><span style="color: #339933;">-</span>$<span style="color: #339933;">*</span><span style="color: #cc66cc;">5</span><span style="color: #339933;">&gt;</span>a</pre></td></tr></table></div>

<p>with a keystroke converts to:</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
18
19
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt; !DOCTYPE html PUBLIC <span style="color: #ff0000;">&quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;</span> <span style="color: #ff0000;">&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span> xmlns<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.w3.org/1999/xhtml&quot;</span> xml:<span style="color: #000066;">lang</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;en&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">meta</span> <span style="color: #000066;">http-equiv</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Content-Type&quot;</span> <span style="color: #000066;">content</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/html;charset=UTF-8&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">title</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">title</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;header&quot;</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;logo&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nav&quot;</span>&gt;</span>
			<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;item-1&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
			<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;item-2&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
			<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;item-3&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
			<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;item-4&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
			<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;item-5&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></pre></td></tr></table></div>

<p>Don't get this wrong, like the man said, "The purpose of ZC is not to write a full HTML page with a single line, but to help you write smaller code chunks.". Here is a video introducing the system in further detail.</p>
<p><object width="400" height="275"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=7405114&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=7405114&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="275"></embed></object></p>
<p>It is easier than it looks actually, and looking a bit over the <a href="http://code.google.com/p/zen-coding/wiki/ZenHTMLSelectorsEn">syntax</a> will make total sense. Printing the <a href="http://code.google.com/p/zen-coding/downloads/detail?name=ZenCodingCheatSheet.pdf&#038;can=2&#038;q=">cheat sheet</a> also helps <img src='http://blog.another-d-mention.ro/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' title="Zen Coding" /> </p>
<p>Also worth noticing that in Notepad++ (the only one I tried) the plugin added few more functions that help with the coding that I'm sure you'll enjoy (Jumping to the edit points is a God given). This project inspired another neat tool for PHP developers to output HTML using this syntax from code. You can find more <a href="http://code.google.com/p/zen-php/">here</a></p>
<p>I have only touched briefly on what it can do but I will certainly not author another single HTML document without the benefit of <a href="http://code.google.com/p/zen-coding/">Zen Coding</a>. </p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.another-d-mention.ro/misc/software/html-zen-coding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Check if user visited certain websites</title>
		<link>http://blog.another-d-mention.ro/programming/check-if-user-visited-certain-websites/</link>
		<comments>http://blog.another-d-mention.ro/programming/check-if-user-visited-certain-websites/#comments</comments>
		<pubDate>Tue, 11 May 2010 13:21:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Java Script]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[history]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://blog.another-d-mention.ro/?p=819</guid>
		<description><![CDATA[Today I found a website called http://www.stayinvisible.com/ that uses a really clever technique to peak in your browser history. They can't see everything of course but they can see whatever they are interested in and that is a list of web-proxy websites. So how are they doing it ? First, they have a list of [...]


Related posts:<ol><li><a href='http://blog.another-d-mention.ro/programming/java-script/on-typing-complete-jquery-plugin/' rel='bookmark' title='Permanent Link: On typing finished jQuery plugin'>On typing finished jQuery plugin</a></li>
<li><a href='http://blog.another-d-mention.ro/misc/firefox-and-user-agent-switcher/' rel='bookmark' title='Permanent Link: Firefox and User Agent Switcher'>Firefox and User Agent Switcher</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/java-script/open-and-save-files-to-desktop-without-going-to-server/' rel='bookmark' title='Permanent Link: Open and Save files to Desktop without going to Server'>Open and Save files to Desktop without going to Server</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Today I found a website called http://www.stayinvisible.com/ that uses a really clever technique to peak in your browser history. They can't see everything of course but they can see whatever they are interested in and that is a list of web-proxy websites. </p>
<p><strong>So how are they doing it ? </strong></p>
<p>First, they have a list of websites they are interested in, like i said, a list of web-proxies.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> sites <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #3366CC;">&quot;hidemyass.com&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;http://www.hidemyass.com&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;http://forum.hidemyass.com&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
    <span style="color: #3366CC;">&quot;freeproxy.ca&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;http://www.freeproxy.ca&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
    <span style="color: #3366CC;">&quot;proxy4free.com&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;http://www.proxy4free.com&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
    ....
    ....
    <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Second, they create a temporary IFRAME where they write a simple 2 lines CSS that does the magic</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="css" style="font-family:monospace;">a <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">&#125;</span>
a<span style="color: #00AA00;">:</span> visited <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#F00</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">inline</span> <span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>... and in the body they append all the links from the <string>sites list. </p>
<p>The browser renders the links, and all the sites that appear in your history will use the "<strong>a:visited</strong>" CSS class. The others use the normal "<strong>a</strong>" class that has a display:none property and will be hidden. </p>
<p>What's left to do is iterate all the links from the frame and check if they are visible or not to know which of them are in your history and which of them aren't. Pretty simple eh ?</p>
<p>So here's the class:</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
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> bHistory <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> sites <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #3366CC;">&quot;hidemyass.com&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;http://www.hidemyass.com&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;http://forum.hidemyass.com&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
    <span style="color: #3366CC;">&quot;freeproxy.ca&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;http://www.freeproxy.ca&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
    <span style="color: #3366CC;">&quot;proxy.org&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;http://www.proxy.org&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;http://www.proxy.org/cgi_proxies.shtml&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;http://www.proxy.org/forum/index.html&quot;</span><span style="color: #009900;">&#93;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> visited <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">function</span> getStyle<span style="color: #009900;">&#40;</span>el<span style="color: #339933;">,</span> scopeDoc<span style="color: #339933;">,</span>styleProp<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>el.<span style="color: #660066;">currentStyle</span><span style="color: #009900;">&#41;</span> <span style="color: #003366; font-weight: bold;">var</span> y <span style="color: #339933;">=</span> el.<span style="color: #660066;">currentStyle</span><span style="color: #009900;">&#91;</span>styleProp<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">getComputedStyle</span><span style="color: #009900;">&#41;</span> <span style="color: #003366; font-weight: bold;">var</span> y <span style="color: #339933;">=</span> scopeDoc.<span style="color: #660066;">defaultView</span>.<span style="color: #660066;">getComputedStyle</span><span style="color: #009900;">&#40;</span>el<span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">getPropertyValue</span><span style="color: #009900;">&#40;</span>styleProp<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">return</span> y<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #003366; font-weight: bold;">function</span> remove<span style="color: #009900;">&#40;</span> el <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    el.<span style="color: #660066;">parentNode</span>.<span style="color: #660066;">removeChild</span><span style="color: #009900;">&#40;</span> el <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #003366; font-weight: bold;">function</span> createIframe<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> iframe <span style="color: #339933;">=</span> document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;iframe&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    iframe.<span style="color: #660066;">style</span>.<span style="color: #660066;">position</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;absolute&quot;</span><span style="color: #339933;">;</span>
    iframe.<span style="color: #660066;">style</span>.<span style="color: #660066;">visibility</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;hidden&quot;</span><span style="color: #339933;">;</span>
    document.<span style="color: #660066;">body</span>.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>iframe<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>iframe.<span style="color: #660066;">contentDocument</span><span style="color: #009900;">&#41;</span> iframe.<span style="color: #660066;">doc</span> <span style="color: #339933;">=</span> iframe.<span style="color: #660066;">contentDocument</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>iframe.<span style="color: #660066;">contentWindow</span><span style="color: #009900;">&#41;</span> iframe.<span style="color: #660066;">doc</span> <span style="color: #339933;">=</span> iframe.<span style="color: #660066;">contentWindow</span>.<span style="color: #660066;">document</span><span style="color: #339933;">;</span>
    iframe.<span style="color: #660066;">doc</span>.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  	iframe.<span style="color: #660066;">doc</span>.<span style="color: #000066; font-weight: bold;">write</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;style&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  	iframe.<span style="color: #660066;">doc</span>.<span style="color: #000066; font-weight: bold;">write</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a{color: #000000; display:none;}&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  	
  	iframe.<span style="color: #660066;">doc</span>.<span style="color: #000066; font-weight: bold;">write</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a:visited {color: #FF0000; display:inline;}&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  	
  	iframe.<span style="color: #660066;">doc</span>.<span style="color: #000066; font-weight: bold;">write</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;/style&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    iframe.<span style="color: #660066;">doc</span>.<span style="color: #000066;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">return</span> iframe<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>  
  <span style="color: #003366; font-weight: bold;">var</span> iframe <span style="color: #339933;">=</span> createIframe<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">function</span> embedLinkInIframe<span style="color: #009900;">&#40;</span> href<span style="color: #339933;">,</span> text <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> a <span style="color: #339933;">=</span> iframe.<span style="color: #660066;">doc</span>.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    a.<span style="color: #660066;">href</span> <span style="color: #339933;">=</span> href<span style="color: #339933;">;</span>
    a.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> site<span style="color: #339933;">;</span>
    iframe.<span style="color: #660066;">doc</span>.<span style="color: #660066;">body</span>.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span> a <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">var</span> site <span style="color: #000066; font-weight: bold;">in</span> sites <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> urls <span style="color: #339933;">=</span> sites<span style="color: #009900;">&#91;</span>site<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>urls .<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      embedLinkInIframe<span style="color: #009900;">&#40;</span> urls<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> site <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> urls<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">match</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/www\./</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> sansWWW <span style="color: #339933;">=</span> urls<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/www\./</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        embedLinkInIframe<span style="color: #009900;">&#40;</span> sansWWW<span style="color: #339933;">,</span> site <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> httpLen <span style="color: #339933;">=</span> urls<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;//&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> withWWW <span style="color: #339933;">=</span> urls<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">substring</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> httpLen <span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;www.&quot;</span> <span style="color: #339933;">+</span> urls<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">substring</span><span style="color: #009900;">&#40;</span> httpLen <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        embedLinkInIframe<span style="color: #009900;">&#40;</span> withWWW<span style="color: #339933;">,</span> site <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #003366; font-weight: bold;">var</span> links <span style="color: #339933;">=</span> iframe.<span style="color: #660066;">doc</span>.<span style="color: #660066;">body</span>.<span style="color: #660066;">childNodes</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>links.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> displayValue <span style="color: #339933;">=</span> getStyle<span style="color: #009900;">&#40;</span>links<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> iframe.<span style="color: #660066;">doc</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;display&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">var</span> didVisit <span style="color: #339933;">=</span> displayValue <span style="color: #339933;">!=</span> <span style="color: #3366CC;">&quot;none&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> didVisit <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
      visited<span style="color: #009900;">&#91;</span> links<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">innerHTML</span> <span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
  remove<span style="color: #009900;">&#40;</span> iframe <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> usedSites <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">var</span> site <span style="color: #000066; font-weight: bold;">in</span> visited <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    usedSites.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span> site <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #000066; font-weight: bold;">return</span> usedSites<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>To use it:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">   <span style="color: #003366; font-weight: bold;">var</span> visited <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> bHistory<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>visited<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// an array with visited websites from the defined list</span></pre></td></tr></table></div>

<p>All credits go to the smart man who did this. Cheers!</urls></pre>
<p></string></p>


<p>Related posts:<ol><li><a href='http://blog.another-d-mention.ro/programming/java-script/on-typing-complete-jquery-plugin/' rel='bookmark' title='Permanent Link: On typing finished jQuery plugin'>On typing finished jQuery plugin</a></li>
<li><a href='http://blog.another-d-mention.ro/misc/firefox-and-user-agent-switcher/' rel='bookmark' title='Permanent Link: Firefox and User Agent Switcher'>Firefox and User Agent Switcher</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/java-script/open-and-save-files-to-desktop-without-going-to-server/' rel='bookmark' title='Permanent Link: Open and Save files to Desktop without going to Server'>Open and Save files to Desktop without going to Server</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.another-d-mention.ro/programming/check-if-user-visited-certain-websites/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Open and Save files to Desktop without going to Server</title>
		<link>http://blog.another-d-mention.ro/programming/java-script/open-and-save-files-to-desktop-without-going-to-server/</link>
		<comments>http://blog.another-d-mention.ro/programming/java-script/open-and-save-files-to-desktop-without-going-to-server/#comments</comments>
		<pubDate>Wed, 05 May 2010 13:21:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Java Script]]></category>
		<category><![CDATA[externalinterface]]></category>
		<category><![CDATA[filereference]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[open]]></category>
		<category><![CDATA[save]]></category>

		<guid isPermaLink="false">http://blog.another-d-mention.ro/?p=817</guid>
		<description><![CDATA[Few days ago I was working on a jQuery based tool to QA the JavaScript functionality of a website and I was in need of a method to save and load my scripts to Desktop. In most cases this require a server script where you send the content and it will serve it to download [...]


Related posts:<ol><li><a href='http://blog.another-d-mention.ro/misc/access-all-files-on-your-hard-disk-from-the-system-tray/' rel='bookmark' title='Permanent Link: Access all files on your hard disk from the system tray'>Access all files on your hard disk from the system tray</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/flex-actionscript/serialize-javascript-object-to-json/' rel='bookmark' title='Permanent Link: Serialize JavaScript object to JSON'>Serialize JavaScript object to JSON</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/right-click-and-custom-context-menu-in-flash-flex/' rel='bookmark' title='Permanent Link: Right click and custom context menu in Flash/Flex'>Right click and custom context menu in Flash/Flex</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Few days ago I was working on a jQuery based tool to QA the JavaScript functionality of a website and I was in need of a method to save and load my scripts to Desktop.<br />
In most cases this require a server script where you send the content and it will serve it to download and same for loading it. But a colleague suggested a better solution: to use the FileReference class.<br />
First step was to create a simple flash with the required functionality and send/retrieve data with ExternalInterface. Failed miserably. Why ? Because it seems Flash will not allow you to open a File Dialog from script only. You literally have to click a button from the movie interface to be able to do that. If you knew that good for you, I didn't.</p>
<p>So, I've created another flash movie, where you pass the open and save image and callback and it will insert the flash with the specified images in place and look just like any other buttons. </p>
<p>Here's a small demonstration (other buttons beside open and save are just for show):<br />
<iframe src="http://blog.another-d-mention.ro/stuff/FileDialogs/index.html" with="400" height="170" frameborder="0" style="overflow:hidden"></iframe><br />
So what do you need to set it up ? </p>
<p>First, you have to include the <strong>FileDialogs.js</strong> in your document (or just paste the code inside it into your own script).</p>
<p>Second, you need your JavaScript callbacks.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> openCallback<span style="color: #009900;">&#40;</span>input<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'text'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> input<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> saveCallback<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     <span style="color: #000066; font-weight: bold;">return</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'text'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p><strong>openCallback()</strong> will be called once the user will select a file from the desktop and pass it's content as a parameter<br />
<strong>saveCallback()</strong> will be called when the user clicks save, before the dialog to choose a file name opens, and it must return the content you want to save to disk</p>
<p>Third, you must setup the whole thing.</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
18
19
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// call this function on the onload event so the placeHolder element gets created</span>
<span style="color: #003366; font-weight: bold;">function</span> <span style="color: #000066;">onLoad</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #006600; font-style: italic;">// Create a config object</span>
    <span style="color: #003366; font-weight: bold;">var</span> config <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> FileDialogsConfig<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #006600; font-style: italic;">// width of the entire flash movie (buttons width + padding)</span>
    config.<span style="color: #660066;">width</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">45</span><span style="color: #339933;">;</span> 
    <span style="color: #006600; font-style: italic;">// height of the movie</span>
    config.<span style="color: #660066;">height</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">16</span><span style="color: #339933;">;</span>
    <span style="color: #006600; font-style: italic;">// padding between buttons</span>
    config.<span style="color: #660066;">padding</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">5</span><span style="color: #339933;">;</span>
    <span style="color: #006600; font-style: italic;">// open dialog button image and javascript callback function</span>
    config.<span style="color: #000066;">open</span>.<span style="color: #660066;">image</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;open.png&quot;</span><span style="color: #339933;">;</span>
    config.<span style="color: #000066;">open</span>.<span style="color: #660066;">handler</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;openCallback&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #006600; font-style: italic;">// save dialog button image and javascript callback function</span>
    config.<span style="color: #660066;">save</span>.<span style="color: #660066;">image</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;save.png&quot;</span><span style="color: #339933;">;</span>
    config.<span style="color: #660066;">save</span>.<span style="color: #660066;">handler</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;saveCallback&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #006600; font-style: italic;">// create the movie inside an element with the given id and configuration</span>
    <span style="color: #003366; font-weight: bold;">new</span> FileDialogs<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;placeHolder&quot;</span><span style="color: #339933;">,</span> config<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p><strong>Note:</strong> Handler callbacks in the config must be declared as String and not reference. IE will freak out and I don't want to fix it.</p>
<p>You can have only one button (open or save) if you chose so. Just don't set the other one.</p>
<p>That's about it. The placeHolder can be any container element. The script will set it's style size based on the configuration, the movie will have transparent background so don't worry about that, and it will set it's float property to left so you can add other stuff after it. But all those things are easy to configure if you mess a bit with the FileDialogs.js file. </p>
<p>Cheers!</p>
<p><a href="http://blog.another-d-mention.ro/stuff/FileDialogs/FileDialogs.zip">Download Source and Demo</a></p>


<p>Related posts:<ol><li><a href='http://blog.another-d-mention.ro/misc/access-all-files-on-your-hard-disk-from-the-system-tray/' rel='bookmark' title='Permanent Link: Access all files on your hard disk from the system tray'>Access all files on your hard disk from the system tray</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/flex-actionscript/serialize-javascript-object-to-json/' rel='bookmark' title='Permanent Link: Serialize JavaScript object to JSON'>Serialize JavaScript object to JSON</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/right-click-and-custom-context-menu-in-flash-flex/' rel='bookmark' title='Permanent Link: Right click and custom context menu in Flash/Flex'>Right click and custom context menu in Flash/Flex</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.another-d-mention.ro/programming/java-script/open-and-save-files-to-desktop-without-going-to-server/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Serialize JavaScript object to JSON</title>
		<link>http://blog.another-d-mention.ro/programming/flex-actionscript/serialize-javascript-object-to-json/</link>
		<comments>http://blog.another-d-mention.ro/programming/flex-actionscript/serialize-javascript-object-to-json/#comments</comments>
		<pubDate>Wed, 28 Apr 2010 11:57:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Flex / ActionScript]]></category>
		<category><![CDATA[Java Script]]></category>
		<category><![CDATA[deserialize]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[object]]></category>
		<category><![CDATA[serialize]]></category>

		<guid isPermaLink="false">http://blog.another-d-mention.ro/?p=816</guid>
		<description><![CDATA[Recently, on a project I was working, I needed a function to serialize a JavaScript object and all I could find online were scripts and jquery plugins for serializing a html form. Then, I found this, a script that takes advantage of the .toSource() method available in Gecko-based browsers and for the rest of them [...]


Related posts:<ol><li><a href='http://blog.another-d-mention.ro/programming/how-to-clone-duplicate-an-object-in-actionscript-3/' rel='bookmark' title='Permanent Link: How to clone (duplicate) an object in ActionScript 3'>How to clone (duplicate) an object in ActionScript 3</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/java-script/on-typing-complete-jquery-plugin/' rel='bookmark' title='Permanent Link: On typing finished jQuery plugin'>On typing finished jQuery plugin</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/right-click-and-custom-context-menu-in-flash-flex/' rel='bookmark' title='Permanent Link: Right click and custom context menu in Flash/Flex'>Right click and custom context menu in Flash/Flex</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Recently, on a project I was working, I needed a function to serialize a JavaScript object and all I could find online were scripts and jquery plugins for serializing a html form. Then, I found <a href="http://blog.stchur.com/2007/04/06/serializing-objects-in-javascript/" target="_blank">this</a>, a script that takes advantage of the <i>.toSource()</i> method available in Gecko-based browsers and for the rest of them plain old recursion. But it does the trick as expected and I'm pretty sure someone else might need it.</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
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> serialize<span style="color: #009900;">&#40;</span>_obj<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>_obj <span style="color: #339933;">!=</span> undefined <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000066; font-weight: bold;">typeof</span> _obj.<span style="color: #660066;">toSource</span> <span style="color: #339933;">!==</span> <span style="color: #3366CC;">'undefined'</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000066; font-weight: bold;">typeof</span> _obj.<span style="color: #660066;">callee</span> <span style="color: #339933;">===</span> <span style="color: #3366CC;">'undefined'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000066; font-weight: bold;">return</span> _obj.<span style="color: #660066;">toSource</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
   <span style="color: #000066; font-weight: bold;">switch</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> _obj<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">'number'</span><span style="color: #339933;">:</span>
      <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">'boolean'</span><span style="color: #339933;">:</span>
      <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">'function'</span><span style="color: #339933;">:</span>
         <span style="color: #000066; font-weight: bold;">return</span> _obj<span style="color: #339933;">;</span>
         <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">'string'</span><span style="color: #339933;">:</span>
          <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #3366CC;">'&quot;'</span> <span style="color: #339933;">+</span> _obj.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/&quot;/mg</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;'&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot;'</span><span style="color: #339933;">;</span>
          <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">'object'</span><span style="color: #339933;">:</span>
          <span style="color: #003366; font-weight: bold;">var</span> str<span style="color: #339933;">;</span>
          <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>_obj.<span style="color: #660066;">constructor</span> <span style="color: #339933;">===</span> Array <span style="color: #339933;">||</span> <span style="color: #000066; font-weight: bold;">typeof</span> _obj.<span style="color: #660066;">callee</span> <span style="color: #339933;">!==</span> <span style="color: #3366CC;">'undefined'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
              str <span style="color: #339933;">=</span> <span style="color: #3366CC;">'['</span><span style="color: #339933;">;</span>
              <span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">,</span> len <span style="color: #339933;">=</span> _obj.<span style="color: #660066;">length</span><span style="color: #339933;">;</span>
              <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> len<span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> str <span style="color: #339933;">+=</span> Utils.<span style="color: #660066;">serialize</span><span style="color: #009900;">&#40;</span>_obj<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">','</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
              str <span style="color: #339933;">+=</span> Utils.<span style="color: #660066;">serialize</span><span style="color: #009900;">&#40;</span>_obj<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">']'</span><span style="color: #339933;">;</span>
          <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
              str <span style="color: #339933;">=</span> <span style="color: #3366CC;">'{'</span><span style="color: #339933;">;</span>
              <span style="color: #003366; font-weight: bold;">var</span> key<span style="color: #339933;">;</span>
              <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>key <span style="color: #000066; font-weight: bold;">in</span> _obj<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> str <span style="color: #339933;">+=</span> key <span style="color: #339933;">+</span> <span style="color: #3366CC;">':'</span> <span style="color: #339933;">+</span> Utils.<span style="color: #660066;">serialize</span><span style="color: #009900;">&#40;</span>_obj<span style="color: #009900;">&#91;</span>key<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">','</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
              str <span style="color: #339933;">=</span> str.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/\,$/</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'}'</span><span style="color: #339933;">;</span>
          <span style="color: #009900;">&#125;</span>
          <span style="color: #000066; font-weight: bold;">return</span> str<span style="color: #339933;">;</span>
          <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
      <span style="color: #003366; font-weight: bold;">default</span><span style="color: #339933;">:</span>
          <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #3366CC;">'&quot;&quot;'</span><span style="color: #339933;">;</span>
          <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>To deserialize it, just use <i>eval()</i>.</p>
<p>Also, if you need the same thing for your Flash/Flex Actionscript3 project, here is a class for that as well -> <a href="http://blog.another-d-mention.ro/stuff/Serializer.as" target="_blank">Click Me</a>.</p>
<p>Cheers!
</pre>


<p>Related posts:<ol><li><a href='http://blog.another-d-mention.ro/programming/how-to-clone-duplicate-an-object-in-actionscript-3/' rel='bookmark' title='Permanent Link: How to clone (duplicate) an object in ActionScript 3'>How to clone (duplicate) an object in ActionScript 3</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/java-script/on-typing-complete-jquery-plugin/' rel='bookmark' title='Permanent Link: On typing finished jQuery plugin'>On typing finished jQuery plugin</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/right-click-and-custom-context-menu-in-flash-flex/' rel='bookmark' title='Permanent Link: Right click and custom context menu in Flash/Flex'>Right click and custom context menu in Flash/Flex</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.another-d-mention.ro/programming/flex-actionscript/serialize-javascript-object-to-json/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Neural networks in ActionScript 3</title>
		<link>http://blog.another-d-mention.ro/programming/neural-networks-in-actionscript-3/</link>
		<comments>http://blog.another-d-mention.ro/programming/neural-networks-in-actionscript-3/#comments</comments>
		<pubDate>Thu, 11 Mar 2010 14:07:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Flex / ActionScript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[actionscript3]]></category>
		<category><![CDATA[ai]]></category>
		<category><![CDATA[artificial]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[intelligence]]></category>
		<category><![CDATA[networks]]></category>
		<category><![CDATA[neural]]></category>

		<guid isPermaLink="false">http://blog.another-d-mention.ro/?p=807</guid>
		<description><![CDATA["An artificial neural network (ANN), usually called "neural network" (NN), is a mathematical model or computational model that tries to simulate the structure and/or functional aspects of biological neural networks. It consists of an interconnected group of artificial neurons and processes information using a connectionist approach to computation. In most cases an ANN is an [...]


Related posts:<ol><li><a href='http://blog.another-d-mention.ro/programming/how-to-clone-duplicate-an-object-in-actionscript-3/' rel='bookmark' title='Permanent Link: How to clone (duplicate) an object in ActionScript 3'>How to clone (duplicate) an object in ActionScript 3</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/create-professional-flex-components/' rel='bookmark' title='Permanent Link: Create professional Flex components'>Create professional Flex components</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/ho-to-install-alchemy/' rel='bookmark' title='Permanent Link: Ho-To: Install Alchemy'>Ho-To: Install Alchemy</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-808" style="margin: 0px 10px 5px 0px;" title="Neural Network" src="http://blog.another-d-mention.ro/wp-content/uploads/2010/03/neural-network.gif" alt="Neural Network" width="150" height="113" />"An <strong>artificial neural network (ANN)</strong>, usually called "neural  network" (NN), is a mathematical model or computational model that tries to  simulate the structure and/or functional aspects of biological neural  networks. It consists of an interconnected group of artificial neurons and processes information using a connectionist approach to computation. In most cases an ANN is an adaptive system that changes its structure based on external  or internal information that flows through the network during the  learning phase. Neural networks are non-linear statistical data  modeling tools. They can be used to model complex relationships  between inputs and outputs or to find patterns in data." (<a href="http://en.wikipedia.org/wiki/Artificial_neural_network">Wikipedia</a>)</p>
<p><a href="http://blog.another-d-mention.ro/wp-content/uploads/2010/03/mlp3.gif"><img class="alignright size-full wp-image-809" title="Multi Layer Perceptron" src="http://blog.another-d-mention.ro/wp-content/uploads/2010/03/mlp3.gif" alt="Multi Layer Perceptron" width="164" height="224" /></a>So, repetition is the mother of all learning they say. You damn right it is. And you can do it in AS3 of course. Not the fastest choice out there but that's not the point. NN's are usually not that fast but they're useful in so many ways.</p>
<p>So, here is my implementation of a neural network multi-layer-perceptron made in AS3, set to learn a simple XOR problem. It uses 2 inputs neurons , 2 hidden layers, each having 2 neurons and one output neuron. It takes about 2 seconds to train it using 10.000 epochs, but then you can save a snapshot of the NN memory as a byteArray, save it to the server and load it back again in an instant without requiring a new training.  I didn't take the time to thoroughly document the classes just yet but I'm sure you'll find them pretty easy to use.</p>
<p>Some reading material:<br />
<a href="http://en.wikipedia.org/wiki/Artificial_neural_network" target="_blank">http://en.wikipedia.org/wiki/Artificial_neural_network</a><br />
<a href="http://fbim.fh-regensburg.de/~saj39122/jfroehl/diplom/e-index.html" target="_blank">http://fbim.fh-regensburg.de/~saj39122/jfroehl/diplom/e-index.html</a> (this is great)<br />
<a href="http://www.ai-junkie.com/ann/evolved/nnt1.html" target="_blank">http://www.ai-junkie.com/ann/evolved/nnt1.html</a></p>
<div align="center">
<object id="nnet" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="397" height="411" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="quality" value="high" /><param name="bgcolor" value="#FFFFFF" /><param name="allowScriptAccess" value="sameDomain" /><param name="src" value="http://blog.another-d-mention.ro/stuff/nnet/NeuralNetworks.swf" /><param name="name" value="SmartImage" /><param name="align" value="middle" /><embed id="nnet" type="application/x-shockwave-flash" width="397" height="411" src="http://blog.another-d-mention.ro/stuff/nnet/NeuralNetworks.swf" align="middle" name="SmartImage" allowscriptaccess="sameDomain" bgcolor="#FFFFFF" quality="high"></embed></object>
</div>
<p><a href="http://blog.another-d-mention.ro/stuff/nnet/srcview/" target="_blank">Sources</a> and <a href="http://blog.another-d-mention.ro/stuff/nnet/srcview/NeuralNetworks.zip" target="_blank">Download</a></p>


<p>Related posts:<ol><li><a href='http://blog.another-d-mention.ro/programming/how-to-clone-duplicate-an-object-in-actionscript-3/' rel='bookmark' title='Permanent Link: How to clone (duplicate) an object in ActionScript 3'>How to clone (duplicate) an object in ActionScript 3</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/create-professional-flex-components/' rel='bookmark' title='Permanent Link: Create professional Flex components'>Create professional Flex components</a></li>
<li><a href='http://blog.another-d-mention.ro/programming/ho-to-install-alchemy/' rel='bookmark' title='Permanent Link: Ho-To: Install Alchemy'>Ho-To: Install Alchemy</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.another-d-mention.ro/programming/neural-networks-in-actionscript-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use clipboard (copy/paste) in C# console application</title>
		<link>http://blog.another-d-mention.ro/programming/c/use-clipboard-copypaste-in-c-console-application/</link>
		<comments>http://blog.another-d-mention.ro/programming/c/use-clipboard-copypaste-in-c-console-application/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 20:04:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[clipboard]]></category>
		<category><![CDATA[copy]]></category>
		<category><![CDATA[paste]]></category>

		<guid isPermaLink="false">http://blog.another-d-mention.ro/?p=805</guid>
		<description><![CDATA[This took me few minutes to figure out and was quite annoying. First you must add a reference to System.Windows.Forms in your application. Go to Project -&#62; Add reference, select System.Windows.Forms from .NET tab in the window that just opened.  You must avoid the ThreadStateException by applying the STAThread attribute to your Main() function. Then [...]


Related posts:<ol><li><a href='http://blog.another-d-mention.ro/programming/communicate-betwen-c-and-an-embeded-flash-application/' rel='bookmark' title='Permanent Link: Communicate betwen C# and an embeded Flash application'>Communicate betwen C# and an embeded Flash application</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><img src="http://blog.another-d-mention.ro/wp-content/uploads/2010/03/net_logo.jpg-150x150.png" alt="net logo.jpg 150x150 Use clipboard (copy/paste) in C# console application" title="net_logo.jpg" width="150" height="150" class="alignleft size-thumbnail wp-image-806" />This took me few minutes to figure out and was quite annoying. First you must add a reference to System.Windows.Forms in your application. Go to Project -&gt; Add reference, select <strong>System.Windows.Forms</strong> from .NET tab in the window that just opened.  You must avoid the ThreadStateException by applying the STAThread attribute to your Main()  function. Then you can use the Clipboard functions without any problems.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">System.Windows.Forms</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #FF0000;">class</span> Program <span style="color: #000000;">&#123;</span>
    <span style="color: #000000;">&#91;</span>STAThread<span style="color: #000000;">&#93;</span>
    <span style="color: #0600FF;">static</span> <span style="color: #0600FF;">void</span> Main<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> args<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
         Clipboard.<span style="color: #0000FF;">SetText</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;this is in clipboard now&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>



<p>Related posts:<ol><li><a href='http://blog.another-d-mention.ro/programming/communicate-betwen-c-and-an-embeded-flash-application/' rel='bookmark' title='Permanent Link: Communicate betwen C# and an embeded Flash application'>Communicate betwen C# and an embeded Flash application</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.another-d-mention.ro/programming/c/use-clipboard-copypaste-in-c-console-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
