<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: length code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Wed, 08 Oct 2008 06:38:50 GMT</pubDate>
    <description>DZone Snippets: length code</description>
    <item>
      <title>Sort file by length of lines</title>
      <link>http://snippets.dzone.com/posts/show/3280</link>
      <description>Sort file by length of lines&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;cat $@ | awk '{ print length, $0 }' | sort -n | awk '{$1=""; print $0}'&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sun, 14 Jan 2007 03:41:12 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3280</guid>
      <author>AlpT (AlpT)</author>
    </item>
    <item>
      <title>cmp-length - compare the length of two series and return -1, 0, or 1, to support stable sorts by length</title>
      <link>http://snippets.dzone.com/posts/show/2769</link>
      <description>&lt;code&gt;&lt;br /&gt;    ; Support func for stable sort comparator&lt;br /&gt;    cmp-length: func [a [series!] b [series!] /local len-a len-b] [&lt;br /&gt;        len-a: length? a&lt;br /&gt;        len-b: length? b&lt;br /&gt;        case [&lt;br /&gt;            len-a &lt; len-b [-1]&lt;br /&gt;            len-a &gt; len-b [1]&lt;br /&gt;            len-a = len-b [0]&lt;br /&gt;        ]&lt;br /&gt;    ]&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 02 Oct 2006 23:19:39 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2769</guid>
      <author>gregg.irwin (Gregg Irwin)</author>
    </item>
    <item>
      <title>one-item? - simple wrapper to aid readability</title>
      <link>http://snippets.dzone.com/posts/show/2053</link>
      <description>&lt;code&gt;&lt;br /&gt;one-item?: func [series] [1 = length? series]&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 17 May 2006 01:44:33 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2053</guid>
      <author>gregg.irwin (Gregg Irwin)</author>
    </item>
    <item>
      <title>Adjust Page Number when Page Length Changes</title>
      <link>http://snippets.dzone.com/posts/show/700</link>
      <description>In a web page you are display a certain page worth of results.  If you allow the user to change the page length, you'll need to find the new page number that contains the first item on the current page.  This is VB.Net code.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;intOldPageLength = GetPageLengthValue()&lt;br /&gt;&lt;br /&gt;' if there is a new page length value&lt;br /&gt;If intOldPageLength &lt;&gt; m_intPageLength Then&lt;br /&gt;&lt;br /&gt;   ' adjust the page number to compensate&lt;br /&gt;   intItemCount = ((m_intPage - 1) * intOldPageLength) + 1&lt;br /&gt;   m_intPage = intItemCount \ m_intPageLength&lt;br /&gt;   If intItemCount - (m_intPage * m_intPageLength) &gt; 0 Then&lt;br /&gt;      m_intPage = m_intPage + 1&lt;br /&gt;   End If&lt;br /&gt;&lt;br /&gt;End If&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;The index of the first item on the current page happens to be a count of the items up to that point.  So assume we are paging that amount and use the last page as our new current page.  We apply standard paging logic of items integer divided by page length to determine the number of pages and add one if there is a remainder.&lt;br /&gt;&lt;br /&gt;There are a couple formulas at work here worth noting.&lt;br /&gt;Index of Last Item on page:&lt;br /&gt;   page number * page length&lt;br /&gt;Index of First Item on page:&lt;br /&gt;   (index of last item of previous page) + 1&lt;br /&gt;   ((page number - 1) * page length) + 1&lt;br /&gt;Page Count based on page length:&lt;br /&gt;   number of items [integer divide] page length&lt;br /&gt;   if there is a remainder to the above then add 1</description>
      <pubDate>Tue, 13 Sep 2005 02:11:51 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/700</guid>
      <author>Will_Rickards (Will Rickards)</author>
    </item>
    <item>
      <title>Lenght between a dot and a line //JavaScript Function</title>
      <link>http://snippets.dzone.com/posts/show/674</link>
      <description>&lt;a href="http://jsfromhell.com/math/dot-line-length"&gt;&lt;br /&gt;Given a dot and a line, it returns the distance between them, the last parameter tells if the line should be considered infinite or if the function should respect its limits.&lt;br /&gt;&lt;br /&gt;[UPDATED CODE AND HELP CAN BE FOUND HERE]&lt;br /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;//+ Jonas Raoni Soares Silva&lt;br /&gt;//@ http://jsfromhell.com/math/dot-line-length [v1.0]&lt;br /&gt;&lt;br /&gt;dotLineLength = function( x, y, x0, y0, x1, y1, o ){&lt;br /&gt;	function lineLength( x, y, x0, y0 ){&lt;br /&gt;		return Math.sqrt( ( x -= x0 ) * x + ( y -= y0 ) * y );&lt;br /&gt;	}&lt;br /&gt;	if( o &amp;&amp; !( o = function( x, y, x0, y0, x1, y1 ){&lt;br /&gt;		if( !( x1 - x0 ) ) return { x: x0, y: y };&lt;br /&gt;		else if( !( y1 - y0 ) ) return { x: x, y: y0 };&lt;br /&gt;		var left, tg = -1 / ( ( y1 - y0 ) / ( x1 - x0 ) );&lt;br /&gt;		return { x: left = ( x1 * ( x * tg - y + y0 ) + x0 * ( x * - tg + y - y1 ) ) / ( tg * ( x1 - x0 ) + y0 - y1 ), y: tg * left - tg * x + y };&lt;br /&gt;	}( x, y, x0, y0, x1, y1 ), o.x &gt;= Math.min( x0, x1 ) &amp;&amp; o.x &lt;= Math.max( x0, x1 ) &amp;&amp; o.y &gt;= Math.min( y0, y1 ) &amp;&amp; o.y &lt;= Math.max( y0, y1 ) ) ){&lt;br /&gt;		var l1 = lineLength( x, y, x0, y0 ), l2 = lineLength( x, y, x1, y1 );&lt;br /&gt;		return l1 &gt; l2 ? l2 : l1;&lt;br /&gt;	}&lt;br /&gt;	else {&lt;br /&gt;		var a = y0 - y1, b = x1 - x0, c = x0 * y1 - y0 * x1;&lt;br /&gt;		return Math.abs( a * x + b * y + c ) / Math.sqrt( a * a + b * b );&lt;br /&gt;	}&lt;br /&gt;};&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 09 Sep 2005 05:01:25 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/674</guid>
      <author>jonasraoni (Jonas Raoni Soares Silva)</author>
    </item>
    <item>
      <title>Line Length //JavaScript Function</title>
      <link>http://snippets.dzone.com/posts/show/671</link>
      <description>&lt;a href="http://jsfromhell.com/math/line-length"&gt;&lt;br /&gt;Returns the length of a line.&lt;br /&gt;&lt;br /&gt;[UPDATED CODE AND HELP CAN BE FOUND HERE]&lt;br /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;//+ Jonas Raoni Soares Silva&lt;br /&gt;//@ http://jsfromhell.com/math/line-length [v1.0]&lt;br /&gt;&lt;br /&gt;lineLength = function( x, y, x0, y0 ){&lt;br /&gt;	return Math.sqrt( ( x -= x0 ) * x + ( y -= y0 ) * y );&lt;br /&gt;};&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 09 Sep 2005 04:48:58 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/671</guid>
      <author>jonasraoni (Jonas Raoni Soares Silva)</author>
    </item>
  </channel>
</rss>
