<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0' version='2.0'><channel><atom:id>tag:blogger.com,1999:blog-6207583460783647164</atom:id><lastBuildDate>Mon, 28 May 2012 11:24:54 +0000</lastBuildDate><category>Regex</category><category>Max</category><category>excel</category><category>css</category><category>tutorials</category><category>mysql</category><category>js</category><category>Max/MSP</category><category>Generative Art</category><category>Javascript</category><category>php</category><category>AS2</category><category>tips</category><category>html</category><category>shortcuts</category><category>AS3</category><category>Actionscript</category><category>Apache</category><category>functions</category><category>csv</category><category>cookie</category><category>usability</category><title>Cron's Web Tech Blog</title><description>Useful scripts, utilities and classes for developers of HTML, PHP, Javascript, Actionscript, mySQL, CSS, etc. This blog will fill the occasional gaps in information I stumble across in my daily developing. If there's something I feel is missing from the vast pool of stuff already out there, I'll post it here. I'm a nice guy. You'd like me.</description><link>http://blog.crondesign.com/</link><managingEditor>noreply@blogger.com (Ciarán O'Kelly)</managingEditor><generator>Blogger</generator><openSearch:totalResults>39</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-6207583460783647164.post-4372569963734057337</guid><pubDate>Mon, 28 May 2012 11:11:00 +0000</pubDate><atom:updated>2012-05-28T12:24:54.428+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>usability</category><category domain='http://www.blogger.com/atom/ns#'>tips</category><category domain='http://www.blogger.com/atom/ns#'>shortcuts</category><title>Add Photoshop PSD &amp; Illustrator AI folder thumbnails to all versions of Windows XP/2003/Vista/2008/7 32/64-bit</title><description>&lt;span style="font-family: inherit;"&gt;This is great. Adobe have never bothered to provide thumbnail support for windows machines. I dont know if this is because they are technically&amp;nbsp;incompetent, lazy&amp;nbsp;or they are just trying to promote their bloated&amp;nbsp;Adobe&amp;nbsp;Bridge viewer application. Either way it bugs me, as users have been screaming for this no-brainer feature since photoshop first arrived on the windows platform in 1992. Yes that's 20 years ago. Anyway, I've been applying registry hacks and messing with dlls for years to get thumbnails going in windows explorer but I finally found this tool today which is a quick and simple solution that claims to work across all versions of both windows and Adobe CS.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: inherit;"&gt;The installer below makes windows&amp;nbsp;automatically&amp;nbsp;load thumbs for all versions of Photoshop and Illustrator in the normal windows folder view.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;span style="background-color: #fff2cc;"&gt;&lt;span style="color: #741b47; font-family: inherit;"&gt;See note in the right hand frame if I helped you out! &amp;gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="background-color: #fff2cc;"&gt;&lt;span style="color: #741b47; font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="background-color: #fff2cc;"&gt;&lt;b style="background-color: white; line-height: 20px;"&gt;&lt;span style="font-family: inherit;"&gt;First install one of these:&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://sourceforge.net/projects/ghostscript/files/AFPL%20Ghostscript/8.54/gs854w32.exe/download" rel="nofollow" style="color: #0000cc; line-height: 1.25em;"&gt;&lt;span style="font-family: inherit;"&gt;AFPL Ghostscript 8.54 32-bit (gs854w32.exe)&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://sourceforge.net/projects/ghostscript/files/AFPL%20Ghostscript/8.54/gs854w64.exe/download" rel="nofollow" style="color: #0000cc; line-height: 1.25em;"&gt;&lt;span style="font-family: inherit;"&gt;AFPL Ghostscript 8.54 64-bit (gs854w64.exe)&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-family: inherit;"&gt;&lt;b&gt;Then install this:&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="https://code.google.com/p/sagethumbs/downloads/list"&gt;&lt;span style="font-family: inherit;"&gt;https://code.google.com/p/sagethumbs/downloads/list&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: inherit;"&gt;...................&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: inherit;"&gt;Thanks to&amp;nbsp;&lt;span style="background-color: white; line-height: 16px;"&gt;Nikolay Raspopov for this!&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: inherit;"&gt;&lt;a class="jive-link-external-small" href="https://code.google.com/p/sagethumbs/" rel="nofollow" style="background-color: #e7e7e7; border-collapse: collapse; border-spacing: 0px; border: 0px; color: #3a91d7; line-height: 21px; list-style: none; margin: 0px; outline: none; padding: 0px; text-align: left; text-decoration: none;" target="_blank"&gt;https://code.google.com/p/sagethumbs/&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: inherit;"&gt;&lt;span style="background-color: white; line-height: 16px;"&gt;SageThumbs Copyright (C) Nikolay Raspopov, 2004-2012. Web site:&amp;nbsp;&lt;/span&gt;&lt;a href="http://www.cherubicsoft.com/projects/sagethumbs" rel="nofollow" style="background-color: white; color: #0000cc; line-height: 16px;"&gt;cherubicsoft.com/projects/sagethumbs&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="background-color: #fff2cc;"&gt;&lt;span style="color: #741b47; font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="background-color: white; line-height: 1.25em; max-width: 64em;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6207583460783647164-4372569963734057337?l=blog.crondesign.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.crondesign.com/2012/05/add-photoshop-psd-illustrator-ai-folder.html</link><author>noreply@blogger.com (Ciarán O'Kelly)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-6207583460783647164.post-6660130255697239594</guid><pubDate>Fri, 11 May 2012 11:57:00 +0000</pubDate><atom:updated>2012-05-28T12:12:43.795+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>js</category><category domain='http://www.blogger.com/atom/ns#'>Javascript</category><category domain='http://www.blogger.com/atom/ns#'>html</category><category domain='http://www.blogger.com/atom/ns#'>functions</category><title>Simple Javascript Pie Chart using HTML5 Canvas tag</title><description>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-eExwerFZNE0/T6z97Ik8nhI/AAAAAAAAO4g/3uxX6KE5se4/s1600/pie.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/-eExwerFZNE0/T6z97Ik8nhI/AAAAAAAAO4g/3uxX6KE5se4/s1600/pie.gif" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;I had a look around today for a handy pie chart that I could quickly drop into a new web app I'm working on and it seems there's a lot of bloated solutions out there. I like to keep things short and sweet so I found this one online and edited it to make it a bit more user friendly. Enjoy!&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="background-color: #fff2cc; color: purple;"&gt;Please see right hand pane before copying my code &amp;gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class="javascript"&gt;&lt;br /&gt;//ADD THIS BETWEEN YOUR HEAD TAGS OR TO AN EXTERNAL JS FILE:&lt;br /&gt;var pieProps = new Object()&lt;br /&gt;&lt;br /&gt;function pieChart(canvas, radius, percentages, n, colors) {&lt;br /&gt; var canvas = document.getElementById(canvas)&lt;br /&gt; var a = pieProps.a = canvas.getContext("2d");&lt;br /&gt; pieProps.colors = colors&lt;br /&gt; pieProps.i = 0&lt;br /&gt; canvas.width = 3.5*radius;&lt;br /&gt; canvas.height = 2.5*radius;&lt;br /&gt; x = y = canvas.height/2;&lt;br /&gt; a.font = "bold 12px Arial";&lt;br /&gt; var u = 0;&lt;br /&gt; var v = 0;&lt;br /&gt; for (i=0;i &amp;lt; percentages.length;i++) {&lt;br /&gt;  v += percentages[i];&lt;br /&gt;  W(i)(x,y,radius,u,v);&lt;br /&gt;  u = v;&lt;br /&gt;  a.fillText(n[i], x+radius+10, y-radius/2+i*18);&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function W(x,y,r,u,v) {&lt;br /&gt; var a = pieProps.a&lt;br /&gt; r ? a.beginPath() | a.fill(a.moveTo(x,y)|a.arc(x,y,r,(u||0)/50*Math.PI,(v||7)/50*Math.PI,0)|a.lineTo(x,y))&lt;br /&gt; : a.fillStyle = '#'+pieProps.colors[pieProps.i++];&lt;br /&gt; return W;&lt;br /&gt;}&lt;br /&gt;//ADD THIS TO YOUR PAGE SOMEWHERE:&lt;br /&gt;&amp;lt;canvas id="c"&amp;gt; Your browser does not support the canvas element. &amp;lt;/canvas&amp;gt;&lt;br /&gt;&lt;br /&gt;//EXAMPLE USAGE:&lt;br /&gt;&amp;lt;body onload="pieChart('c', 100, [70,25,15], ['Carbs','Protein','Fat'], ['CCCCCC','FFBF43','FF850D'])"&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;This code is adapted from&amp;nbsp;&lt;a href="http://reubencrane.com/canvas_pie.html"&gt;http://reubencrane.com/canvas_pie.html&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6207583460783647164-6660130255697239594?l=blog.crondesign.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.crondesign.com/2012/05/simple-javascript-pie-chart-using-html5.html</link><author>noreply@blogger.com (Ciarán O'Kelly)</author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-eExwerFZNE0/T6z97Ik8nhI/AAAAAAAAO4g/3uxX6KE5se4/s72-c/pie.gif' height='72' width='72'/><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-6207583460783647164.post-8456092845049573527</guid><pubDate>Fri, 23 Mar 2012 18:08:00 +0000</pubDate><atom:updated>2012-05-28T12:13:51.033+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>Actionscript</category><category domain='http://www.blogger.com/atom/ns#'>AS3</category><title>AS3 Load external flash SWFs into a queue to play in a consecutive sequence</title><description>This script imports a text file from the local directory and imports all swfs listed in the text file to play on the stage sequentially, i.e. one after another. Its very useful for banner ads and other animations when you need to be able to slot new ads into the sequence.&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;You dont need to understand or edit the code at all to use this so I'm not going to post the actual code. Just a download link with some instructions:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Open the bannercontrol.fla and change the stage dimensions to the size you need.&lt;/li&gt;&lt;li&gt;Open swfsequence.swf and add any filenames you need to the sequence&lt;/li&gt;&lt;li&gt;Place any files you want to import into the same folder as the other files and let her rip!&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="background-color: #fff2cc;"&gt;&lt;span style="color: #4c1130;"&gt;Please see my note in the right hand pane before &lt;a href="http://www.crondesign.com/projects/downloads/SWFsequence.zip" rel="nofollow" target="_blank"&gt;downloading the files&lt;/a&gt;&amp;nbsp;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6207583460783647164-8456092845049573527?l=blog.crondesign.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.crondesign.com/2012/03/as3-load-external-flash-swfs-into-queue.html</link><author>noreply@blogger.com (Ciarán O'Kelly)</author><thr:total>1</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-6207583460783647164.post-5047249931315920370</guid><pubDate>Thu, 26 Jan 2012 18:34:00 +0000</pubDate><atom:updated>2012-01-30T12:45:14.684Z</atom:updated><category domain='http://www.blogger.com/atom/ns#'>js</category><category domain='http://www.blogger.com/atom/ns#'>Javascript</category><category domain='http://www.blogger.com/atom/ns#'>functions</category><title>Free Javascript for Rotating Website Banner or Fading Slideshow - standalone</title><description>As flash becomes less widespread I've had more and more instances where I need to create website banners in Javascript rather than my &lt;a href="http://blog.crondesign.com/2009/11/free-as2-script-for-rotating-website.html" target="_blank"&gt;old flash approach&lt;/a&gt;. Today I've decided to share my method with my adoring public (that's you).&lt;br /&gt;&lt;br /&gt;This method is completely standalone and doesn not require jQuery or any other plugins or architecture. It has been tested and works in latest versions of all browsers.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.crondesign.com/projects/demos/banner.html" target="_blank"&gt;View a demo here&lt;/a&gt; (right click to get the whole source at once) or view the step-by-step instructions below...&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;span style="background-color: #fff2cc; color: #4c1130;"&gt;Please see my note before copying my code - thank you! &amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;span style="background-color: #fff2cc; color: purple;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;Add this between your head tags. You can tweak the speeds etc in the BANNER SETUP section at the top.&lt;/div&gt;&lt;pre&gt;&lt;code class="javascript"&gt;&lt;br /&gt;//ROTATING BANNER BY CIARAN O'KELLY 2012 - BLOG.CRONDESIGN.COM&lt;br /&gt;//BANNER SETUP:&lt;br /&gt;var imageCount = 5;  //how many images in total?&lt;br /&gt;var changeSpeed = 3;  //how many seconds between fades?&lt;br /&gt;var fadeSpeed = 0.5; //how many seconds should the fade take?&lt;br /&gt;var fps = 25;   //animation frames per second&lt;br /&gt;//BANNER FUNCTIONS:&lt;br /&gt;var topImgID&lt;br /&gt;var changeInterval&lt;br /&gt;function $(id){&lt;br /&gt; return(document.getElementById(id));&lt;br /&gt;}&lt;br /&gt;function changeOpac(obj, opacity) {//change the opacity for different browsers:&lt;br /&gt; obj = obj.style; &lt;br /&gt; obj.opacity = (opacity / 100);&lt;br /&gt; obj.MozOpacity = (opacity / 100);&lt;br /&gt; obj.KhtmlOpacity = (opacity / 100);&lt;br /&gt; obj.filter = "alpha(opacity=" + opacity + ")";&lt;br /&gt;}&lt;br /&gt;function changeImage(){&lt;br /&gt; var nextImgID = ( topImgID+1 &amp;lt;= imageCount ? topImgID+1 : 1 ); //get id number of next image in list&lt;br /&gt; var nextImg = $('banner'+nextImgID);&lt;br /&gt; var lastImg = $('banner'+topImgID);&lt;br /&gt; var opac = 0;&lt;br /&gt; changeOpac( nextImg, opac) //make next image invisible, then bring it to the top:&lt;br /&gt; lastImg.style.zIndex = 2;&lt;br /&gt; nextImg.style.zIndex = 3;&lt;br /&gt; var fadeInterval = setInterval(function(){ //run fade on interval:&lt;br /&gt;  if(opac &amp;lt; 100){//continue fade:&lt;br /&gt;   opac += Math.ceil(100/(fadeSpeed*fps));&lt;br /&gt;   changeOpac(nextImg, opac);&lt;br /&gt;  }else{//end fade:&lt;br /&gt;   lastImg.style.zIndex = 1;&lt;br /&gt;   clearInterval(fadeInterval);&lt;br /&gt;  }&lt;br /&gt; }, 1000/fps)&lt;br /&gt; topImgID = nextImgID; //prepare next fade&lt;br /&gt;}&lt;br /&gt;function startBanner(firstImageID){&lt;br /&gt; topImgID = (firstImageID==undefined ? 1+Math.floor(Math.random()*(imageCount)) : firstImageID);&lt;br /&gt; $('banner'+topImgID).style.zIndex = 2;&lt;br /&gt; changeInterval = setInterval(changeImage, changeSpeed*1000);&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;Add this to your stylesheet and tweak to your liking:&lt;/div&gt;&lt;pre&gt;&lt;code class="css"&gt;&lt;br /&gt;.banner{position:absolute; z-index:1; height:230px; width:720px; top:0px; background:#FFF; border:solid 1px #CCC}&lt;br /&gt;.banner h1{position: absolute; bottom:20px; right:20px; font-style:italic; color:#444; float:right; width:50%; font-size:40px; text-align:right; line-height:100%;}&lt;br /&gt;#banner1{background-image:url(banner1.jpg);}&lt;br /&gt;#banner2{background-image:url(banner2.jpg);}&lt;br /&gt;#banner3{background:#F90}&lt;br /&gt;#banner4{background:#FFC}&lt;br /&gt;#banner5{background:#99CCFF}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div&gt;Add this to your html and tweak to your liking::&lt;/div&gt;&lt;pre&gt;&lt;code class="html"&gt;&lt;br /&gt;        &amp;lt;div id=&amp;quot;banner1&amp;quot; class=&amp;quot;banner&amp;quot;&amp;gt;&lt;br /&gt;            &amp;lt;h1&amp;gt;This banner fades between images&amp;lt;/h1&amp;gt;&lt;br /&gt;        &amp;lt;/div&amp;gt;&lt;br /&gt;        &amp;lt;div id=&amp;quot;banner2&amp;quot; class=&amp;quot;banner&amp;quot;&amp;gt;&lt;br /&gt;            &amp;lt;h1&amp;gt;It runs on a loop&amp;lt;/h1&amp;gt;&lt;br /&gt;        &amp;lt;/div&amp;gt;&lt;br /&gt;        &amp;lt;div id=&amp;quot;banner3&amp;quot; class=&amp;quot;banner&amp;quot;&amp;gt;&lt;br /&gt;            &amp;lt;h1&amp;gt;The images are actually div tags&amp;lt;/h1&amp;gt;&lt;br /&gt;        &amp;lt;/div&amp;gt;&lt;br /&gt;        &amp;lt;div id=&amp;quot;banner4&amp;quot; class=&amp;quot;banner&amp;quot;&amp;gt;&lt;br /&gt;            &amp;lt;h1&amp;gt;So they can contain text, colours or other content&amp;lt;/h1&amp;gt;&lt;br /&gt;        &amp;lt;/div&amp;gt;&lt;br /&gt;        &amp;lt;div id=&amp;quot;banner5&amp;quot; class=&amp;quot;banner&amp;quot;&amp;gt;&lt;br /&gt;            &amp;lt;h1&amp;gt;You can control the speed, the start image &amp;amp; number of images&amp;lt;/h1&amp;gt;&lt;br /&gt;        &amp;lt;/div&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;Finally, if you want the banner to automatically start, add this to your body tag. &lt;b&gt;1&lt;/b&gt; is the id of the first image you want to show. Leave it blank to choose a random image.&lt;br /&gt;&lt;pre&gt;&lt;code class="html"&gt;&lt;br /&gt;&amp;lt;body onload=&amp;quot;startBanner(1)&amp;quot;&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6207583460783647164-5047249931315920370?l=blog.crondesign.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.crondesign.com/2012/01/free-javascript-for-rotating-website.html</link><author>noreply@blogger.com (Ciarán O'Kelly)</author><thr:total>6</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-6207583460783647164.post-8503200566803143117</guid><pubDate>Sun, 13 Nov 2011 22:26:00 +0000</pubDate><atom:updated>2011-11-13T22:32:55.930Z</atom:updated><category domain='http://www.blogger.com/atom/ns#'>tips</category><category domain='http://www.blogger.com/atom/ns#'>css</category><title>Print CSS backgrounds in Google Chrome &amp; Safari webkit</title><description>&lt;span style="font-family: inherit;"&gt;Up until now it's been impossible, but a new fix published this week by the chrome team makes it simple for a site developer to trigger background printing using CSS...&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;div&gt;&lt;span style="font-family: inherit;"&gt;Just add the following CSS rule to any element you want to print as it looks on screen (you need &lt;b&gt;chrome 17&lt;/b&gt; or higher for this to work):&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="background-color: #fff2cc; color: purple;"&gt;&lt;span style="font-family: inherit;"&gt;If I helped you out, please see my note &amp;nbsp;:) &amp;nbsp; &amp;nbsp;&amp;gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;-webkit-print-color-adjust:exact;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6207583460783647164-8503200566803143117?l=blog.crondesign.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.crondesign.com/2011/11/print-css-backgrounds-in-google-chrome.html</link><author>noreply@blogger.com (Ciarán O'Kelly)</author><thr:total>4</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-6207583460783647164.post-1415233273821613262</guid><pubDate>Sat, 05 Nov 2011 21:11:00 +0000</pubDate><atom:updated>2011-11-05T21:38:46.437Z</atom:updated><category domain='http://www.blogger.com/atom/ns#'>js</category><category domain='http://www.blogger.com/atom/ns#'>Javascript</category><category domain='http://www.blogger.com/atom/ns#'>functions</category><title>Javascript function for checking a variables type or empty/unset variables - similar to PHP's empty()</title><description>I've been building on this one all week and I'm finding it more and more useful for quickly writing variable checks at the top of functions. You can use it to easily check if a var is defined or check if it is of a certain type. It's a work in progress but it's very handy. Check out the commented examples to get an idea of potential uses. Ideas for improvements/additions are welcome!&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;span style="background-color: #fff2cc;"&gt;&lt;span style="color: purple;"&gt;Please see note before copying my code&amp;gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class="javascript"&gt;&lt;br /&gt;//CHECK TYPE OF PASSED OBJ:&lt;br /&gt;function is(obj,type){&lt;br /&gt; switch(type){&lt;br /&gt;  case 'array': case 'ar': //ARRAY:&lt;br /&gt;   return(String(obj.constructor).indexOf('Array')&amp;gt;-1)&lt;br /&gt;  break;&lt;br /&gt;  case 'integer': case 'int': case 'number': //NUMBER:&lt;br /&gt;   return((parseFloat(obj) == parseInt(obj)) &amp;amp;&amp;amp; !isNaN(obj))&lt;br /&gt;  break;&lt;br /&gt;  default: //IS EMPTY:&lt;br /&gt;   if(obj==null || obj==undefined || obj==' ' || obj==0 || obj==false || obj=="false" || obj=='' || obj=="\n") return(false);&lt;br /&gt;   return(true)&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;/*EXAMPLES:&lt;br /&gt;returns true if myvar is a positive value (string, number, array, DOM element, etc):&lt;br /&gt;if(is(myvar)){..continue with function...}&lt;br /&gt;&lt;br /&gt;returns true if myvar is an array:&lt;br /&gt;if(is(myvar,'array')){..continue with function...}&lt;br /&gt;&lt;br /&gt;returns true if myvar is an integer or can be converted to an integer:&lt;br /&gt;if(is(myvar,'int')){..continue with function...}&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;//CHECKS IF ANY OF THE PASSED ARG(S) ARE BLANK OR FALSE OR 0 OR UNDEFINED:&lt;br /&gt;function isempty(){&lt;br /&gt; for (var i = 0; i &amp;lt; arguments.length; i++) {&lt;br /&gt;  if(!is(arguments[i])){return(true)}&lt;br /&gt; }  &lt;br /&gt; return(false)&lt;br /&gt;}&lt;br /&gt;/*EXAMPLE:&lt;br /&gt;if(isempty(requiredVar1,requiredVar2,requiredVar3)){&lt;br /&gt;       return(false);&lt;br /&gt;}else{...continue with function...}&lt;br /&gt;*/ &lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6207583460783647164-1415233273821613262?l=blog.crondesign.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.crondesign.com/2011/11/javascript-function-for-checking.html</link><author>noreply@blogger.com (Ciarán O'Kelly)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-6207583460783647164.post-95715779934668453</guid><pubDate>Wed, 12 Oct 2011 16:21:00 +0000</pubDate><atom:updated>2011-10-12T17:38:01.776+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>tips</category><title>How to repair Google Apps setup server errors</title><description>I got a tip today from a friend of mine working in Google. A server error occurred during the registration of my new domain and I was left with no gApps and no tech support (anyone on gApps standard will notice there is absolutely no way to contact anyone remotely related to a google employee).&lt;br /&gt;&lt;div&gt;Anyway it seems the most common of these server errors is that the account you register with is not given admin rights. Here's the fix...&lt;br /&gt;&lt;div&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;span style="background-color: #fff2cc;"&gt;&lt;span style="color: purple;"&gt;Please see note in right hand pane before or after trying this :)&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Try this troubleshooter:&lt;/div&gt;&lt;div&gt;&lt;a class="ot-anchor" href="http://www.google.com/support/a/bin/answer.py?answer=143296" style="background-color: white; color: #3366cc; cursor: pointer; font-family: arial, sans-serif; font-size: 13px; line-height: 18px; text-decoration: none;"&gt;http://www.google.com/support/a/bin/answer.py?answer=143296&lt;/a&gt;&lt;span style="background-color: white; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;"&gt;&amp;nbsp;and select &lt;b&gt;'I never created an admin account'&lt;/b&gt;.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="background-color: white; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;"&gt;Follow the instructions to restore access!&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6207583460783647164-95715779934668453?l=blog.crondesign.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.crondesign.com/2011/10/how-to-repair-google-apps-setup-server.html</link><author>noreply@blogger.com (Ciarán O'Kelly)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-6207583460783647164.post-6106335024450409528</guid><pubDate>Tue, 19 Jul 2011 12:52:00 +0000</pubDate><atom:updated>2011-07-27T12:00:53.759+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>tutorials</category><category domain='http://www.blogger.com/atom/ns#'>html</category><category domain='http://www.blogger.com/atom/ns#'>css</category><title>Most simple/basic single level CSS dropdown menu without Javascript tutorial</title><description>Sometimes when web demos focus on extended functionality, it's difficult to identify and extract exactly what you need for your own project from the examples. With beginners &amp;amp; newcomers to CSS in mind, I've put together this extremely simple dropdown menu &amp;amp; tutorial. You can take this skeleton and add styling and content for your own project. This menu auto sizes/auto expands to fit its content and could easily be adapted to add more levels, animation or fancy styling.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.crondesign.com/projects/demos/dropdown.html" target="_blank"&gt;Check out the demo here&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Step by Step:&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;1.&lt;/b&gt; Firstly you'll need to create some links. Here's some I made earlier. Copy the code below somewhere inside your body tags.&lt;br /&gt;&lt;span class="Apple-style-span" style="background-color: #fff2cc; color: purple;"&gt;&lt;i&gt;Please see the right hand pane before copying my code - Thank you! &amp;gt;&amp;gt;&amp;gt;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class="html"&gt;&lt;br /&gt;&amp;lt;ul id='menu'&amp;gt;&lt;br /&gt;   &amp;lt;li&amp;gt;&amp;lt;a href='#'&amp;gt;Colours&amp;lt;/a&amp;gt;&lt;br /&gt;     &amp;lt;ul&amp;gt;&lt;br /&gt;         &amp;lt;li&amp;gt;&amp;lt;a href='#'&amp;gt;Red&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;         &amp;lt;li&amp;gt;&amp;lt;a href='#'&amp;gt;Yellow&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;         &amp;lt;li&amp;gt;&amp;lt;a href='#'&amp;gt;Blue&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;     &amp;lt;/ul&amp;gt;&lt;br /&gt;   &amp;lt;/li&amp;gt;&lt;br /&gt;   &amp;lt;li&amp;gt;&amp;lt;a href='#'&amp;gt;Fruits&amp;lt;/a&amp;gt;&lt;br /&gt;     &amp;lt;ul&amp;gt;&lt;br /&gt;         &amp;lt;li&amp;gt;&amp;lt;a href='#'&amp;gt;Orange&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;         &amp;lt;li&amp;gt;&amp;lt;a href='#'&amp;gt;Apple&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;         &amp;lt;li&amp;gt;&amp;lt;a href='#'&amp;gt;Bananna&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;     &amp;lt;/ul&amp;gt;&lt;br /&gt;   &amp;lt;/li&amp;gt;&lt;br /&gt;   &amp;lt;li&amp;gt;&amp;lt;a href='#'&amp;gt;No Submenu&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;b&gt;2.&lt;/b&gt; Next, you'll need to add styling. Copy the code below and paste inside your style tags or in your external stylesheet.&lt;br /&gt;&lt;pre&gt;&lt;code class="css"&gt;&lt;br /&gt;/*DROPDOWN FUNCTIONALITY*/&lt;br /&gt;/*set up ul tags*/ &lt;br /&gt;#menu, #menu ul{ padding:0; margin:0}&lt;br /&gt;/*set up a tags*/ &lt;br /&gt;#menu a{display:block;}&lt;br /&gt;/*position level 1 links horizontally*/ &lt;br /&gt;#menu li{display:block; float:left;}&lt;br /&gt;/*undo previous style for level 2 links*/&lt;br /&gt;#menu li ul li{float:none;}&lt;br /&gt;/*position level 2 links vertically and hide*/ &lt;br /&gt;#menu li ul{display:none; position:absolute; z-index:1}&lt;br /&gt;/*unhide level 2 links on li:hover from level 1*/ &lt;br /&gt;#menu li:hover ul{display:block;}&lt;br /&gt;&lt;br /&gt;/*DROPDOWN STYLING:*/&lt;br /&gt;#menu{height:25px}&lt;br /&gt;#menu a{color:#09F; padding:5px 10px 5px 10px;}&lt;br /&gt;#menu a:hover{color:#0CF;}&lt;br /&gt;#menu li{background-color:#FFF; border:solid 1px #CCC;  margin-left:-1px}&lt;br /&gt;#menu li:hover{background-color:#F0F0F0}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;b&gt;3.&lt;/b&gt; Test it. Isn't that nice? Now change the links from step 1 and the /*DROPDOWN STYLING*/ section from step 2 until your menu looks as you'd like.&lt;br /&gt;&lt;br /&gt;&lt;i&gt;Tested in IE9, Chrome &amp;amp; Firefox but should work across all modern browsers.&lt;/i&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6207583460783647164-6106335024450409528?l=blog.crondesign.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.crondesign.com/2011/07/most-simplebasic-single-level-css.html</link><author>noreply@blogger.com (Ciarán O'Kelly)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-6207583460783647164.post-1796269076887416533</guid><pubDate>Sun, 17 Jul 2011 15:27:00 +0000</pubDate><atom:updated>2011-07-19T14:30:04.851+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>Actionscript</category><category domain='http://www.blogger.com/atom/ns#'>AS3</category><category domain='http://www.blogger.com/atom/ns#'>shortcuts</category><category domain='http://www.blogger.com/atom/ns#'>functions</category><title>AS3: Simple, Powerful String Find &amp; Replace all instances function for Flash Actionscript. Similar to PHP's str_replace replacement.</title><description>Exactly what it says on the tin!&lt;br /&gt;&lt;br /&gt;&lt;a href="http://blog.crondesign.com/2010/06/as2-simple-powerful-string-replace.html"&gt;AS2 version here&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="background-color: #fff2cc;"&gt;&lt;span class="Apple-style-span" style="color: #741b47;"&gt;Please see right hand pane before copying my code - thanks! &amp;gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class="actionscript"&gt;&lt;br /&gt;//needle and/or replacement can be either a string or an array of strings:&lt;br /&gt;function replace ( needle, replacement, haystack:String):String{&lt;br /&gt;   var r=haystack;&lt;br /&gt;   if(typeof(needle)=="string"){&lt;br /&gt;    needle = [needle]&lt;br /&gt;   }&lt;br /&gt;   if(typeof(replacement)=="string"){&lt;br /&gt;    replacement = [replacement]&lt;br /&gt;   }&lt;br /&gt;   while(replacement.length&amp;lt;needle.length){&lt;br /&gt;    replacement.push(replacement[replacement.length-1])&lt;br /&gt;   }&lt;br /&gt;   for(var i in needle){&lt;br /&gt;    r = r.split(needle[i]).join(replacement[i])&lt;br /&gt;   }&lt;br /&gt;   return(r)&lt;br /&gt;  }&lt;br /&gt;//SAMPLE USAGE:&lt;br /&gt;trace( replace( "A", "X", "ABCDEFG" ) )  //outputs: XBCDEF&lt;br /&gt;trace( replace(["A","B","C"] , ["X","Y","Z"], "ABCDEFG") )  //outputs: XYZDEF&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6207583460783647164-1796269076887416533?l=blog.crondesign.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.crondesign.com/2011/07/as3-simple-powerful-string-find-replace.html</link><author>noreply@blogger.com (Ciarán O'Kelly)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-6207583460783647164.post-7475775129245612747</guid><pubDate>Sun, 17 Jul 2011 14:39:00 +0000</pubDate><atom:updated>2011-07-17T15:39:55.440+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>Actionscript</category><category domain='http://www.blogger.com/atom/ns#'>AS3</category><category domain='http://www.blogger.com/atom/ns#'>functions</category><title>AS3: Wave of values class function - produces incremental and decremental values</title><description>Sometimes it's necessary to have a value increment until it gets to a certain point and then have it decrement again in a wave shape. A simple Math.sin() calculation will work in some cases but its not easy to control the increment using that method. This handy &amp;amp; simple class makes it quick and easy to do just this. There's lots of room for improvements &amp;amp; additions so feel free to post updates :)&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="background-color: #fff2cc; color: #741b47;"&gt;Please see right hand pane before copying my code- thanks! &amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class="actionscript"&gt;&lt;br /&gt;package com.cron {&lt;br /&gt; &lt;br /&gt; public class valueWave {&lt;br /&gt;  private var inc,startno,counter,max,min //counter is always&amp;gt;0&lt;br /&gt;  public var num //latest value&lt;br /&gt;  &lt;br /&gt;  public function valueWave($min:Number=0, $max:Number=10, $increment:Number=1, $startno:Number=0 ) {&lt;br /&gt;   if($max&amp;lt;$min){&lt;br /&gt;    trace("valueWave ERROR: max must be greater than min")&lt;br /&gt;    return&lt;br /&gt;   }&lt;br /&gt;   inc=$increment&lt;br /&gt;   startno=$startno&lt;br /&gt;   counter=$startno&lt;br /&gt;   num=$startno&lt;br /&gt;   max=$max&lt;br /&gt;   min=$min&lt;br /&gt;  }&lt;br /&gt;  &lt;br /&gt;  public function next(){&lt;br /&gt;   if(max==0){return(num);} //disable if max and min are the same&lt;br /&gt;   num = Math.abs((counter % (2*(max-min))) - (max-min)) + min;&lt;br /&gt;   counter += inc;&lt;br /&gt;   return(num)&lt;br /&gt;  }&lt;br /&gt;  &lt;br /&gt;  public function reset(){&lt;br /&gt;   counter=startno&lt;br /&gt;  }&lt;br /&gt;  &lt;br /&gt; }&lt;br /&gt; &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;//USAGE::&lt;br /&gt;//the code above should be saved as [your root class path]/com/cron/valueWave.as&lt;br /&gt;import com.cron.valueWave&lt;br /&gt;&lt;br /&gt;var W=new valueWave(1,10,1,5);&lt;br /&gt;&lt;br /&gt;addEventListener(Event.ENTER_FRAME,function(){&lt;br /&gt;    trace(W.next());&lt;br /&gt;})&lt;br /&gt;&lt;br /&gt;//OUTPUTS:&lt;br /&gt;5,4,3,2,1,2,3,4,5,6,7,8,9,10,9,8,7,6,5,etc&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6207583460783647164-7475775129245612747?l=blog.crondesign.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.crondesign.com/2011/07/as3-wave-of-values-class-function.html</link><author>noreply@blogger.com (Ciarán O'Kelly)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-6207583460783647164.post-8581150047619857341</guid><pubDate>Sun, 05 Jun 2011 19:02:00 +0000</pubDate><atom:updated>2011-06-05T20:08:48.359+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>Actionscript</category><category domain='http://www.blogger.com/atom/ns#'>AS3</category><category domain='http://www.blogger.com/atom/ns#'>shortcuts</category><category domain='http://www.blogger.com/atom/ns#'>functions</category><title>AS3 handy weighted random &amp; rounding functions with decimal/floating point precision</title><description>Like a lot of the "improvements" Adobe made to Actionscript with AS3, the Math.random() function is now a pain in the ass. It only generates a floating point number between 0 and 1 so 99% of the time, you need a few lines of code to get your random on.&lt;br /&gt;With time saving in mind, I've written this weighted random function which makes beautiful randomness a lot handier to implement. For best results throw this in a class package and include it in every project.&lt;br /&gt;Here it comes...&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="background-color: #fff2cc; color: purple;"&gt;Please see right hand pane before copying my code &amp;gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class="actionscript"&gt;&lt;br /&gt;function round(num:Number, precision:int):Number{&lt;br /&gt;   var decimal:Number = Math.pow(10, precision);&lt;br /&gt;   return Math.round(decimal* num) / decimal;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function rand(to:Number, from=0, decimalPlaces=0, weightedRange=0, weightStrength=0):Number{&lt;br /&gt;   var ret&lt;br /&gt;   if(to == from){return(to);}&lt;br /&gt; &lt;br /&gt;   if(weightedRange &amp;amp;&amp;amp; Math.random()&amp;lt;=weightStrength){&lt;br /&gt;      ret = round( Math.random()*(weightedRange[1]-weightedRange[0]) + weightedRange[0], decimalPlaces )&lt;br /&gt;   }else{&lt;br /&gt;      ret = round( Math.random()*(to-from)+from, decimalPlaces )&lt;br /&gt;   }&lt;br /&gt;   return(ret)&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;//USAGE:&lt;br /&gt;rand(100)                   //return random number 0-100 INCLUSIVE&lt;br /&gt;rand(10, -5)                //return random number between -5 and 10&lt;br /&gt;rand(10, -5, 2)             //return random number between -5.00 and 10.00&lt;br /&gt;rand(10, 6, 0, [0,5], 0.9)  //90% chance of returning number between 0-5, 10% chance of returning number between 6-10&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6207583460783647164-8581150047619857341?l=blog.crondesign.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.crondesign.com/2011/06/as3-handy-weighted-random-rounding.html</link><author>noreply@blogger.com (Ciarán O'Kelly)</author><thr:total>1</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-6207583460783647164.post-1668129904165025992</guid><pubDate>Sat, 23 Apr 2011 18:51:00 +0000</pubDate><atom:updated>2012-04-27T14:18:16.997+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>tips</category><title>SugarSync referral link - Better than dropbox</title><description>If you dont backup your computer already, try this... It automatically keeps your documents synced to the web in case your computer dies someday. Its better than dropbox because you can choose any folders on your computer to backup and you get more space. You can also share any backed up file with friends/clients with a simple right click. You get 5.5GB free with this referral link (I get an extra bonus too so everyone's a winner). For the less tech savvy of you: just install it and it will ask you what folders on your computer are important. After that you can forget about it until your computer dies.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="font-size: large;"&gt;Heres the link: &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: x-small;"&gt;(for 5.5GB free cloud storage)&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: large;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: large;"&gt;&amp;gt;&amp;gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;a href="https://www.sugarsync.com/referral?rf=bn8r6fwn2k9kr&amp;amp;utm_source=website&amp;amp;utm_medium=web&amp;amp;utm_campaign=referral&amp;amp;shareEvent=87295" style="font-size: x-large;"&gt;SugarSync referral&lt;/a&gt;&amp;nbsp;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6207583460783647164-1668129904165025992?l=blog.crondesign.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.crondesign.com/2011/04/sugarsync-referral-link-better-than.html</link><author>noreply@blogger.com (Ciarán O'Kelly)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-6207583460783647164.post-477373109996115901</guid><pubDate>Mon, 18 Apr 2011 11:39:00 +0000</pubDate><atom:updated>2011-04-18T13:11:38.897+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>Actionscript</category><category domain='http://www.blogger.com/atom/ns#'>AS3</category><category domain='http://www.blogger.com/atom/ns#'>functions</category><title>AS3 function to rotate a 2D or 3D MovieClip or Sprite around its center or change to any registration point</title><description>OK here we go - I looked everywhere for this one but only found bits of code from various forums and blogs that were part of classes and packages and as such, full of dependent variables. Anyway, after a bit of advice from the very helpful community at &lt;a href="http://stackoverflow.com/"&gt;StackOverflow&lt;/a&gt;&amp;nbsp;and a bit of tinkering,&amp;nbsp;she's up and running!&lt;br /&gt;&lt;br /&gt;The function below will rotate a DisplayObject around any point on a 2D or 3D plane. This is particularly useful for rotating around an object's center point so this is the default behaviour. Enjoy!&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="background-color: #fff2cc; color: purple;"&gt;Please see right hand pane before copying my code &amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class="actionscript"&gt;&lt;br /&gt;&lt;br /&gt;//ROTATE AN OBJECT AROUND A POINT OR ITS CENTER POINT:&lt;br /&gt;function rotObj(mc, angle, axis="Z", regX='center', regY=0, regZ=0) {&lt;br /&gt; mc.z=mc.z //workaround for matrix3D bug&lt;br /&gt; if (axis=="X") {&lt;br /&gt;  axis=Vector3D.X_AXIS;&lt;br /&gt; } else if (axis=="Y") {&lt;br /&gt;  axis=Vector3D.Y_AXIS;&lt;br /&gt; } else if (axis=="Z") {&lt;br /&gt;  axis=Vector3D.Z_AXIS;&lt;br /&gt; }&lt;br /&gt; if(regX=='center'){//get center point:&lt;br /&gt;  regX=mc.x+mc.width*1.5&lt;br /&gt;  regY=mc.y+mc.height*1.5&lt;br /&gt;  regZ=mc.z&lt;br /&gt; }&lt;br /&gt; mc.transform.matrix3D.appendTranslation(-regX,-regY,-regZ);&lt;br /&gt; mc.transform.matrix3D.appendRotation(angle, axis);&lt;br /&gt; mc.transform.matrix3D.appendTranslation(regX,regY,regZ);&lt;br /&gt;}&lt;br /&gt;//SAMPLE USE:&lt;br /&gt;rotObj(myMC, 45)  //rotates myMC 45 degrees around its center point&lt;br /&gt;rotObj(myMC, 45, "Y") //rotates myMC 45 degrees on Y axis around its center point&lt;br /&gt;rotObj(myMC, 45, "X", 200, 300) //rotates myMC 45 degrees on X axis around the point 200,300&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6207583460783647164-477373109996115901?l=blog.crondesign.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.crondesign.com/2011/04/as3-function-to-rotate-2d-or-3d.html</link><author>noreply@blogger.com (Ciarán O'Kelly)</author><thr:total>1</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-6207583460783647164.post-1501213527804256764</guid><pubDate>Mon, 14 Mar 2011 15:17:00 +0000</pubDate><atom:updated>2011-03-14T15:42:51.154Z</atom:updated><category domain='http://www.blogger.com/atom/ns#'>js</category><category domain='http://www.blogger.com/atom/ns#'>Javascript</category><category domain='http://www.blogger.com/atom/ns#'>Max</category><category domain='http://www.blogger.com/atom/ns#'>Max/MSP</category><category domain='http://www.blogger.com/atom/ns#'>functions</category><title>Max/MSP Javascript "find object" - lazy dollar function</title><description>&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;The second function in my&amp;nbsp;&lt;span class="Apple-style-span" style="line-height: 22px;"&gt;"&lt;/span&gt;&lt;span class="Apple-style-span" style="line-height: 22px;"&gt;&lt;i&gt;Making Max JS less crap&lt;/i&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="line-height: 22px;"&gt;" series, this function scans all objects in the patch and all subpatches and returns a reference to the object with the specified scripting name: It's basically a lazy man's version of my &lt;a href="http://blog.crondesign.com/2011/03/maxmsp-javascript-dollar-function.html"&gt;dollar function&lt;/a&gt; which means you dont need to give every patcher a scripting name. The downside is it (probably) runs a bit slower. Enjoy!&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #4c4c4c; font-family: Trebuchet, 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: 22px;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="background-color: #fff2cc; color: #4c1130; font-family: Trebuchet, 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: 22px;"&gt;Please see right hand pane before copying my code&amp;gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class="javascript"&gt;&lt;br /&gt;function _$(id){ //search through all max objects:&lt;br /&gt;    tempobj=0&lt;br /&gt;    tempname=id&lt;br /&gt;    this.patcher.applydeepif (_$act,_$scan);&lt;br /&gt;    delete tempname&lt;br /&gt;    return(tempobj)&lt;br /&gt;}&lt;br /&gt;function _$act(obj){&lt;br /&gt;    tempobj=obj&lt;br /&gt;}&lt;br /&gt;function _$scan(obj){&lt;br /&gt;    if(obj.varname==tempname){&lt;br /&gt;        return(true)&lt;br /&gt;    }else{&lt;br /&gt;        return(false)&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;//USAGE:&lt;br /&gt;_$("myButton").message('set','new text!') //find the first object anywhere in the project that has scripting name myButton and send it a message.&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6207583460783647164-1501213527804256764?l=blog.crondesign.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.crondesign.com/2011/03/maxmsp-javascript-find-object-dollar.html</link><author>noreply@blogger.com (Ciarán O'Kelly)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-6207583460783647164.post-5670525291203937759</guid><pubDate>Mon, 14 Mar 2011 14:54:00 +0000</pubDate><atom:updated>2011-03-15T15:46:22.196Z</atom:updated><category domain='http://www.blogger.com/atom/ns#'>js</category><category domain='http://www.blogger.com/atom/ns#'>Javascript</category><category domain='http://www.blogger.com/atom/ns#'>Max</category><category domain='http://www.blogger.com/atom/ns#'>Max/MSP</category><category domain='http://www.blogger.com/atom/ns#'>functions</category><title>Max/MSP Javascript: Dollar Function - Returns a reference to a Max Object in a patch/subpatch</title><description>I started using Max this month and was simultaneously impressed with its power and simplicity and frustrated by it's cumbersome interface. I quickly checked out it's javascript capabilities and became much more comfortable. JS allows you do simple operations quite quickly that would take a tonne of parsing objects which use up space and lead to a messy patch.&lt;br /&gt;&lt;br /&gt;That said, JS in Max is really a slightly ugly cousin of browser based javascript. Calls to objects are long winded and basically everything is a bit head wrecking!&lt;br /&gt;&lt;br /&gt;So here we go: the first in my "&lt;i&gt;Making Max JS less crap&lt;/i&gt;" series... The infamous dollar function! All you need to do to access a max object is give the object a scripting name in the inspector* and then use: $('scriptingname')&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="background-color: #fff2cc;"&gt;&lt;span class="Apple-style-span" style="color: #4c1130;"&gt;Please see right hand pane before copying my code&amp;gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class="javascript"&gt;&lt;br /&gt;function $(stringref){&lt;br /&gt;    stringref=stringref.replace(/parent/gi, "parentpatcher")&lt;br /&gt;    var path=stringref.split('.')&lt;br /&gt;    var obj=this.patcher&lt;br /&gt;    for(i in path){&lt;br /&gt;        if(path[i]=='parentpatcher'){ //up 1 level:&lt;br /&gt;            obj=obj.parentpatcher&lt;br /&gt;        }else{&lt;br /&gt;            obj=obj.getnamed(path[i])&lt;br /&gt;            if(i!=path.length-1){ //down 1 level:&lt;br /&gt;                obj=obj.subpatcher()&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;    return(obj)&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;//USAGE:&lt;br /&gt;$("myButton").message('set','new text!') //access 'myButton' object in current patcher&lt;br /&gt;$("parent.myButton").message('set','new text!') //access 'myButton' object in parent patcher&lt;br /&gt;$("myPatcher.myButton").message('set','new text!') //access 'myButton' object in child patcher&lt;br /&gt;$("parent.myPatcher.myButton").message('set','new text!') //access 'myButton' object in sibling patcher&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;* If you're not bothered giving every patcher a unique scripting name in the inspector, try my &lt;a href="http://blog.crondesign.com/2011/03/maxmsp-javascript-find-object-dollar.html"&gt;lazy dollar function&lt;/a&gt;&amp;nbsp;instead.&lt;br /&gt;&lt;br /&gt;UPDATE:&lt;br /&gt;A good way to use this function is to use &lt;a href="http://hallluke.wordpress.com/2010/10/31/including-extra-javascript-files/"&gt;Luke Hall's include script&lt;/a&gt;. Save his script into your jsexternals folder, save my functions into your project folder as basefunctions.js (or something similar) and then you can simply use &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;include(this,"basefunctions.js")&lt;/span&gt; at the top of every JS file you use. Thanks Luke - this is awesome!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6207583460783647164-5670525291203937759?l=blog.crondesign.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.crondesign.com/2011/03/maxmsp-javascript-dollar-function.html</link><author>noreply@blogger.com (Ciarán O'Kelly)</author><thr:total>2</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-6207583460783647164.post-6347585751777041300</guid><pubDate>Sun, 13 Feb 2011 22:19:00 +0000</pubDate><atom:updated>2011-02-13T22:20:53.465Z</atom:updated><category domain='http://www.blogger.com/atom/ns#'>Actionscript</category><category domain='http://www.blogger.com/atom/ns#'>AS3</category><category domain='http://www.blogger.com/atom/ns#'>functions</category><title>Actionscript 3: Better Random Function &amp; Better Rounding Function</title><description>I was amazed at how lame the rounding and random functions are in AS3 so I've written 2 simple functions to add much needed functionality. Enjoy...&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;pre&gt;&lt;code class="actionscript"&gt;&lt;br /&gt;//Returns a random number between from and to inclusive&lt;br /&gt;function randomNo(to:Number,from=0,decimalPlaces=0):Number{&lt;br /&gt; var ret=roundDecimal(Math.random()*(to-from)+from,decimalPlaces)&lt;br /&gt; return(ret)&lt;br /&gt;}&lt;br /&gt;function roundDecimal(num:Number, precision:int):Number{&lt;br /&gt; var decimal:Number = Math.pow(10, precision);&lt;br /&gt; return Math.round(decimal* num) / decimal;&lt;br /&gt;}&lt;br /&gt;randomNo(2) //returns 0, 1 or 2&lt;br /&gt;randomNo(20,18,2) //returns anything from 18.00 to 20.00&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6207583460783647164-6347585751777041300?l=blog.crondesign.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.crondesign.com/2011/02/actionscript-3-better-random-function.html</link><author>noreply@blogger.com (Ciarán O'Kelly)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-6207583460783647164.post-465624602578247794</guid><pubDate>Fri, 11 Feb 2011 16:45:00 +0000</pubDate><atom:updated>2011-02-11T16:45:02.256Z</atom:updated><category domain='http://www.blogger.com/atom/ns#'>js</category><category domain='http://www.blogger.com/atom/ns#'>Javascript</category><category domain='http://www.blogger.com/atom/ns#'>Actionscript</category><category domain='http://www.blogger.com/atom/ns#'>AS3</category><category domain='http://www.blogger.com/atom/ns#'>AS2</category><category domain='http://www.blogger.com/atom/ns#'>functions</category><title>Actionscript/Javascript Colour mode conversion functions - convert HSB/HSL/HSV to RGB to web HEX color or to flash matrix</title><description>I wrote/found/tweaked these conversion functions today to convert between the most common colour modes. it was very difficult to find a solid source for converting colours online so I thought I'd post them here for the world. They should work in actionscript 2 &amp;amp; 3 and could easily be tweaked to work in php, python or any other language. Here goes...&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="background-color: #fff2cc; color: purple;"&gt;&lt;i&gt;Please see the right hand pane to say thanks!&amp;nbsp;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class="acrionscript"&gt;&lt;br /&gt;function hex2rgb(hex:uint):Array{&lt;br /&gt; var rgb:Array = new Array();&lt;br /&gt; rgb[0] = hex &amp;gt;&amp;gt; 16;&lt;br /&gt; rgb[1]= hex &amp;gt;&amp;gt; 8 &amp;amp; 0xFF;&lt;br /&gt; rgb[2] = hex &amp;amp; 0xFF;&lt;br /&gt; return rgb;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function rgb2hex (rgb:Array):uint{&lt;br /&gt; var hex = rgb[0] &amp;lt;&amp;lt; 16 ^ rgb[1] &amp;lt;&amp;lt; 8 ^ rgb[2];&lt;br /&gt; return hex;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function hsb2rgb(hsb:Array):Array {&lt;br /&gt; var red, grn, blu, i, f, p, q, t;&lt;br /&gt; hsb[0]%=360;&lt;br /&gt; if(hsb[2]==0) {return(new Array(0,0,0));}&lt;br /&gt; hsb[1]/=100;&lt;br /&gt; hsb[2]/=100;&lt;br /&gt; hsb[0]/=60;&lt;br /&gt; i = Math.floor(hsb[0]);&lt;br /&gt; f = hsb[0]-i;&lt;br /&gt; p = hsb[2]*(1-hsb[1]);&lt;br /&gt; q = hsb[2]*(1-(hsb[1]*f));&lt;br /&gt; t = hsb[2]*(1-(hsb[1]*(1-f)));&lt;br /&gt; if (i==0) {red=hsb[2]; grn=t; blu=p;}&lt;br /&gt; else if (i==1) {red=q; grn=hsb[2]; blu=p;}&lt;br /&gt; else if (i==2) {red=p; grn=hsb[2]; blu=t;}&lt;br /&gt; else if (i==3) {red=p; grn=q; blu=hsb[2];}&lt;br /&gt; else if (i==4) {red=t; grn=p; blu=hsb[2];}&lt;br /&gt; else if (i==5) {red=hsb[2]; grn=p; blu=q;}&lt;br /&gt; red = Math.floor(red*255);&lt;br /&gt; grn = Math.floor(grn*255);&lt;br /&gt; blu = Math.floor(blu*255);&lt;br /&gt; return (new Array(red,grn,blu));&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function rgb2hsb(rgb:Array):Array {&lt;br /&gt; var x, f, i, hue, sat, val;&lt;br /&gt; rgb[0]/=255;&lt;br /&gt; rgb[1]/=255;&lt;br /&gt; rgb[2]/=255;&lt;br /&gt; x = Math.min(Math.min(rgb[0], rgb[1]), rgb[2]);&lt;br /&gt; val = Math.max(Math.max(rgb[0], rgb[1]), rgb[2]);&lt;br /&gt; if (x==val){&lt;br /&gt;  return(new Array(undefined,0,val*100));&lt;br /&gt; }&lt;br /&gt; f = (rgb[0] == x) ? rgb[1]-rgb[2] : ((rgb[1] == x) ? rgb[2]-rgb[0] : rgb[0]-rgb[1]);&lt;br /&gt; i = (rgb[0] == x) ? 3 : ((rgb[1] == x) ? 5 : 1);&lt;br /&gt; hue = Math.floor((i-f/(val-x))*60)%360;&lt;br /&gt; sat = Math.floor(((val-x)/val)*100);&lt;br /&gt; val = Math.floor(val*100);&lt;br /&gt; return(new Array(hue,sat,val));&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function hsb2hex(hsb:Array):uint{&lt;br /&gt; var rgb=hsb2rgb(hsb);&lt;br /&gt; return(rgb2hex(rgb));&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function hex2hsb(hex:uint):Array{&lt;br /&gt; var rgb=hex2rgb(hex);&lt;br /&gt; return(rgb2hsb(rgb));&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;//flash only function: I dont have an inverse for this. maybe someone could post one in the comments?&lt;br /&gt;function hex2matrix ( hex:uint, alpha:Number ){&lt;br /&gt; var matrix:Array = [];&lt;br /&gt; matrix = matrix.concat([((hex &amp;amp; 0x00FF0000) &amp;gt;&amp;gt;&amp;gt; 16)/255, 0, 0, 0, 0]);// red&lt;br /&gt; matrix = matrix.concat([0, ((hex &amp;amp; 0x0000FF00) &amp;gt;&amp;gt;&amp;gt; 8)/255, 0, 0, 0]); //green&lt;br /&gt; matrix = matrix.concat([0, 0, (hex &amp;amp; 0x000000FF)/255, 0, 0]); // blue&lt;br /&gt; matrix = matrix.concat([0, 0, 0, alpha/100, 0]); // alpha&lt;br /&gt; return matrix;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;//USAGE:&lt;br /&gt;trace('YELLOW HSB: 60,100,100 in hex mode is:'+hsb2hex([60,100,100])) //see note below *&lt;br /&gt;trace('YELLOW HEX: FFFF00 in HSB mode is:'+hex2hsb(0xFFFF00))&lt;/code&gt;&lt;/pre&gt;I should note for beginners that most functions return an array of values. To access the individual hue/sat/brightness or red/green/blue values, use array syntax like so: &lt;pre&gt;&lt;code class='actionscript'&gt;&lt;br /&gt;hsb=hex2hsb(0xFFFF00);&lt;br /&gt;hue=hsb[0];&lt;br /&gt;sat=hsb[1];&lt;br /&gt;val=hsb[2]&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;* I should also mention that flash converts hex values to numbers so hsb2hex([60,100,100]) will return 16776960 which is the same as 0xFFFF00 as far as flash is concerned.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6207583460783647164-465624602578247794?l=blog.crondesign.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.crondesign.com/2011/02/actionscriptjavascript-colour-mode.html</link><author>noreply@blogger.com (Ciarán O'Kelly)</author><thr:total>2</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-6207583460783647164.post-7062139094947827961</guid><pubDate>Mon, 23 Aug 2010 02:08:00 +0000</pubDate><atom:updated>2010-08-23T14:43:57.199+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>js</category><category domain='http://www.blogger.com/atom/ns#'>Javascript</category><category domain='http://www.blogger.com/atom/ns#'>functions</category><title>Javascript: Simple, Drag &amp; Drop element class - multiple draggable elements on one page.</title><description>&lt;span class="Apple-style-span" style="font-family: Arial; font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;I found a tonne of these drag &amp;amp; drop functions online but they were all either too big &amp;amp; bloated or relied heavily on external libraries. The one I did find that was small and usable triggers &lt;a href="http://code.google.com/p/chromium/issues/detail?id=7423"&gt;chrome bug 7423&lt;/a&gt;&amp;nbsp;because it captures the mousedown event for the page. So I've written my own and posted here for your convenience.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Arial; font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&lt;a href="http://www.crondesign.com/projects/demos/dragable.html"&gt;See Demo&lt;/a&gt;&amp;nbsp;(Internet Explorer ain't supported)&lt;/span&gt;&lt;/span&gt; &lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-family: Arial; font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;Tested in Firefox and Chrome. IE will take some tweaking&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;THE FILE:&lt;/span&gt;&lt;/b&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt; &lt;/span&gt;&lt;span class="Apple-style-span" style="color: #4c1130;"&gt;&lt;span class="Apple-style-span" style="background-color: #fff2cc;"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;(Please see right hand pane before download!)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;a href="http://www.crondesign.com/projects/downloads/dragable.js"&gt;http://www.crondesign.com/projects/downloads/dragable.js&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;IN HEAD:&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&amp;lt;script src="dragable.js" type="text/javascript"&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;ON PAGE LOAD OR AT FOOT OF PAGE:&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;lt;script type="text/javascript"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;makeDragable('myTitleBar','myPopup');&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;b&gt;myTitleBar &lt;/b&gt;should be replaced with the ID of the element you want the user to click&lt;br /&gt;&lt;b&gt;myPopup &lt;/b&gt;should be replaced with the ID of the element you want to move around&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"&gt;MULTIPLE DRAGABLE ELEMENTS ON ONE PAGE:&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;b&gt;&lt;/b&gt;&amp;lt;script type="text/javascript"&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;makeDragable(['myTitleBar1','myTitleBar2'], ['myPopup1','myPopup2']);&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6207583460783647164-7062139094947827961?l=blog.crondesign.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.crondesign.com/2010/08/javascript-simple-drag-drop-element_6224.html</link><author>noreply@blogger.com (Ciarán O'Kelly)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-6207583460783647164.post-3310103196980398619</guid><pubDate>Tue, 29 Jun 2010 16:30:00 +0000</pubDate><atom:updated>2011-07-17T16:28:30.295+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>Actionscript</category><category domain='http://www.blogger.com/atom/ns#'>AS2</category><category domain='http://www.blogger.com/atom/ns#'>functions</category><title>AS2: Simple, Powerful String Find &amp; Replace all instances function for Flash Actionscript. Similar to PHP's str_replace replacement.</title><description>Exactly what it says on the tin!&lt;br /&gt;&lt;br /&gt;&lt;a href="http://blog.crondesign.com/2011/07/as3-simple-powerful-string-find-replace.html"&gt;AS3 version here&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="background-color: #fff2cc; color: purple;"&gt;Please see right hand panel before copying&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class="actionscript"&gt;&lt;br /&gt;//needle and/or replacement can be either a string or an array of strings:&lt;br /&gt;_global.str_replace=function(needle, replacement, haystack:String) {&lt;br /&gt; var r=haystack;&lt;br /&gt; if(typeof(needle)=="string"){&lt;br /&gt;  needle=Array(needle)&lt;br /&gt; }&lt;br /&gt; if(typeof(replacement)=="string"){&lt;br /&gt;  replacement=Array(replacement)&lt;br /&gt;  &lt;br /&gt; }&lt;br /&gt; while(replacement.length&amp;lt;needle.length){&lt;br /&gt;  replacement.push(replacement[replacement.length-1])&lt;br /&gt; }&lt;br /&gt; for(var i in needle){&lt;br /&gt;  r=r.split(needle[i]).join(replacement[i])&lt;br /&gt; }&lt;br /&gt; return(r)&lt;br /&gt;}&lt;br /&gt;/*SAMPLE USAGE:&lt;br /&gt;trace( strreplace("A","X","ABCDEFG") )  //outputs: XBCDEF&lt;br /&gt;trace( strreplace(Array("A","B","C"),Array("X","Y","Z"),"ABCDEFG") )  //outputs: XYZDEF&lt;br /&gt;*/&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6207583460783647164-3310103196980398619?l=blog.crondesign.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.crondesign.com/2010/06/as2-simple-powerful-string-replace.html</link><author>noreply@blogger.com (Ciarán O'Kelly)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-6207583460783647164.post-4157887825301012363</guid><pubDate>Fri, 18 Jun 2010 03:02:00 +0000</pubDate><atom:updated>2010-06-18T04:27:00.703+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>Actionscript</category><category domain='http://www.blogger.com/atom/ns#'>AS2</category><category domain='http://www.blogger.com/atom/ns#'>functions</category><title>Resize a Movie Clip containing a mask by getting dimensions of visible bounds/area and compensating width/height</title><description>This was a head wrecker and took me most of the day today. Actionscript does not see Movie Clips as we do and considers invisible content to be part of the MC. As such, when you try to resize an MC that contains masked content which extends beyond what we consider to be the edges of the MovieClip, flash makes a balls of it.&lt;br /&gt;&lt;br /&gt;To counteract this I've written and rewritten a double function which resizes your clip based on the visible area rather than what flash considers the bounds. Here it comes...&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;pre&gt;&lt;code class="actionscript"&gt;&lt;br /&gt;//Returns width or height you need to use to resize an MC containing a mask.&lt;br /&gt;//include visibleOrigSize if you know it to cut down on processing power&lt;br /&gt;function maskCompensate(mc:MovieClip, prop:String, desiredSize:Number, visibleOrigSize:Number){&lt;br /&gt; var oX=mc._xscale;&lt;br /&gt; var oY=mc._yscale;&lt;br /&gt; mc._xscale=mc._yscale=100&lt;br /&gt; if(visibleOrigSize==undefined){&lt;br /&gt;  var visibleOrigSize=(prop=="_width" ? getVisibleBounds(mc).width : getVisibleBounds(mc).height)&lt;br /&gt; }&lt;br /&gt; var diff = mc[prop]-visibleOrigSize&lt;br /&gt; var percentIncrease = desiredSize/visibleOrigSize&lt;br /&gt; mc._xscale=oX&lt;br /&gt; mc._yscale=oY&lt;br /&gt; return(desiredSize+diff*percentIncrease)&lt;br /&gt;}&lt;br /&gt;import flash.display.BitmapData;&lt;br /&gt;function getVisibleBounds(mc){&lt;br /&gt; var myBitmapData:BitmapData = new BitmapData(mc._width,mc._height);&lt;br /&gt; myBitmapData.draw(mc);&lt;br /&gt; bounds = myBitmapData.getColorBoundsRect( 0xFFFFFFFF, 0xFFFFFFFF, false );&lt;br /&gt; bitmapData.dispose();&lt;br /&gt; return(bounds)&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;//sample usage:&lt;br /&gt;this._width = maskCompensate(this,"_width",500) &lt;br /&gt;this._height = maskCompensate(this,"_height",300) &lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6207583460783647164-4157887825301012363?l=blog.crondesign.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.crondesign.com/2010/06/resize-movie-clip-containing-mask-by.html</link><author>noreply@blogger.com (Ciarán O'Kelly)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-6207583460783647164.post-4749540344133322235</guid><pubDate>Thu, 13 May 2010 03:05:00 +0000</pubDate><atom:updated>2010-05-26T16:08:29.879+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>Regex</category><category domain='http://www.blogger.com/atom/ns#'>Apache</category><title>Universal ALL DOMAIN rewrite for non-www to canonical/www using htaccess or https.conf on apache server</title><description>&lt;br /&gt;This took me a few days to get right. The lack of feedback from testing, along with browser caching and the general head wrecking-ness of Regex make htaccess rewrites like this a total pain in the ass. Anyway thanks to the guys over at the alt.apache.configuration newsgroup, I've managed this:&lt;br /&gt;&lt;br /&gt;The code below will rewrite anything on your server that does not have a www. at the beginning to the same thing with a www. prefixed. Urls beginning with an IP address are left alone so that http://IPADDRESS/~username/ access still works.&lt;br /&gt;&lt;br /&gt;Subdomains are also redirected to their www. equivalent however they should still resolve and work normally. (untested)&lt;br /&gt;&lt;br /&gt;This is great if you run your own server and want to redirect everything at once or if you just want a template that you can use for all your websites&amp;nbsp;without&amp;nbsp;editing or altering.&lt;br /&gt;&lt;br /&gt;My code works without too much Regex with makes it a lot less memory intensive than most "universal" mod_rewrites out there.&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;The code below works on APACHE servers.&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #741b47;"&gt;&lt;span class="Apple-style-span" style="color: black;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The code can go in a file named &lt;b&gt;.htaccess&lt;/b&gt; (yes that's an empty filename with a dot htaccess extension) in the root directory of your website like so:&lt;br /&gt;&lt;span class="Apple-style-span" style="background-color: #fff2cc; color: #741b47;"&gt;&lt;i&gt;Please &lt;/i&gt;see right hand pane before copying &amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;RewriteEngine on&lt;br /&gt;RewriteCond %{HTTP_HOST} !^www\.&lt;br /&gt;RewriteCond %{HTTP_HOST} ![0-9]{1,3}\.[0-9]{1,3}\.&lt;br /&gt;RewriteRule !"" http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NC]&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;Or if you have access to &lt;b&gt;httpd.conf &lt;/b&gt;- the apache configuration file, the following will be much easier on the server.* Just add this at the bottom of /etc/httpd/conf/httpd.conf ** and restart.&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #741b47;"&gt;&lt;i&gt;&lt;span class="Apple-style-span" style="background-color: #fff2cc;"&gt;Please&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #741b47;"&gt;&lt;span class="Apple-style-span" style="background-color: #fff2cc;"&gt;see right hand pane before copying &amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&amp;lt;Directory /home/*&amp;gt;&lt;br /&gt;RewriteEngine on&lt;br /&gt;RewriteCond %{HTTP_HOST} !^www\.&lt;br /&gt;RewriteCond %{HTTP_HOST} ![0-9]{1,3}\.[0-9]{1,3}\.&lt;br /&gt;RewriteRule !"" http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NC]&lt;br /&gt;&amp;lt;/directory&amp;gt;&lt;/code&gt;&lt;/pre&gt;* The htaccess version is parsed every time the server is accessed while the httpd.conf version is parsed once when the server is started up.&lt;br /&gt;** These paths and instructions work on my VPS running Ubuntu. The paths might be different for other&amp;nbsp;distributions.&lt;br /&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6207583460783647164-4749540344133322235?l=blog.crondesign.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.crondesign.com/2010/05/universal-all-domain-rewrite-for-non.html</link><author>noreply@blogger.com (Ciarán O'Kelly)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-6207583460783647164.post-8416347083965110755</guid><pubDate>Thu, 06 May 2010 02:54:00 +0000</pubDate><atom:updated>2010-05-06T21:35:07.620+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>php</category><category domain='http://www.blogger.com/atom/ns#'>shortcuts</category><category domain='http://www.blogger.com/atom/ns#'>functions</category><title>PHP: Ultimate get/fetch RELATIVE PATH function between 2 folders/directories/files/pages or root dir</title><description>I wrote these functions today when everything I found online that attempted the same job was either too bulky, or too restrictive. It took me flippin ages - far longer than it should have! But it has huge functionality and will be a great addition to the arsenal.  The main function relpath basically calculates the relative path from anywhere to anywhere on the same domain. Possible uses are listed below: &lt;ol&gt;&lt;li&gt;Get relative path from the current page to the root directory of the  local domain (rootpath)...    &lt;pre&gt;&lt;code class="php"&gt;echo relpath(); //outputs ../../ or something similar&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;Get relative path from the current page to&amp;nbsp;any other file/folder on the domain...  &lt;pre&gt;&lt;code class="php"&gt;echo relpath("/scripts/javascripts/jsmin/min.js");&amp;nbsp;//outputs ../../jsmin/min.js&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;Get relative path from&amp;nbsp;any file/folder on the domain to&amp;nbsp;any other file/folder on the domain...  &lt;pre&gt;&lt;code class="php"&gt;echo relpath("/scripts/connect.php","/scripts/javascripts/jsmin");&amp;nbsp;//outputs ../../scripts.connect.php&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ol&gt;Full functions with details and comments below. &lt;br /&gt;&lt;div&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;URL Input Formats:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;To save as much coding time as possible, relpath is very sympathetic and will accept absolute or&amp;nbsp;relative&amp;nbsp;urls with or without query strings, trailing slashes, www subdomain or http protocall as in examples below:&lt;br /&gt;&amp;nbsp;&lt;/div&gt;&lt;ul style="font-style:italic"&gt;&lt;li&gt;http://www.website.com/scripts/javascripts/jsmin/min.js&lt;/li&gt;&lt;li&gt;http://website.com/scripts/javascripts/jsmin/&lt;/li&gt;&lt;li&gt;www.website.com/scripts/javascripts/jsmin&lt;/li&gt;&lt;li&gt;website.com/scripts/javascripts/jsmin&lt;/li&gt;&lt;li&gt;/scripts/javascripts/jsmin/min.js (relative path from root dir)&lt;/li&gt;&lt;li&gt;/scripts/javascripts/jsmin/min.js?p=compress&lt;/li&gt;&lt;li&gt;&lt;b style="font-style:normal"&gt;NOT:&lt;/b&gt;&amp;nbsp;scripts/javascripts/jsmin/min.js (needs beginning / )&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;The Functions:&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="background-color: #fff2cc;"&gt;&lt;span class="Apple-style-span" style="color: #741b47;"&gt;Please see right hand pane before copying! &amp;gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;pre&gt;&lt;code class="php"&gt;&lt;br /&gt;&lt;br /&gt;//RETURN RELATIVE PATH $from FILE/DIRECTORY TO $to FILE/DIRECTORY:&lt;br /&gt;//default returns relative path from current page to root directory&lt;br /&gt;function relpath($to=0,$from=0){&lt;br /&gt; $from=pathFromRoot($from,1);&lt;br /&gt; if($to){&lt;br /&gt;  $basename='/'.basename($to);&lt;br /&gt;  $to=pathFromRoot($to,1);&lt;br /&gt; }else{//return path to root dir:&lt;br /&gt;  return(str_repeat("../",count($from)));&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; //find point where paths branch by discarding mataching directories:&lt;br /&gt; for($i=0;$i&amp;lt; count($from);$i++){&lt;br /&gt;  if($from[$i]==$to[$i]){&lt;br /&gt;   unset($from[$i]);&lt;br /&gt;   unset($to[$i]);&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt; //compile result:&lt;br /&gt; $result=str_repeat("../",count($from)); //write relative path to the branching point&lt;br /&gt; $result.=implode('/',$to); //write path to target direcory&lt;br /&gt; return($result.$basename);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;//CONVERT A RELATIVE PATH TO AN ABSOLUTE PATH:&lt;br /&gt;function abspath($relPathFromRoot=0,$domain=0){&lt;br /&gt; if(!$relPathFromRoot){$relPathFromRoot=$_SERVER['PHP_SELF'];}//defaults to current page (calling script)&lt;br /&gt; if(!$domain){$domain=$_SERVER['HTTP_HOST'];}//defaults to current domain&lt;br /&gt; return "http://".$domain.str_replace(array('http://','www.',$domain),'',$relPathFromRoot);&lt;br /&gt;}&lt;br /&gt;//RETURN STRING URL OR ARRAY OF DIRECTORIES FROM ROOT: dir1/dir2/etc OR array("dir1", "dir2", etc);&lt;br /&gt;function pathFromRoot($tofile=0,$returnArray=0,$remote=0){&lt;br /&gt; $tofile=abspath($tofile);&lt;br /&gt; $path=trim(parseUrl($tofile,'path'),'/');&lt;br /&gt; return($returnArray ? explode('/',$path) : $path);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;//RETURNS ARRAY OF COMPONANT PARTS OF AN ABSOLUTE URL:&lt;br /&gt;function parseUrl($url,$returnKey=0) {&lt;br /&gt; $r  = "^(?:(?P&lt;scheme&gt;\w+)://)?";&lt;br /&gt; $r .= "(?:(?P&lt;login&gt;\w+):(?P&lt;pass&gt;\w+)@)?";&lt;br /&gt; $r .= "(?P&lt;host&gt;(?:(?P&lt;subdomain&gt;[-\w\.]+)\.)?" . "(?P&lt;domain&gt;[-\w]+\.(?P&lt;tld&gt;\w+)))";&lt;br /&gt; $r .= "(?::(?P&lt;port&gt;\d+))?";&lt;br /&gt; $r .= "(?P&lt;path&gt;[\w/]*/(?P&lt;file&gt;\w+(?:\.\w+)?)?)?";&lt;br /&gt; $r .= "(?:\?(?P&lt;arg&gt;[\w=&amp;]+))?";&lt;br /&gt; $r .= "(?:#(?P&lt;anchor&gt;\w+))?";&lt;br /&gt; $r = "!$r!";// Delimiters&lt;br /&gt; preg_match ( $r, $url, $out );&lt;br /&gt; $out['path']=str_replace($out['file'],'',$out['path']); //hack fix&lt;br /&gt;    return ($returnKey ? $out[$returnKey] : $out);&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div&gt;  &lt;p&gt;&lt;strong&gt;NOTES:&lt;/strong&gt;&lt;br /&gt;    This is for Unix servers but could be tweaked for Windows servers.&lt;br /&gt;  Functions could possibly could do with some performance improvements (I'm open to suggestions!)&lt;/p&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6207583460783647164-8416347083965110755?l=blog.crondesign.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.crondesign.com/2010/05/php-ultimate-getfetch-relative-path.html</link><author>noreply@blogger.com (Ciarán O'Kelly)</author><thr:total>1</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-6207583460783647164.post-8452082307405009401</guid><pubDate>Sun, 02 May 2010 16:46:00 +0000</pubDate><atom:updated>2010-05-02T18:08:22.999+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>php</category><category domain='http://www.blogger.com/atom/ns#'>shortcuts</category><title>PHP: Quick &amp; handy browser sniffer/checker function/class</title><description>Yes, you can check your visitor's browser using PHP! What's more, it never goes out of date! It automatically updates to recognise the lastest browsers. As much as I'd like to, I can't take credit for this one - it's the work of&amp;nbsp;&lt;a href="http://garetjax.info/projects/browscap/"&gt;Jonathan Stoppani&lt;/a&gt;&amp;nbsp;and makes browser sniffing with PHP an absolute breeze.&lt;br /&gt;&lt;br /&gt;This class (named Browscap) is a great alternative to PHP's native get_broswer function which requires manual regular updating of a browser.ini definitions file. Instead, Browscap intermittently imports the latest browser definitions from &lt;a href="http://browserproject.com/"&gt;browserproject.com&amp;nbsp;&lt;/a&gt;&amp;nbsp;so that your scripts are always up to speed with the latest browser information.&lt;br /&gt;Instructions and download below...&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;I've made a few edits to Jonathan's great class to make it a bit easier to implement. All you need to do is download the files below and add these two lines to your PHP script:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class="php"&gt;&lt;br /&gt;require("path/to/checkbroswer.php");&lt;br /&gt;$browserInfo=checkbrowser(); //returns array of info on the browser (print_r($browserInfo) to view)&lt;br /&gt;&lt;br /&gt;//alternatively, if you dont need all that array data:&lt;br /&gt;$browser=checkbrowser('Browser'); //returns Case sensitive browser name (Firefox,Chrome,IE,etc)&lt;br /&gt;$version=checkbrowser('Version'); //returns browser's version number (3.6, etc)&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;For details on what is returned in the array check out the&amp;nbsp;&lt;a href="http://code.google.com/p/phpbrowscap/wiki/QuickStart"&gt;Browscap website&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.crondesign.com/projects/downloads/checkbrowser.zip"&gt;» Download the modified Browscap file&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;NOTE: This is quite slow for one visitor every 10 days (which I can live with!) as it has to import the definitions file. Otherwise all data is cached and it should be nice and fast.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6207583460783647164-8452082307405009401?l=blog.crondesign.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.crondesign.com/2010/05/php-quick-handy-browser-snifferchecker.html</link><author>noreply@blogger.com (Ciarán O'Kelly)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-6207583460783647164.post-9082256402545583909</guid><pubDate>Sun, 02 May 2010 01:00:00 +0000</pubDate><atom:updated>2010-05-02T02:14:05.090+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>js</category><category domain='http://www.blogger.com/atom/ns#'>Javascript</category><category domain='http://www.blogger.com/atom/ns#'>usability</category><category domain='http://www.blogger.com/atom/ns#'>html</category><category domain='http://www.blogger.com/atom/ns#'>css</category><title>Javascript: Auto-Expand a form's select box on hover/mouseover</title><description>Productivity is all about cutting down mouse clicks. With this in mind, I've written this function to open/close a html dropdown menu on mouseover/out. It's currently more of an idea than a usable function, so it might need some testing &amp;amp; tweaking to work cross browser in a real web environment but the basic principal is here to get you started. &lt;br /&gt;&lt;a href="http://crondesign.com/projects/demos/selectbox.html" target='_blank'&gt;Try a demo »&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;b&gt;The Function:&lt;/b&gt; &lt;span class="Apple-style-span" style="background-color: #fff2cc;"&gt;&lt;span class="Apple-style-span" style="color: #741b47;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Please see right hand pane&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class="javascript"&gt;&lt;br /&gt;function toggleSelectBox(selbox){ &lt;br /&gt; if(selbox.size&amp;gt;1){//HIDE:&lt;br /&gt;  selbox.size=1;&lt;br /&gt;  selbox.style.position='static';&lt;br /&gt; }else{//SHOW:&lt;br /&gt;  selbox.size = selbox.options.length;&lt;br /&gt;  selbox.style.position='absolute';&lt;br /&gt;  selbox.style.height='auto';&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;pre&gt;&lt;code class="html"&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;select id="type" name="type" onmouseout="toggleSelectBox(this)" onmouseover="toggleSelectBox(this)"&amp;gt;&lt;br /&gt;&amp;lt;option value=""&amp;gt;opt1&amp;lt;/option&amp;gt;&lt;br /&gt;&amp;lt;option value=""&amp;gt;opt2&amp;lt;/option&amp;gt;&lt;br /&gt;&amp;lt;option value=""&amp;gt;opt3&amp;lt;/option&amp;gt;&lt;br /&gt;&amp;lt;/select&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6207583460783647164-9082256402545583909?l=blog.crondesign.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.crondesign.com/2010/05/javascript-auto-expand-forms-select-box.html</link><author>noreply@blogger.com (Ciarán O'Kelly)</author><thr:total>2</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-6207583460783647164.post-2744476156252192154</guid><pubDate>Wed, 28 Apr 2010 14:16:00 +0000</pubDate><atom:updated>2011-07-27T12:07:03.956+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>js</category><category domain='http://www.blogger.com/atom/ns#'>Javascript</category><category domain='http://www.blogger.com/atom/ns#'>shortcuts</category><title>Javascript: Set or get URL/URI/src/href of an iframe or frame/frameset function</title><description>This function simply targets an iframe or frameset and retrieves or changes it's src or href attribute.&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;Tested in FF 3.6 and Chrome (might need some tweaking for IE)&lt;br /&gt;&lt;br /&gt;&lt;b&gt;The Function:&lt;/b&gt; &lt;span class="Apple-style-span" style="color: #741b47;"&gt;&lt;span class="Apple-style-span" style="background-color: #fff2cc;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;(Please see right hand pane before copying my code - thank you! &amp;gt;&amp;gt;&amp;gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class="javascript"&gt;&lt;br /&gt;/*loads a url in the specified frame/iframe or returns the loaded url if url arg is blank&lt;br /&gt;frame  //DOM reference to a frame/iframe or string ID of an iframe in this document&lt;br /&gt;url  //url to href to. ignore or set=0 to return current url of page&lt;br /&gt;*/&lt;br /&gt;function framehref(frame,url){&lt;br /&gt; if(typeof(frame)=='string'){//find iframe (will not find a frame):&lt;br /&gt;  frame=document.getElementById(frame);&lt;br /&gt; }&lt;br /&gt; if(frame.tagName=='IFRAME'){//iframe:&lt;br /&gt;  if(url==undefined){ return( frame.contentWindow.document.location );}&lt;br /&gt;  frame.contentWindow.document.location.href=url;&lt;br /&gt; }else{//frame:&lt;br /&gt;  if(url==undefined){ return( frame.document.location );}&lt;br /&gt;  frame.document.location.href=url;&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;//sample usage:&lt;br /&gt;alert(framehref('myIframe')); //alerts the current location of the iframe &lt;br /&gt;framehref('myIframe',"http://www.google.com/"); //sends the iframe to google homepage&lt;br /&gt;framehref(top.right,"http://www.google.com/"); //sends the right hand frame (in a frameset) to google homepage&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6207583460783647164-2744476156252192154?l=blog.crondesign.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.crondesign.com/2010/04/javascript-easy-function-to-set-or-get.html</link><author>noreply@blogger.com (Ciarán O'Kelly)</author><thr:total>2</thr:total></item></channel></rss>
