<?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>jek2kdotcom &#187; Tutorials</title>
	<atom:link href="http://www.jek2k.com/wp/category/tutorial/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jek2k.com/wp</link>
	<description>still awake at night?</description>
	<lastBuildDate>Thu, 12 May 2011 10:33:04 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Free PSD template for logo design</title>
		<link>http://www.jek2k.com/wp/2009/07/05/free-psd-template-for-logo-design/</link>
		<comments>http://www.jek2k.com/wp/2009/07/05/free-psd-template-for-logo-design/#comments</comments>
		<pubDate>Sun, 05 Jul 2009 20:37:51 +0000</pubDate>
		<dc:creator>Nicolò</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Design]]></category>

		<guid isPermaLink="false">http://www.jek2k.com/wp/?p=284</guid>
		<description><![CDATA[
Even if it&#8217;s not our primary business, in the last six months my studio was tasked to design a bunch of logos for companies, start-ups and web apps. During this period of time we&#8217;ve been putting together a simple sketchboard template to display concepts and show design previews to clients.
I&#8217;m finding this template very useful [...]]]></description>
			<content:encoded><![CDATA[<p><a title="Read full post" href="http://www.jek2k.com/wp/index.php/2009/07/05/free-psd-template-for-logo-design/"><img title="Free PSD sketchboard template for logo design" src="http://www.jek2k.com/wp/wp-content/uploads/2009/07/Immagine-2.jpg" alt="Free PSD sketchboard template for logo design" width="450" height="327" /></a></p>
<p>Even if it&#8217;s not our primary business, in the last six months my studio was tasked to design a bunch of logos for companies, start-ups and web apps. During this period of time we&#8217;ve been putting together <strong>a simple sketchboard template</strong> to display concepts and show design previews to clients.</p>
<p>I&#8217;m finding this template very useful and use it regularly for logo design &#8211; it could be used for icon design as well.</p>
<p>I&#8217;m sharing the <strong>layered PSD file</strong> here, so you can grab it and use it.</p>
<p><span id="more-284"></span></p>
<p><img title="Guides " src="http://www.jek2k.com/wp/wp-content/uploads/2009/07/Immagine-1-450x328.png" alt="Guides " width="450" height="328" /></p>
<p><img title="Full View " src="http://www.jek2k.com/wp/wp-content/uploads/2009/07/Immagine-4-450x162.png" alt="Full View " width="450" height="162" /></p>
<p>The template comes half white and half black, to display logos on both backgrounds. The background is composed of several layers, so you can easily exclude the squared paper pattern or the shadows.</p>
<p>It already includes guides to easily center and align things and has text headings that you can adapt to your needs. Finally, this PSD template lets you layout up to 4 concepts at a time (each in white and black versions) and comes at 300dpi resolution so it will work for hi-res images or for printing.</p>
<p><a title="Download PSD template for free" href="http://www.jek2k.com/wp/wp-content/uploads/2009/07/logo_template.psd.zip">Download PSD template</a> (26.2 MB, ZIP)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jek2k.com/wp/2009/07/05/free-psd-template-for-logo-design/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Retrieving Twitter updates with PHP</title>
		<link>http://www.jek2k.com/wp/2008/06/08/retrieving-twitter-updates-with-php/</link>
		<comments>http://www.jek2k.com/wp/2008/06/08/retrieving-twitter-updates-with-php/#comments</comments>
		<pubDate>Sat, 07 Jun 2008 23:53:33 +0000</pubDate>
		<dc:creator>Nicolò</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.jek2k.com/wp/index.php/2008/06/08/retrieving-twitter-updates-with-php/</guid>
		<description><![CDATA[I&#8217;ve started using Twitter a few months ago. Personally, I like the idea of easily sending short status updates, and the opportunity to integrate it into my blog or my Facebook page.
I&#8217;ve started playing around with Twitter APIs and found an interesting PHP class by Nick Beam.
I&#8217;ve used that class, basically a PHP wrapper for [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve started using <a href="http://twitter.com/">Twitter</a> a few months ago. Personally, I like the idea of easily sending short status updates, and the opportunity to integrate it into my blog or my Facebook page.</p>
<p>I&#8217;ve started playing around with <a href="http://groups.google.com/group/twitter-development-talk/web/api-documentation">Twitter APIs</a> and found <a href="http://twitter-development-talk.googlegroups.com/web/api_class.phps.txt?gda=bo4h1UMAAADDY4RxBmouwZtsLlfZE2USiiafVgS5RiazxT4znoMLKmG1qiJ7UbTIup-M2XPURDRSOws4Xi3QnSf7-kobJbms4hW8pUgcobEJRPIfCgn0ug">an interesting PHP class</a> by <a href="http://beamdev.blogspot.com/">Nick Beam</a>.<br />
I&#8217;ve used that class, basically a PHP wrapper for the the Twitter APIs, to develop a little PHP script that retrieves the last status updates from my Twitter profile. This can be integrated in virtually any website or blog using PHP, including your WordPress-powered blog.</p>
<p><strong>The basic script</strong><br />
The script lets you define a few parameters:</p>
<ul>
<li>your Twitter username</li>
<li>your password (in case your updates are protected)</li>
<li>the number of status updates to retrieve</li>
</ul>
<p>You can see it in action <a href="http://playground.gnvpartners.net/apps/twitter/twitter.php">here</a>.</p>
<p><strong>Filtering status updates</strong><br />
After I developed this simple script, I thought of using it to send quick updates to my website, like for example &#8220;taking the day off&#8221; or &#8220;starting a new project&#8221;.<br />
I realized I wanted to have the opportunity to filter my Twitted updates, to choose which messages should be published on my websites and which are just personal or part of Twitter conversations.</p>
<p>I decided to add a simple filtering functionality to my script, so that you can add a string to your messages to identify them. For example, I&#8217;m using this features to send updates to <a href="http://playground.gnvpartners.net/">playground.gnvpartners.net</a>, as shown in the screenshot below.</p>
<p style="text-align:center;"><a href="http://playground.gnvpartners.net/"><img src="http://www.jek2k.com/wp/wp-content/uploads/2008/06/twitter1.jpg" alt="twitter1.jpg" /></a></p>
<p>I simply add <strong>[playground]</strong> before each message that I want to be published on that website. The string is obviously fully editable so that you can use any prefix you like.</p>
<p>Here&#8217;s how the PHP function call looks like:</p>
<pre class="brush: php;">
         getTwits('nicolovolpato','password',5,'playground');
</pre>
<p>where the first parameter is your Twitter username, the second one is your password (empty if your tweets are public), the third one is the number of messages to show and the last one is the string you want to use as a filter.</p>
<p>Anyway, I guess the best way to learn how the script works is to download the source and play with it.</p>
<p><a href="http://playground.gnvpartners.net/apps/twitter/twitter_functions.zip"></a></p>
<p><a href="http://www.jek2k.com/wp/wp-content/uploads/2008/06/twitter_toolkit.zip">Download twitter_toolkit.zip</a> (8kb ZIP).</p>
<p class="note">This tutorial is provided as is. Please do not email me questions or support requests about the scripts contained in this page. Use the comments below instead. Thank you.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jek2k.com/wp/2008/06/08/retrieving-twitter-updates-with-php/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Building a custom Skype-me button with status icon</title>
		<link>http://www.jek2k.com/wp/2008/02/08/building-a-custom-skype-me-button-with-status-icon/</link>
		<comments>http://www.jek2k.com/wp/2008/02/08/building-a-custom-skype-me-button-with-status-icon/#comments</comments>
		<pubDate>Thu, 07 Feb 2008 23:25:55 +0000</pubDate>
		<dc:creator>Nicolò</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.jek2k.com/wp/index.php/2008/02/08/building-a-custom-skype-me-button-with-status-icon/</guid>
		<description><![CDATA[I&#8217;m not a big fan of Skype and I usually don&#8217;t use it. However, in a recent project, I was asked to add a &#8220;Skype Me&#8221; button in the contacts section of a client&#8217;s website.
I guess you all know Skype provides a bunch of free buttons and even an online wizard to build custom buttons. [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m not a big fan of Skype and I usually don&#8217;t use it. However, in a recent project, I was asked to add a &#8220;Skype Me&#8221; button in the contacts section of a client&#8217;s website.<br />
I guess you all know Skype provides a bunch of free buttons and even an online wizard to build custom buttons. This works pretty good, except it only allows to use the default Skype buttons and icons and images are PNGs.</p>
<p>What to do then if you need to use custom-designed buttons? Or if you&#8217;re targeting IE6 and have no transparent-PNGs support? I scored 2 on 2, having both those problems.</p>
<p>So I decided to search for some Skype documentation and build a script myself.<br />
Some basic information on creating custom Skype buttons and links <a href="http://www.skype.com/share/buttons/advanced.html">can be found here</a>. This explains how to code links, but still doesn&#8217;t address my problem. Then I found some more in-depth documentation on building web-services and apps interacting with Skype, that <a href="https://developer.skype.com/Docs/Web">can be downloaded from here</a>.</p>
<p>This way I found out that you can call a remote Skype URL, passing in your username and some parameters, to retrieve a status <a href="http://mystatus.skype.com/nicolovolpato">button</a>, a status <a href="http://mystatus.skype.com/nicolovolpato">code</a> or a status <a href="http://mystatus.skype.com/nicolovolpato.txt">string</a>.</p>
<p>The numeric status code is easier to use. Here&#8217;s a short list of numeric codes and their meaning:</p>
<ul>
<li><strong>0</strong> &#8211; unknown</li>
<li><strong>1</strong> &#8211; offline</li>
<li><strong>2</strong> &#8211; online</li>
<li><strong>3</strong> &#8211; away</li>
<li><strong>4</strong> &#8211; not available</li>
<li><strong>5</strong> &#8211; do not disturb</li>
<li><strong>6</strong> &#8211; invisible</li>
<li><strong>7</strong> &#8211; skype me</li>
</ul>
<p>Then I coded a short PHP script to take advantage of this function and retrieve the status code for a given Skype username.</p>
<pre class="brush: php;">
function getSkypeStatus($username) {
	$remote_status = fopen ('http://mystatus.skype.com/'.$username.'.num', 'r');
	if (!$remote_status) {
	    return '0';
	    exit;
	}
	while (!feof ($remote_status)) {
	    $value = fgets ($remote_status, 1024);
	    return trim($value);
	}
	fclose($remote_status);
}
</pre>
<p>Half of the job was done. Now I needed to link each code to a custom-designed status icon.</p>
<pre class="brush: php;">
function getSkypeStatusIcon($username) {
	$status = getSkypeStatus($username);
	// change the path of the icons folder to match your site
	echo '&lt;img src=&quot;/skype-icons/'.$status.'.jpg&quot; alt=&quot;call '.$username.'&quot; /&gt;';
}
</pre>
<p>So that calling the PHP function with the desired username&#8230;</p>
<pre class="brush: php;">
getSkypeStatusIcon('nicolovolpato');
</pre>
<p>&#8230;returns the necessary HTML code for the icon image.</p>
<pre class="brush: php;">
&lt;img src=&quot;/skype-icons/1.jpg&quot; alt=&quot;call nicolovolpato&quot; /&gt;
</pre>
<p>Of course I had then to go back to Photoshop and design my custom icons. I simply named the files like the status codes, where 1.jpg is the icon for offline, 2.jpg is the icon for online and so on.</p>
<p>I&#8217;ve tested this script using my Skype account and other accounts and seems pretty reliable. This is not the only method and I&#8217;m pretty sure this is not even the best method available, but it&#8217;s just the solution I have found to this problem and wanted to share it.</p>
<p><a rel="attachment" href="http://www.jek2k.com/wp/wp-content/uploads/2008/02/skype.php.zip" title="Download skype.php.zip">Download the source code</a> (4k ZIP)</p>
<p class="note">This tutorial is provided as is. Please do not email me questions or support requests about the scripts contained in this page. Use the comments below instead. Thank you.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jek2k.com/wp/2008/02/08/building-a-custom-skype-me-button-with-status-icon/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Drop down with MooTools</title>
		<link>http://www.jek2k.com/wp/2008/01/20/drop-down-with-mootools/</link>
		<comments>http://www.jek2k.com/wp/2008/01/20/drop-down-with-mootools/#comments</comments>
		<pubDate>Sun, 20 Jan 2008 20:23:27 +0000</pubDate>
		<dc:creator>Nicolò</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.jek2k.com/wp/index.php/2008/01/20/drop-down-with-mootools/</guid>
		<description><![CDATA[Last year, when I launched this version of Jek2k.com, I published a tutorial on how to make drop-down panels like the ones on this site.
As some of you might have noticed, since last month I&#8217;ve changed the JavaScripts on this site. I&#8217;ve swtiched to MooTools. I&#8217;ve used it quite often in my latest projects and [...]]]></description>
			<content:encoded><![CDATA[<p>Last year, when I launched this version of Jek2k.com, <a href="http://www.jek2k.com/wp/index.php/2006/07/14/drop-down-with-javascript/">I published a tutorial on how to make drop-down panels</a> like the ones on this site.</p>
<p>As some of you might have noticed, since last month I&#8217;ve changed the JavaScripts on this site. I&#8217;ve swtiched to <a href="http://mootools.net">MooTools</a>. I&#8217;ve used it quite often in my latest projects and I must say I&#8217;m finding it pretty easy to use.</p>
<p>For all those who liked the old drop-down script, I&#8217;m now posting an updated version with a short tutorial.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>1. Wrap everything inside a DOM Ready Event.</p>
<pre class="brush: jscript;">
window.addEvent('domready', function() {
	// CODE HERE

});
 </pre>
<p>2. Define which Html element (&#8221;myPanel&#8221;) will be affected by the drop-down effect. You might want to hide it, so that it starts collapsed.</p>
<pre class="brush: jscript;">
var mySlide = new Fx.Slide('myPanel');
mySlide.hide();
 </pre>
<p>3. The following lines add a Click event to the &#8220;Open Panel&#8221; link and add desired effect to open the drop-down panel, fade-out the &#8220;Open Panel&#8221; link and fade in the &#8220;Close Panel&#8221; link.</p>
<pre class="brush: jscript;">
var fx = new Fx.Styles($('openPanel'), {duration:500, wait:false});
$('openPanel').addEvent('click', function(e){
   mySlide.toggle();
 	fx.start({
   	'opacity': 0
   }).chain(function(){
     	$('openPanel').setStyle('display', 'none');
       $('closePanel').setStyle('display', 'block');
       $('closePanel').setStyle('opacity', '0');
       fx1.start({
           'opacity': 1
       });
   });
});
 </pre>
<p>4. Lastly, we need some other code to handle the &#8220;Close Panel&#8221; link, which mirrors the code above.</p>
<pre class="brush: jscript;">
var fx1 = new Fx.Styles($('closePanel'), {duration:500, wait:false});
$('closePanel').addEvent('click', function(e){
	mySlide.toggle();
   fx1.start({
   	'opacity': 0
  	}).chain(function(){
   	$('openPanel').setStyle('display', 'block');
      	$('closePanel').setStyle('display', 'none');
       $('openPanel').setStyle('opacity', '0');
       fx.start({
       	'opacity': 1
       });
   });
});
 </pre>
<p>Please see also <a href="http://docs.mootools.net/">MooTools own documentation</a> and <a href="http://demos.mootools.net/">demos</a> for the <a href="http://demos.mootools.net/Fx.Slide">Fx.Slide</a> and the <a href="http://demos.mootools.net/Fx.Styles">Fx.Styles</a> behaviours.</p>
<p><a title="Download dropdown_js.zip" href="http://www.jek2k.com/wp/wp-content/uploads/2008/01/dropdown_js.zip">Download the Source Code</a> (24k ZIP)</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p><strong>Updated on 22.01.2008</strong><br />
Today my friend <a href="http://www.luscarpa.eu/">Luca</a>, who is a pro developer, emailed me a modified version of the above script, that he has kindly corrected and improved. He also has shortened the script, making it a lot easier.</p>
<pre class="brush: jscript;">
window.addEvent('domready', function() {
	// Label for link
	var labelOpen='Open Panel';
	var labelClose='Close Panel';

	// Set slide and styles effects
	var mySlide = new Fx.Slide('myPanel').hide();
	var fx = new Fx.Styles($('linkPanel'), {duration:500, wait:false});
	$('linkPanel').addEvent('click', function(e){
		mySlide.toggle();
		$('linkPanel').toggleClass('openPanel');
		fx.start({
			'opacity': 0
		}).chain(function(){
			if($('linkPanel').hasClass('openPanel')) $('linkPanel').setHTML(labelClose);
			else $('linkPanel').setHTML(labelOpen);
			fx.start({'opacity': 1})
		});
	});
});
 </pre>
<p>Below is the link to download Luca&#8217;s new version:</p>
<p><a title="Download dropdown_js_v2.0.zip" href="http://www.jek2k.com/wp/wp-content/uploads/2008/01/dropdown_js_v2.0.zip">Download the new Source Code</a> (24k ZIP)</p>
<p class="note">This tutorial is provided as is. Please do not email me questions or support requests about the scripts contained in this page. Use the comments below instead. Thank you.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jek2k.com/wp/2008/01/20/drop-down-with-mootools/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Cryptography and Flash</title>
		<link>http://www.jek2k.com/wp/2007/05/22/cryptography-and-flash/</link>
		<comments>http://www.jek2k.com/wp/2007/05/22/cryptography-and-flash/#comments</comments>
		<pubDate>Mon, 21 May 2007 22:23:22 +0000</pubDate>
		<dc:creator>Nicolò</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.jek2k.com/wp/index.php/2007/05/09/cryptography-and-flash/</guid>
		<description><![CDATA[Many times, when you&#8217;re developing a rich Flash app, or more frequently an advanced Flash website, you have to deal with login forms to authenticate users.
And maybe you want to store your encrypted password in a database, and then retrieve them using some server-side script.
Or you want to send an encrypted string back to the [...]]]></description>
			<content:encoded><![CDATA[<p>Many times, when you&#8217;re developing a rich Flash app, or more frequently an advanced Flash website, you have to deal with login forms to authenticate users.<br />
And maybe you want to store your encrypted password in a database, and then retrieve them using some server-side script.<br />
Or you want to send an encrypted string back to the database.</p>
<p>In a scenario like this, you might want (or need) to decrypt encrypted password or string in order to obtain readable data. ActionScript, by default, can&#8217;t handle it. </p>
<p>I found an interesting solution provided by <a href="http://www.meychi.com/archive/000031.php">Meychi</a>, called ASCrypt.<br />
It is simple Flash Extension that enables crypting and decrypting functions in ActionScript. It provides classes with methods to crypt and decrypt strings and support all the following standards: Base8, Base64, Goauld, LZW, GUID, RC4, MD5, SHA1, ROT13, Rijndael and TEA.<br />
It is quite easy to use and works great with both ActionScript and ActionScript 2.0.</p>
<p>Anyway, I&#8217;m going to show you a really basic example of how to pass an encrypted password from a server-side ASP.NET page to a SWF movie. </p>
<p>Let&#8217;s make a stupid ASP.NET script that encrypts a given password and passes the obtained string to Flash.</p>
<p><strong>encrypted_pass.aspx</strong><br />
<pre><pre>
&lt;% 
&#039;sets a variable containing our password 
Dim PassWord = &quot;pass&quot;
 
&#039;encrypts the password to a Base64 string
Response.Write(&quot;pwd=&quot;+Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(PassWord))) 
%&gt; 
</pre></pre> </p>
<p>These few lines of script take a simple variable (PassWord) and encrypt it to a Base64 string.<br />
If you view it in a browser, you&#8217;ll see an output like pwd=cGFzcw==.</p>
<p><strong>decrypt_pass.fla</strong><br />
<pre><pre>
// imports Meychi&#039;s ASCrypt class
import com.meychi.ascrypt.*;

// creates a LoadVars object to handle loaded external data
this.pwdLoader = new LoadVars();

// function to be called when external data is loaded into Flash
this.pwdLoader.onLoad = function(success) {
&nbsp;&nbsp;// checks if loading was succesful and external file contains data
&nbsp;&nbsp;if (success &amp;&amp; pwdLoader.pwd != &quot;&quot; &amp;&amp; pwdLoader.pwd != undefined) {
&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;// decrypts the password retrieved from the external file
&nbsp;&nbsp;&nbsp;&nbsp;// and outputs the original string
&nbsp;&nbsp;&nbsp;&nbsp;trace(&quot;PASSWORD= &quot;+Base64.decode(pwdLoader.pwd));
&nbsp;&nbsp;}
};

// loads the external .aspx file
this.pwdLoader.load(&quot;encrypted_pass.aspx&quot;);
</pre></pre></p>
<p>Save your Flash file and test it. The output panel will show PASSWORD = pass, so it gets back to the original value.</p>
<p>This is a really simple example, but shows how easy it is to handle encrypted data with the ASCrypt class.</p>
<p>You can download the ASCrypt Extension (.mxp file) and some sample Flash files from <a href="http://www.meychi.com/archive/000031.php">Meychi&#8217;s website</a>.</p>
<p style="text-align:center;"><a href="http://www.jek2k.com/wp/wp-content/uploads/2007/05/ascrypt_sample.zip"><img class="no-border" src="http://www.jek2k.com/wp/wp-content/uploads/2007/05/btn_source_down.png" alt="Download Source Code" /></a></p>
<p>Here is the source code for the example:<br />
<a href="http://www.jek2k.com/wp/wp-content/uploads/2007/05/ascrypt_sample.zip" title="ascrypt_sample.zip">Download ascrypt_sample.zip (28k ZIP)</a></p>
<p>&nbsp;</p>
<p class="note">This tutorial is provided as is. Please do not email me questions or support requests about the scripts contained in this page. Use the comments below instead. Thank you.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jek2k.com/wp/2007/05/22/cryptography-and-flash/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Timed based CSS stylesheet with PHP</title>
		<link>http://www.jek2k.com/wp/2007/05/03/timed-based-css-stylesheet-with-php/</link>
		<comments>http://www.jek2k.com/wp/2007/05/03/timed-based-css-stylesheet-with-php/#comments</comments>
		<pubDate>Thu, 03 May 2007 21:41:00 +0000</pubDate>
		<dc:creator>Nicolò</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.jek2k.com/wp/index.php/2007/05/03/timed-based-css-stylesheet-with-php/</guid>
		<description><![CDATA[It&#8217;s been quite a long time since I last posted an article here at Jek2k.com.
On my company&#8217;s web site I&#8217;ve made a little PHP script to change the CSS stylesheet depending on the time of the day. We have a bright white theme for day time and a dark black one for night time and [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been quite a long time since I last posted an article here at Jek2k.com.</p>
<p>On <a href="http://www.gnvpartners.com/web/">my company&#8217;s web site</a> I&#8217;ve made a little PHP script to change the CSS stylesheet depending on the time of the day. We have a bright white theme for day time and a dark black one for night time and Sundays (when we are closed). This script was initially inspired by the beautiful <a href="http://www.radiantmars.com/">Radiant Mars website</a>. </p>
<p>Some of you have asked me how I made it, so here is the code: </p>
<p><pre><pre>
&lt;?php 
// time based Css Swicth
$time = date(&quot;H&quot;);
$date = date(&quot;w&quot;);
if (!isset($_GET[&#039;css&#039;])) {
if ($time &gt;= 9 &amp;&amp; $time &lt; 18 &amp;&amp; $date != 0) { ?&gt;
&lt;link rel=&quot;stylesheet&quot; href=&quot;&lt;?php bloginfo(&#039;stylesheet_directory&#039;); ?&gt;/styles/day.css&quot; type=&quot;text/css&quot; media=&quot;screen&quot; /&gt;
&lt;? } else { ?&gt;
&lt;link rel=&quot;stylesheet&quot; href=&quot;&lt;?php bloginfo(&#039;stylesheet_directory&#039;); ?&gt;/styles/night.css&quot; type=&quot;text/css&quot; media=&quot;screen&quot; /&gt;
&lt;? }; 
} else { ?&gt;
&lt;link rel=&quot;stylesheet&quot; href=&quot;&lt;?php bloginfo(&#039;stylesheet_directory&#039;); ?&gt;/styles/&lt;?php echo $_GET[&#039;css&#039;]; ?&gt;.css&quot; type=&quot;text/css&quot; media=&quot;screen&quot; /&gt;
&lt;? }; ?&gt;
</pre></pre></p>
<p>Looks easy, doesn&#8217;t it? </p>
<p><strong>Let&#8217;s see it in detail</strong>.<br />
  First I&#8217;ve set up two variables to read the current time (hour) of the day and the current day (number, 0 = Sunday) of the week.</p>
<p><pre><pre>
$time = date(&quot;H&quot;);
$date = date(&quot;w&quot;);
</pre></pre></p>
<p>For more information about handling date and time with PHP, please <a href="http://it.php.net/date">see the PHP documentation</a>. </p>
<p>Then we have a pretty simple IF clause to check if the current time is between 9AM and 6PM and today is not Sunday.<br />
  According to this clause, the correct CSS stylesheet is loaded. </p>
<p><pre><pre>if ($time &gt;= 9 &amp;&amp; $time &lt; 18 &amp;&amp; $date != 0) { ?&gt;
&lt;link rel=&quot;stylesheet&quot; href=&quot;&lt;?php bloginfo(&#039;stylesheet_directory&#039;); ?&gt;/styles/day.css&quot; type=&quot;text/css&quot; media=&quot;screen&quot; /&gt;
&lt;? } else { ?&gt;
&lt;link rel=&quot;stylesheet&quot; href=&quot;&lt;?php bloginfo(&#039;stylesheet_directory&#039;); ?&gt;/styles/night.css&quot; type=&quot;text/css&quot; media=&quot;screen&quot; /&gt;
&lt;? }; 
</pre></pre></p>
<p>The last part is another IF clause, mainly for debug reasons.<br />
  It checks if we have added a variable to the page&#8217;s URL, ie. pagename.php?css=day. This way we can override the time check and load the desired CSS stylesheet directly. This is useful to test your CSS files without waiting for it to change. </p>
<p>That&#8217;s it. Pretty basic, but remember I&#8217;m just a designer!</p>
<p>Use the <a href="http://it.php.net/date">PHP  date function</a> to read other parameters and modify this script to change the CSS stylesheet according to seasons, holidays, day of the week or whatever you like. </p>
<p class="note">This tutorial is provided as is. Please do not email me questions or support requests about the scripts contained in this page. Use the comments below instead. Thank you.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jek2k.com/wp/2007/05/03/timed-based-css-stylesheet-with-php/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Multiple drop-downs</title>
		<link>http://www.jek2k.com/wp/2006/12/20/multiple-drop-downs/</link>
		<comments>http://www.jek2k.com/wp/2006/12/20/multiple-drop-downs/#comments</comments>
		<pubDate>Wed, 20 Dec 2006 21:16:52 +0000</pubDate>
		<dc:creator>Nicolò</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.jek2k.com/wp/index.php/2006/12/20/multiple-drop-downs/</guid>
		<description><![CDATA[This is a followup to my previous JavaScript tutorial (Italian version can be found here).
Many people asked for multiple drop-downs panels within one page or multiple links to open/close a single drop-down panel.
I made a little variation to the original script to cover both cases.
Hope this helps.
Download the Source Code (28k ZIP).
This tutorial is provided [...]]]></description>
			<content:encoded><![CDATA[<p>This is a followup to <a href="http://www.jek2k.com/wp/index.php/2006/07/14/drop-down-with-javascript/">my previous JavaScript tutorial</a> (Italian version can be found <a href="http://www.jek2k.com/wp/index.php/2006/06/10/drop-down-con-javascript/">here</a>).</p>
<p>Many people asked for multiple drop-downs panels within one page or multiple links to open/close a single drop-down panel.</p>
<p>I made a little variation to the original script to cover both cases.<br />
Hope this helps.</p>
<p><a href="http://www.jek2k.com/wp/wp-content/uploads/2006/12/multiple_drop_down_js.zip">Download the Source Code</a> (28k ZIP).</p>
<p class="note">This tutorial is provided as is. Please do not email me questions or support requests about the scripts contained in this page. Use the comments below instead. Thank you.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jek2k.com/wp/2006/12/20/multiple-drop-downs/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Update: Wifi low-cost per Mac</title>
		<link>http://www.jek2k.com/wp/2006/11/16/update-wifi-low-cost-per-mac/</link>
		<comments>http://www.jek2k.com/wp/2006/11/16/update-wifi-low-cost-per-mac/#comments</comments>
		<pubDate>Wed, 15 Nov 2006 23:45:44 +0000</pubDate>
		<dc:creator>Nicolò</dc:creator>
				<category><![CDATA[Reviews]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.jek2k.com/wp/index.php/2006/11/16/update-wifi-low-cost-per-mac/</guid>
		<description><![CDATA[Questo post è un&#8217;integrazione del mio precedente articolo Wifi low-cost per Mac, in cui propongo una soluzione economica all&#8217;acquisto di una scheda Airport.
Qualche giorno fa, Matteo mi ha scritto una email chiedendomi chiarimenti in merito all&#8217; articolo  citato poco fa, riportandomi alcuni problemi di funzionamento del dispositivo USB Wave 54.
Ci siamo scambiati un paio [...]]]></description>
			<content:encoded><![CDATA[<p><em>Questo post è un&#8217;integrazione del mio precedente articolo <a href="http://www.jek2k.com/wp/index.php/2006/06/12/wifi-low-cost-per-mac/">Wifi low-cost per Mac</a>, in cui propongo una soluzione economica all&#8217;acquisto di una scheda Airport.</em></p>
<p>Qualche giorno fa, Matteo mi ha scritto una email chiedendomi chiarimenti in merito all&#8217; articolo  citato poco fa, riportandomi alcuni problemi di funzionamento del dispositivo USB Wave 54.<br />
Ci siamo scambiati un paio di email e pare che ora la chiavetta USB funzioni a dovere.</p>
<p>Per questo motivo, nell&#8217;eventualità che qualcuno di voi possa riscontrare problemi simili, Matteo ed io abbiamo deciso di pubblicare questo post, nella speranza di essere di qualche aiuto e risparmiarvi ore di ricerca su Google.</p>
<p>Di seguito eccovi la cronologia delle nostre email.</p>
<blockquote><p>Ciao Nicolò,</p>
<p>ho recentemente acquistato un router wi-fi e in bundle c&#8217;era questa fantomatica chiavetta USB wave 54&#8230; Ho provato ad installare i driver da te segnalati, ma non succede nulla&#8230; l&#8217;utlity della Zydas non vede la chiavetta e il led di stato si spegne quasi subito una volta inserita la chiavetta&#8230; anc&#8217;io sono su Mac OS 10.3.9 Panther e sto usando un Mac Mini&#8230;<br />
Non so, se hai qualche consiglio ti sarei davvero grato.<br />
[...]</p>
<p>Matteo</p></blockquote>
<p>-</p>
<blockquote><p>Ciao Matteo,</p>
<p>premetto che non so molto di più sulla chiavetta USB Wave 54 rispetto a quanto scritto sul mio sito.</p>
<p>Dunque, io faccio così: inserisco la chiavetta a computer spento, lo accendo, quando Mac OS è pronto, apro Preferenze del Sistema, utility della chiavetta e seleziono la base wifi a cui connetterlo e faccio click sul bottone Connetti (&#8221;Connect this site&#8230;&#8221;).<br />
Tutto qua.<br />
A volte bisogna ripetere la procedura di connessione alla base o aspettare un po&#8217; di tempo, e non sempre la banda wifi è ottimale, però in linea di massima ha sempre funzionato in questo modo.</p>
<p>Spero ti sia utile,<br />
ciao</p>
<p>Nicolò</p></blockquote>
<p>-</p>
<blockquote><p>Ciao Nicolò,</p>
<p>ti posso dire (tenendo incrociate le dita) che la chiavetta USB digicom stia funzionando a dovere con i driver Zydas&#8230; ho fatto come hai detto, collegando la chiavetta a Mac spento&#8230; ogni tanto fa faticarsi a connettersi ma poi la navigazione è stabile.,.. per essere completi, sto usando Mac OS Panther 10.3.9 su un Mac Mini e i nuovi driver Zydas (che adesso si trovano sul sito di Atheros) nella versione 4.5.7.0. Ti ringrazio per il tuo blog, che mi è stato davvero utile e mi ha fatto risparmiare tempo e soprattutto denaro per acquistare una chiavetta wi-fi dedicata a Mac OS (che poi ce ne sono poche&#8230;)<br />
[...]</p>
<p>Buon lavoro</p>
<p>Matteo</p></blockquote>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
<strong>Updated 19.01.2007:</strong></p>
<p>In seguito alla segnalazione di Lara, posto di seguito l&#8217;ultima release dei driver, che risolve alcuni problemi di compatibilità:<br />
<a href="http://www.jek2k.com/wp/wp-content/uploads/2007/01/ZDA211MacUSB_install_4_5_7_0.dmg.zip">ZDA211MacUSB_install_4_5_7_0.dmg.zip</a> (1.7 MB ZIP).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jek2k.com/wp/2006/11/16/update-wifi-low-cost-per-mac/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress: displaying content outside the Loop</title>
		<link>http://www.jek2k.com/wp/2006/10/30/wordpress-displaying-content-outside-the-loop/</link>
		<comments>http://www.jek2k.com/wp/2006/10/30/wordpress-displaying-content-outside-the-loop/#comments</comments>
		<pubDate>Mon, 30 Oct 2006 11:59:45 +0000</pubDate>
		<dc:creator>Nicolò</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.jek2k.com/wp/index.php/2006/10/30/wordpress-displaying-content-outside-the-loop/</guid>
		<description><![CDATA[I assume everyone out there know what WordPress is and what it does.
The Loop is the process that occurs when WordPress reads the database and outputs your posts or pages to the destination Html page.
A more detailed explanation can be found here.
Inside the Loop you can use Template Tags (see this page) to modify the [...]]]></description>
			<content:encoded><![CDATA[<p>I assume everyone out there know what WordPress is and what it does.</p>
<p><strong>The Loop</strong> is the process that occurs when WordPress reads the database and outputs your posts or pages to the destination Html page.<br />
A more detailed explanation can be found <a href="http://codex.wordpress.org/The_Loop">here</a>.</p>
<p>Inside the Loop you can use <strong>Template Tags</strong> (<a href="http://codex.wordpress.org/Template_Tags">see this page</a>) to modify the output information and choose what elements of the post should be displayed (see <a href="http://codex.wordpress.org/Template_Tags#Post_tags">Post Tags</a>).</p>
<p>This is the very basic concept behind WordPress templates.</p>
<p>With WordPress you have also the ability to make <strong>custom queries</strong> to the database to extract your specific content.<br />
In this case, you will need the following sintax:<br />
<pre><pre>
&lt;?php query_posts(&#039;category_name=news&amp;showposts=5&#039;); ?&gt;
&lt;?php if (have_posts()) : ?&gt;
&lt;?php while (have_posts()) : the_post(); ?&gt;

&nbsp;&nbsp;&nbsp;&nbsp; &lt;div class=&quot;news&quot;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;h4&gt;&lt;a href=&quot;&lt;?php the_permalink(); ?&gt;&quot;&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h4&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php the_excerpt(); ?&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp; &lt;/div&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;?php endwhile; ?&gt;
&lt;?php endif; ?&gt;
</pre></pre></p>
<p>The code above works perfectly when you are inside the Loop, <strong>but what if you are outside of it?</strong><br />
Or if you want to include contents from two different loops, for example for making an Asides section?<br />
Then the <strong>query_posts()</strong> function will not be of any help.</p>
<p>You will have to make a totally new custom query, using a different sintax.<br />
This is needed in order to not overwrite the data retrieved by the main Loop query.</p>
<p>It will look like this:<br />
<pre><pre>
&lt;?php $my_query = new WP_Query(&#039;pagename=another-static-page&#039;); ?&gt;
&lt;?php while ($my_query-&gt;have_posts()) : $my_query-&gt;the_post(); ?&gt;
&lt;?php $do_not_duplicate = $post-&gt;ID; ?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;h1&gt;&lt;?php the_title(); ?&gt;&lt;/h1&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php the_content(); ?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;?php endwhile; ?&gt;
</pre></pre></p>
<p>The first line:<br />
<pre><pre>
&lt;?php $my_query = new WP_Query(&#039;pagename=another-static-page&#039;); ?&gt;
</pre></pre><br />
makes the new query and storing the retrieved data inside the <strong>$my_query</strong> variable.<br />
That&#8217;s the reason why we have that strange sintax <strong>$my_query->have_posts()</strong> later on.<br />
This ensures we are browsing data only inside our new variable.</p>
<p>This line:<br />
<pre><pre>
&lt;?php $do_not_duplicate = $post-&gt;ID; ?&gt;
</pre></pre><br />
makes sure we&#8217;re not duplicating posts, so the same post won&#8217;t appear in both queries.</p>
<p>As you can see, then we can output the information with the same good old sintax:<br />
<pre><pre>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php the_content(); ?&gt;
</pre></pre></p>
<p>This way of retrieving and displaying custom information from your WordPress database comes very handy when creating advanced themes or when using WP as a CMS platform and you want to have full control on what is displayed. </p>
<p>As always, the best place to find exhaustive information about Wordpress tweaks is the <a href="http://codex.wordpress.org">Codex website.</a></p>
<p class="note">This tutorial is provided as is. Please do not email me questions or support requests about the scripts contained in this page. Use the comments below instead. Thank you.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jek2k.com/wp/2006/10/30/wordpress-displaying-content-outside-the-loop/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>A PHP Css stylesheet switcher</title>
		<link>http://www.jek2k.com/wp/2006/08/01/a-php-css-stylesheet-switcher/</link>
		<comments>http://www.jek2k.com/wp/2006/08/01/a-php-css-stylesheet-switcher/#comments</comments>
		<pubDate>Tue, 01 Aug 2006 00:47:42 +0000</pubDate>
		<dc:creator>Nicolò</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.jek2k.com/wp/index.php/2006/08/01/a-php-css-stylesheet-switcher/</guid>
		<description><![CDATA[This is an English translation of the original  tutorial.
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-
Following my previous article, I keep on publishing the &#8220;secrets&#8221; behind Jek2k.com.
Today we&#8217;ll see how to create a Css stylesheet switcher using PHP, to change your Css on-the-fly.
There are many techniques to do that.
First, using Javascript.
On A List Apart you can find a very well written [...]]]></description>
			<content:encoded><![CDATA[<p>This is an English translation of <a href="http://www.jek2k.com/wp/index.php/2006/06/18/css-switch-con-php/">the original  tutorial</a>.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
Following <a href="http://www.jek2k.com/wp/index.php/2006/06/10/drop-down-con-javascript/">my previous article</a>, I keep on publishing the &#8220;secrets&#8221; behind Jek2k.com.<br />
Today we&#8217;ll see how to create a Css stylesheet switcher using PHP, to change your Css on-the-fly.</p>
<p>There are many techniques to do that.<br />
First, using Javascript.<br />
On <a href="http://www.alistapart.com/articles/alternate/" target="_blank">A List Apart</a> you can find a very well written tutorial to create a Css switcher with JS, using a cookie to keep the user&#8217;s preference.<br />
And the obtained page also conforms to W3C standards.</p>
<p>The main problem of this method is that, being Javascript, it runs on the client, so it depends on the browser and requires the user to have JS enabled.<br />
<em>The validity of this technique depends on your site&#8217;s target. No problem if you have a tech-savvy users target, with modern browsers and smart enough to not disable Javascript!</em></p>
<p>I chose to use another method, using PHP, not because of my users, but because I use WordPress, which is written in PHP.<br />
Aside from this, PHP runs on the server, so it is browser-independent.<br />
<a href="http://www.alistapart.com/articles/phpswitch/" target="_blank">A List Apart</a> has a very good tutorial which covers this method too.<br />
A very easy, step-by-step tutorial.</p>
<p>I&#8217;d add just a couple of suggestions, to make it even smoother.</p>
<p>First:<br />
the cookie duration.<br />
Do you really want to keep the cookie for a year??!!? I think it is really too long.</p>
<p>So, in the following piece of code<br />
<pre><pre>
&lt;?php
setcookie (&#039;sitestyle&#039;, $set, time()+31536000, &#039;/&#039;, &#039;yourdomain.com&#039;, &#039;0&#039;);
header(&quot;Location: $HTTP_REFERER&quot;);
?&gt;
</pre></pre><br />
change the value <strong>31536000</strong> (duration of the cookie, in seconds).<br />
to <strong>2592000</strong> to set a monthly cookie, or <strong>604800</strong> to set a weekly one</p>
<p>Second:<br />
the code that reads the cookie. Change the following<br />
<pre><pre>
&lt;?php echo (!$sitestyle)?&#039;defaultstyle&#039;:$sitestyle ?&gt;
</pre></pre><br />
to<br />
<pre><pre>
&lt;?php echo (!$_COOKIE[&#039;sitestyle&#039;])?&#039;defaultstyle&#039;:$_COOKIE[&#039;sitestyle&#039;] ?&gt;
</pre></pre><br />
which seems to work better (at least, it does work better for me). </p>
<p>&nbsp;</p>
<p>Well, that&#8217;s all folks!<br />
I hope this can be useful to someone.</p>
<p class="note">This tutorial is provided as is. Please do not email me questions or support requests about the scripts contained in this page. Use the comments below instead. Thank you.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jek2k.com/wp/2006/08/01/a-php-css-stylesheet-switcher/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>

