<?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>My Distributed Life &#187; JavaScript</title>
	<atom:link href="http://mydistributedlife.com/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://mydistributedlife.com</link>
	<description>Musings of a Geek/Husband/Father</description>
	<lastBuildDate>Thu, 30 Apr 2015 05:11:59 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.1.1</generator>
	<item>
		<title>File Size to String in JavaScript</title>
		<link>http://mydistributedlife.com/2012/03/file-size-to-string-in-javascript/</link>
		<comments>http://mydistributedlife.com/2012/03/file-size-to-string-in-javascript/#comments</comments>
		<pubDate>Fri, 23 Mar 2012 05:14:35 +0000</pubDate>
		<dc:creator><![CDATA[Garett]]></dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://mydistributedlife.com/?p=21</guid>
		<description><![CDATA[Recently, I needed to figure out a way to convert the size of a file, which is being returned in bytes, to a string representation.  So, given a file size in bytes like 349792 the string “342KB&#8221; would be returned.  Inspired by the following StackOverflow post, I came up with this JavaScript version. function fileSizeToString(size) ... <span class="more"><a class="more-link" href="http://mydistributedlife.com/2012/03/file-size-to-string-in-javascript/">[Read more...]</a></span>]]></description>
				<content:encoded><![CDATA[<p>Recently, I needed to figure out a way to convert the size of a file, which is being returned in bytes, to a string representation.  So, given a file size in bytes like 349792 the string “342KB&#8221; would be returned.  Inspired by the following <a href="http://stackoverflow.com/questions/281640/how-do-i-get-a-human-readable-file-size-using-net" target="_blank">StackOverflow post</a>, I came up with this JavaScript version.</p>
<pre class="brush: javascript auto-links: false;">function fileSizeToString(size) {
    var suffix = ["B", "KB", "MB", "GB"];

    var place = Math.floor(Math.log(size) / Math.log(1024));
    var fileSize = Math.round(size / Math.pow(1024, place));

    return (fileSize + suffix[place]);
};</pre>
<p>As you can see this is a relatively simple function, and really boils down to two lines of code. The first line</p>
<pre class="brush: javascript auto-links: false;">var place = Math.floor(Math.log(size) / Math.log(1024));</pre>
<p>determines which suffix will be used. While the second line</p>
<pre class="brush: javascript auto-links: false;">var fileSize = Math.round(size / Math.pow(1024, place));</pre>
<p>calculates the file size, which is typically <a href="http://en.wikipedia.org/wiki/File_size" target="_blank">measured</a> in units of 1024.</p>
<p>In my case I only needed to support up to gigabyte file sizes, but the function could easily be modified to support larger sizes.</p>
<p>Happy Coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://mydistributedlife.com/2012/03/file-size-to-string-in-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Internet Explorer Finally Supports SVG</title>
		<link>http://mydistributedlife.com/2010/03/internet-explorer-finally-supports-svg/</link>
		<comments>http://mydistributedlife.com/2010/03/internet-explorer-finally-supports-svg/#comments</comments>
		<pubDate>Mon, 29 Mar 2010 03:01:05 +0000</pubDate>
		<dc:creator><![CDATA[Garett]]></dc:creator>
				<category><![CDATA[SVG]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[VML]]></category>

		<guid isPermaLink="false">http://mydistributedlife.com/?p=18</guid>
		<description><![CDATA[I was reading the Internet Explorer 9 Platform Preview release notes, and was happy to see that SVG is listed among its supported features.&#160; It&#8217;s one of those features that have been dubiously missing from previous versions of the browser. This has forced many developers to opt for VML when rendering to Internet Explorer, which ... <span class="more"><a class="more-link" href="http://mydistributedlife.com/2010/03/internet-explorer-finally-supports-svg/">[Read more...]</a></span>]]></description>
				<content:encoded><![CDATA[<p>I was reading the Internet Explorer 9 Platform Preview <a href="http://ie.microsoft.com/testdrive/info/ReleaseNotes/Default.html">release notes</a>, and was happy to see that <a href="http://en.wikipedia.org/wiki/Svg">SVG</a> is listed among its supported features.&nbsp; It&#8217;s one of those features that have been dubiously missing from previous versions of the browser. This has forced many developers to opt for <a href="http://en.wikipedia.org/wiki/Vector_Markup_Language">VML</a> when rendering to Internet Explorer, which can be a pain as I recently found out while working on a project, because certain features always seem to be <a href="http://www.lrbabe.com/?p=104">broken</a> with each new release. While it will be years before we will only have to support SVG across all browsers, it&#8217;s still great to see that this will eventually be possible. However, from my experience with Microsoft technologies, I say that with a great deal of caution.</p>
]]></content:encoded>
			<wfw:commentRss>http://mydistributedlife.com/2010/03/internet-explorer-finally-supports-svg/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
