<?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>nightdrops.com &#187; tips</title>
	<atom:link href="http://www.nightdrops.com/tag/tips/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nightdrops.com</link>
	<description>like the color blue</description>
	<lastBuildDate>Thu, 01 Jul 2010 13:19:03 +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>WordPress + Google Analytics: skipping administrator pageviews</title>
		<link>http://www.nightdrops.com/2009/wordpress-google-analytics-skipping-administrator-pageviews/</link>
		<comments>http://www.nightdrops.com/2009/wordpress-google-analytics-skipping-administrator-pageviews/#comments</comments>
		<pubDate>Fri, 20 Feb 2009 08:29:59 +0000</pubDate>
		<dc:creator>kajyr</dc:creator>
				<category><![CDATA[Blog posts]]></category>
		<category><![CDATA[analytics]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.nightdrops.com/?p=160</guid>
		<description><![CDATA[Being the stat nerd that I am, I love to track visit to this blog (and other websites) with Google Analytics. Problem is that I&#8217;ve noticed that also my visits couts, i don&#8217;t want this, at least, if i&#8217;m logged as an administrator i open the blog pages lots of times, to check the comments, [...]]]></description>
			<content:encoded><![CDATA[<p>Being the stat nerd that I am, I love to track visit to this blog (and other websites) with Google Analytics.</p>
<p>Problem is that I&#8217;ve noticed that also my visits couts, i don&#8217;t want this, at least, if i&#8217;m logged as an administrator i open the blog pages lots of times, to check the comments, to edit the layout of the pages and so on.</p>
<p><strong>Edit: Marco from <a href="http://www.goanalytics.info/" target="_blank">goanalytics.info</a> suggested a smarter way to do that. See comment #1. ;-)</strong></p>
<p>So after some researches, i&#8217;ve found the solution: you can filter Analytics pageviews basing on IP or cookies. The first one is useful when you don&#8217;t want a renge of users in a lan, but since I&#8217;m a freelance and work from home (but also from my parent&#8217;s home, and sometimes i open the blog at a friend house) the IP solution doesn&#8217;t work.</p>
<p>Cookies.</p>
<p>The Idea is to modify the wordpress template, so that can insert a cookie if you are logged in as the administrator. WordPress already sets up some cookies for you, but using these will filter out every wordpress user, we just want to filter out ourselves.</p>
<p>To find if the user is an administrator, a good tip come from the <a href="http://markjaquith.wordpress.com/2006/03/27/how-to-check-if-a-wordpress-user-is-an-administrator/" target="_blank">Mark on WordPress</a> blog, you have to check user capabilities.</p>
<p>Next, reading GA Help tells you how to filter results based on a user defined keyword, you need to add a js function to the body onload event (assuming you don&#8217;t have any other, if it is the case, just add after the ;</p>
<p>Mixing the two things, something like this should came out:</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> current_user_can<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'manage_options'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
    <span style="color: #0000ff;">$onload</span> = <span style="color: #ff0000;">&quot;onLoad='javascript:pageTracker._setVar(<span style="color: #000099; font-weight: bold;">\&quot;</span>custom_keyword<span style="color: #000099; font-weight: bold;">\&quot;</span>);'&quot;</span>;<br />
<span style="color: #66cc66;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><br />
&lt;body <span style="color: #000000; font-weight: bold;">&lt;?php</span> <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #0000ff;">$onload</span>; <span style="color: #000000; font-weight: bold;">?&gt;</span> &gt;&lt;/body&gt;</div></div>
<p>This should replace your body tag, so should go in the header.php (in my template, at least); remember to replace custom keyword with something unique, a md5 of something should work.</p>
<p>Notice that this javascript uses a function from google, so you have to include the GA js library in the head. But Analytics tells you to include the code at the bottom.. You can choose. It will work fine if you just paste the GA code in the head, or else you can split it (in that code, there are 2 &lt;script&gt; blocks, the first loads the .js from Google, the seconds tracks the visits), so that the first script block goes into the head, and the latter at the bottom of the page.</p>
<p>Next you have to setup a filter in GA. Easy easy, goto Analytics Setting (the firse page after the login), find the Filter Manager link, add a new filter,with these options</p>
<p>Filter Type: Custom filter &gt; Exclude<br />
Filter Field: User Defined<br />
Filter Pattern:custom_keyword<br />
Case Sensitive: No</p>
<p>Enjoy. ;-)</p>
<p>References:</p>
<p id="post-22">Mark on WordPress: <a href="http://markjaquith.wordpress.com/2006/03/27/how-to-check-if-a-wordpress-user-is-an-administrator/" target="_blank">How to check if a WordPress user is an “administrator”</a></p>
<p class="answer_title">Google Analytics Help: <a href="http://www.google.com/support/analytics/bin/answer.py?hl=en&amp;answer=55481" target="_blank">How do I exclude my internal traffic from reports?</a>, <a href="http://www.google.com/support/googleanalytics/bin/answer.py?answer=55492&amp;hl=en" target="_blank">How do i create a custom filter</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nightdrops.com/2009/wordpress-google-analytics-skipping-administrator-pageviews/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>FlexBuilder: generating documentation</title>
		<link>http://www.nightdrops.com/2009/flex-3-generating-documentation/</link>
		<comments>http://www.nightdrops.com/2009/flex-3-generating-documentation/#comments</comments>
		<pubDate>Thu, 19 Feb 2009 22:25:49 +0000</pubDate>
		<dc:creator>kajyr</dc:creator>
				<category><![CDATA[Blog posts]]></category>
		<category><![CDATA[ant]]></category>
		<category><![CDATA[asdoc]]></category>
		<category><![CDATA[documentation]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[Flexbuilder]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.nightdrops.com/blog/?p=20</guid>
		<description><![CDATA[Has anyone tryed to document ActionScript code using asdoc? I for myself hate to input shell commands in Windoze. I used to be a unix &#8211; bash hacker (in another life), and i find particularly annoying the windows shell (don&#8217;t even talk about the one in Vista..). So i said to my good old friend [...]]]></description>
			<content:encoded><![CDATA[<p>Has anyone tryed to document ActionScript code using asdoc? I for myself hate to input shell commands in Windoze. I used to be a unix &#8211; bash hacker (in another life), and i find <span class="clickable" onclick="dr4sdgryt(event,&quot;Ox&quot;)"><span class="sg"><span class="se1"><span class="trn">particularly annoying the windows shell (don&#8217;t even talk about the one in Vista..).</span></span></span></span></p>
<p><span class="clickable" onclick="dr4sdgryt(event,&quot;Ox&quot;)"><span class="sg"><span class="se1"><span class="trn">So i said to my good old friend Google: how can i use ant (which can be used in eclipse) to generate documentation with some clicks?</span></span></span></span></p>
<p><span class="clickable" onclick="dr4sdgryt(event,&quot;Ox&quot;)"><span class="sg"><span class="se1"><span class="trn">The answer lies around and need a few hacks, I post here my version for the sake of clarity.</span></span></span></span></p>
<p><span class="clickable" onclick="dr4sdgryt(event,&quot;Ox&quot;)"><span class="sg"><span class="se1"><span class="trn">I won&#8217;t tell you how to install ANT in Eclipse / Flex Builder using the Software Update tool, this may offend you.</span></span></span></span></p>
<p><span class="clickable" onclick="dr4sdgryt(event,&quot;Ox&quot;)"><span class="sg"><span class="se1"><span class="trn">Instead i&#8217;ll tell you that once setup is done, you need to upen the Ant view and you need an xml named build.xml with some rules in it, that tells which program to run, in which folder to save the output and so on. The xml is pretty self explaining, but in case just drop a line.</span></span></span></span></p>
<pre><span class="clickable" onclick="dr4sdgryt(event,&quot;Ox&quot;)"><span class="sg"><span class="se1"><span class="trn">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;project name="asdoc" default="main" basedir="."&gt;

    &lt;property name="Flex.dir" location="C:\Program Files\Adobe\Flex Builder 3"/&gt;

    &lt;property name="FlexSDK.dir" location="${Flex.dir}\sdks\3.2.0"/&gt;

    &lt;property name="AsDocs.dir" location="${FlexSDK.dir}\bin\asdoc.exe"/&gt;

    &lt;property name="AppClasses.dir" location="${basedir}\..\src"/&gt;

    &lt;property name="Output.dir" location="${basedir}\out" /&gt;

    &lt;target name="main" depends="clean,compile" description="full build of asdocs"/&gt;

    &lt;target name="clean"&gt;
        &lt;delete dir="${Output.dir}" failOnError="false" includeEmptyDirs="true"/&gt;
        &lt;mkdir dir="${Output.dir}"/&gt;
    &lt;/target&gt;

    &lt;target name="compile"&gt;
        &lt;exec executable="${AsDocs.dir}" failonerror="true"&gt;
            &lt;arg line='+configname=air'/&gt;
            &lt;arg line='-doc-sources ${AppClasses.dir}'/&gt;
            &lt;arg line='-window-title "My Application"'/&gt;
            &lt;arg line='-output ${Output.dir}'/&gt;
        &lt;/exec&gt;
    &lt;/target&gt;

&lt;/project&gt;

</span></span></span></span></pre>
<p><span class="clickable" onclick="dr4sdgryt(event,&quot;Ox&quot;)"><span class="sg"><span class="se1"><span class="trn">Note that the paths are relative to the position of the build.xml file.<br />
(Also, i didn&#8217;t build the xml from scratch, there are many version of the same file on many blogs, so if the one who wrote it shows up, it will be an honor to credit him)<br />
</span></span></span></span></p>
<p><span class="clickable" onclick="dr4sdgryt(event,&quot;Ox&quot;)"><span class="sg"></span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nightdrops.com/2009/flex-3-generating-documentation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Easy recursion: determine if a component is showing</title>
		<link>http://www.nightdrops.com/2009/easy-recursion-determine-if-a-component-is-showing/</link>
		<comments>http://www.nightdrops.com/2009/easy-recursion-determine-if-a-component-is-showing/#comments</comments>
		<pubDate>Mon, 19 Jan 2009 15:54:09 +0000</pubDate>
		<dc:creator>kajyr</dc:creator>
				<category><![CDATA[Blog posts]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[recursion]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.nightdrops.com/?p=97</guid>
		<description><![CDATA[A good and easy example of a recursive function has come to my mind while replying to this question on stackoverflow. The problem was how to know is a component (mx:UIComponent) was visible or not, just like Component.isShowing() works in Java. You canno&#8217;t rely on the visible property of the UIComponent, you have to check [...]]]></description>
			<content:encoded><![CDATA[<p>A good and easy example of a recursive function has come to my mind while replying to <a href="http://stackoverflow.com/questions/452344/flex-determine-if-a-component-is-showing#456699" target="_blank">this question</a> on <a href="http://stackoverflow.com/">stackoverflow</a>.</p>
<p>The problem was how to know is a component (mx:UIComponent) was visible or not, just like <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Component.html#isShowing()">Component.isShowing()</a> works in Java. You canno&#8217;t rely on the visible property of the UIComponent, you have to check every parent to see if it too is visible.</p>
<p>First step in recursion is to block the basic level. If the component reference is null, it is not visible; if the component we are checking is an Application, it should be visible, according to his visible property (it doesn&#8217;t have a parent).</p>
<p>All the other cases should check the property, AND the parent&#8217;s property. (If a component isn&#8217;t on the DisplayList, his parent will be null, and it will not be visible,  and so for all of his children).</p>
<div class="codecolorer-container actionscript3 default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><br /><strong>GeSHi Error:</strong> GeSHi could not find the language actionscript3 (using path /nfs/c03/h01/mnt/85630/domains/nightdrops.com/html/wp-content/plugins/snipplr/geshi/geshi/) (code 2)<br /></div>
]]></content:encoded>
			<wfw:commentRss>http://www.nightdrops.com/2009/easy-recursion-determine-if-a-component-is-showing/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The stage property and the display list</title>
		<link>http://www.nightdrops.com/2009/the-stage-property-and-the-display-list/</link>
		<comments>http://www.nightdrops.com/2009/the-stage-property-and-the-display-list/#comments</comments>
		<pubDate>Fri, 09 Jan 2009 10:37:16 +0000</pubDate>
		<dc:creator>kajyr</dc:creator>
				<category><![CDATA[Blog posts]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.nightdrops.com/blog/?p=17</guid>
		<description><![CDATA[In Actionscript, the stage object is referenced by the DisplayObject.stage property. I use it alot, for example, to center elements on the screen, but as we read in the api reference, If a display object is not added to the display list, its stage property is set to null. this can be uncomfortable when you want to position something [...]]]></description>
			<content:encoded><![CDATA[<p>In Actionscript, the stage object is referenced by the <a href="http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/display/DisplayObject.html#stage" target="_blank">DisplayObject.stage</a> property. I use it alot, for example, to center elements on the screen, but as we read in the api reference,</p>
<blockquote><p>If a display object is not added to the display list, its stage property is set to null.</p></blockquote>
<p>this can be uncomfortable when you want to position something <em>before</em> attaching it, for any reason, or if you want a control object to operate on some stage property (fullscreen, for example).</p>
<p>So to avoid this, I usually add a static property to my Document Class, let&#8217;s call it staticStage:</p>
<div class="codecolorer-container actionscript3 default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><br /><strong>GeSHi Error:</strong> GeSHi could not find the language actionscript3 (using path /nfs/c03/h01/mnt/85630/domains/nightdrops.com/html/wp-content/plugins/snipplr/geshi/geshi/) (code 2)<br /></div>
<p>Of course, the stage in FlashExample will not be null, since the DocumentClass is always added to the display list.</p>
<p>With this trick, you always have the stage at hand, by simply referencing <tt>FlashExample.staticStage</tt> anywhere on your code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nightdrops.com/2009/the-stage-property-and-the-display-list/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fading out and detaching</title>
		<link>http://www.nightdrops.com/2009/fading-out-and-detaching/</link>
		<comments>http://www.nightdrops.com/2009/fading-out-and-detaching/#comments</comments>
		<pubDate>Thu, 08 Jan 2009 10:27:31 +0000</pubDate>
		<dc:creator>kajyr</dc:creator>
				<category><![CDATA[Blog posts]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[quickreference]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[TweenLite]]></category>

		<guid isPermaLink="false">http://www.nightdrops.com/blog/?p=10</guid>
		<description><![CDATA[One class i really do like is TweenLite. I don&#8217;t really like the default tweening engine for a couple of reasons, but mainly because i have to save the tween object in a reference in my class, or the garbage collector could eat it (stopping the tweens in a unpredictable status). TweenLite don&#8217;t require this [...]]]></description>
			<content:encoded><![CDATA[<p>One class i really do like is <a href="http://blog.greensock.com/tweenliteas3/">TweenLite</a>. I don&#8217;t really like the default tweening engine for a couple of reasons, but mainly because i have to save the tween object in  a reference in my class, or the garbage collector could eat it (stopping the tweens in a unpredictable status).<br />
TweenLite don&#8217;t require this (it exposes static functions, and keep internal references to the tweens) and permits me to specify functions to be called, not only handlers (which i know, may sound a little ActionScript 2.0, but in fact permits to call any funcion, and so avoiding one-line handlers).</p>
<p>One small example, (to be used inside a DisplayObjectContainer) is fading out a child, and detaching after. In one clear line<span style="font-family:monospace;">:</span></p>
<div class="codecolorer-container actionscript3 default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><br /><strong>GeSHi Error:</strong> GeSHi could not find the language actionscript3 (using path /nfs/c03/h01/mnt/85630/domains/nightdrops.com/html/wp-content/plugins/snipplr/geshi/geshi/) (code 2)<br /></div>
<p>Let&#8217;s bring this a step further: we can easily apply this technique to all child of a given container:</p>
<div class="codecolorer-container actionscript3 default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><br /><strong>GeSHi Error:</strong> GeSHi could not find the language actionscript3 (using path /nfs/c03/h01/mnt/85630/domains/nightdrops.com/html/wp-content/plugins/snipplr/geshi/geshi/) (code 2)<br /></div>
<p>So now all the time removeChild is called from outside, the child gently fade away, and then quietly removes himself.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nightdrops.com/2009/fading-out-and-detaching/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
