<?xml version='1.0' encoding='utf-8' ?>

<rss version='2.0' xmlns:lj='http://www.livejournal.org/rss/lj/1.0/' xmlns:atom10='http://www.w3.org/2005/Atom'>
<channel>
  <title>pvaneynd</title>
  <link>https://pvaneynd.dreamwidth.org/</link>
  <description>pvaneynd - Dreamwidth Studios</description>
  <lastBuildDate>Fri, 18 Apr 2014 12:41:36 GMT</lastBuildDate>
  <generator>LiveJournal / Dreamwidth Studios</generator>
  <lj:journal>pvaneynd</lj:journal>
  <lj:journaltype>personal</lj:journaltype>
  <image>
    <url>https://v2.dreamwidth.org/7693145/447974</url>
    <title>pvaneynd</title>
    <link>https://pvaneynd.dreamwidth.org/</link>
    <width>76</width>
    <height>100</height>
  </image>

<item>
  <guid isPermaLink='true'>https://pvaneynd.dreamwidth.org/152129.html</guid>
  <pubDate>Fri, 18 Apr 2014 12:41:36 GMT</pubDate>
  <title>Finding a new line in a file</title>
  <link>https://pvaneynd.dreamwidth.org/152129.html</link>
  <description>Today I helped a collegue who came with the question: &lt;i&gt;I have two files, how do I find which lines were added to one file, but not to the other?&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;He was thinking of a program to write. I&apos;m more a KISS person, why waste time writing a program when brute force will do &lt;i&gt;just fine&lt;/i&gt;.&lt;br /&gt;&lt;br /&gt;So:&lt;br /&gt;&lt;br /&gt;We have two files &lt;b&gt;a&lt;/b&gt; and &lt;b&gt;b&lt;/b&gt;:&lt;br /&gt;&lt;br /&gt;&lt;tt&gt;&lt;pre&gt;
pevaneyn@mac-book:/tmp :) $ cat a
1
2
3
4
5
pevaneyn@mac-book:/tmp :) $ cat b
1
2
3
4
5
7
8&lt;/pre&gt;&lt;/tt&gt;&lt;br /&gt;&lt;br /&gt;We want to see the lines in &lt;b&gt;b&lt;/b&gt; which are not in &lt;b&gt;a&lt;/b&gt;:&lt;br /&gt;&lt;br /&gt;&lt;tt&gt;&lt;pre&gt;pevaneyn@mac-book:/tmp :) $ cat a b | sort | uniq -u
7
8&lt;/pre&gt;&lt;/tt&gt;&lt;br /&gt;&lt;br /&gt;So we take the two files, sort then and then print the unique lines.&lt;br /&gt;&lt;br /&gt;But what if there are also unique lines in a which we don&apos;t need? So let&apos;s add a line to 0 which we do not want to see in the output:&lt;br /&gt;&lt;br /&gt;&lt;tt&gt;&lt;pre&gt;pevaneyn@mac-book:/tmp :) $ cat &amp;gt;&amp;gt; a
0
pevaneyn@Pmac-book:/tmp :) $ cat a b | sort | uniq -u
0
7
8&lt;/pre&gt;&lt;/tt&gt;&lt;br /&gt;&lt;br /&gt;How do we remove this 0?&lt;br /&gt;&lt;br /&gt;A trick is to include &lt;b&gt;a&lt;/b&gt; twice, then a line in a will never be unique:&lt;br /&gt;&lt;br /&gt;&lt;tt&gt;&lt;pre&gt;pevaneyn@mac-book:/tmp :) $ cat a a b | sort | uniq -u
7
8&lt;/pre&gt;&lt;/tt&gt;&lt;br /&gt;&lt;br /&gt;I used a similar method today to find which interface gave the CRC errors...&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=pvaneynd&amp;ditemid=152129&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://pvaneynd.dreamwidth.org/152129.html</comments>
  <category>life</category>
  <category>tricks</category>
  <category>work</category>
  <category>opensource</category>
  <lj:mood>happy</lj:mood>
  <lj:security>public</lj:security>
  <lj:reply-count>2</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://pvaneynd.dreamwidth.org/152036.html</guid>
  <pubDate>Mon, 07 Apr 2014 06:49:41 GMT</pubDate>
  <title>Old versus new</title>
  <link>https://pvaneynd.dreamwidth.org/152036.html</link>
  <description>For a side project at $WORK I need to plot some data.&lt;br /&gt;&lt;br /&gt;In the past I used &lt;a href=&quot;http://www.gnuplot.info/&quot;&gt;gnuplot&lt;/a&gt; but as I wanted to interactively investigate the data I wrote a GUI browser in &lt;a href=&quot;http://clojure.org/&quot;&gt;Clojure&lt;/a&gt;. This was relatively easy and fast enough.&lt;br /&gt;&lt;br /&gt;But I&apos;ve been told that I&apos;m not with the new hotness and that I should investigate doing this in the browser. So I found the pretty impressive &lt;a href=&quot;http://dygraphs.com/&quot;&gt;dygraphs&lt;/a&gt; javascript library.&lt;br /&gt;&lt;br /&gt;The plots look fantastic and are really what I need. So I make my first html5 like page and tried it.&lt;br /&gt;&lt;br /&gt;At first I thought that something was wrong. If I do this plot with gnuplot I get:&lt;br /&gt;&lt;br /&gt;&lt;tt&gt;&lt;pre&gt;$ time gnuplot plot.gnuplot

real	0m0.818s
user	0m0.608s
sys	0m0.209s&lt;/pre&gt;&lt;/tt&gt;&lt;br /&gt;&lt;br /&gt;In Safari it took &lt;b&gt;22 minutes&lt;/b&gt;, while showing a beachball all the time, to plot this data. Chrome and Firefox do it quite a bit better at only two minutes, but still... not subsecond is it? Using the &apos;canvas&apos; html5 terminal in gnuplot produces 14M html file which only takes something lik 20 seconds to get drawn in all browsers.&lt;br /&gt;&lt;br /&gt;But I must admit that the default look and interactivity of dygraph is lightyears ahead of my gnuplot settings...&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=pvaneynd&amp;ditemid=152036&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://pvaneynd.dreamwidth.org/152036.html</comments>
  <category>work</category>
  <category>opensource</category>
  <category>gnuplot</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
</channel>
</rss>
