<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:gd="http://schemas.google.com/g/2005" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;CEEHRHc6fSp7ImA9WhRWEUs.&quot;"><id>tag:blogger.com,1999:blog-2574712085639993348</id><updated>2011-12-29T13:43:55.915+01:00</updated><category term="Random" /><category term="mmap" /><category term="streambuf" /><category term="Project management" /><category term="Cs-137" /><category term="SQL" /><category term="Safeguards" /><category term="NTP" /><category term="BWR" /><category term="locale" /><category term="risk" /><category term="assembly" /><category term="binary" /><category term="Quality" /><category term="C++" /><category term="nuclear" /><category term="peak-search" /><category term="reactor" /><category term="Intrusion" /><category term="timestamp" /><category term="Video" /><category term="Crypto" /><category term="Be-7" /><category term="Radioactivity" /><category term="Ubuntu-9.04" /><category term="Reviews" /><category term="IPv6" /><category term="snippets" /><category term="Executables" /><category term="Asio" /><category term="SSH" /><category term="Fukushima" /><category term="security" /><category term="Programming Challenges" /><category term="tip" /><category term="PHP" /><category term="editor" /><category term="spectroscopy" /><category term="BOUML" /><category term="posix_time" /><category term="PostgreSQL" /><category term="Ping" /><category term="Agile" /><category term="libssh2" /><category term="Am-241" /><category term="Scrum" /><category term="Fission" /><category term="Databases" /><category term="Boost" /><category term="boyscout" /><category term="Accident" /><title>Jansson Consulting</title><subtitle type="html">Nuclear consultancy and computer wizardry at your disposal.</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://blog.p-jansson.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://blog.p-jansson.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><author><name>Peter Jansson</name><uri>http://www.blogger.com/profile/02543155564076384235</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_icY8aPexjCA/Sp63XsM3SLI/AAAAAAAAANI/VcVhqbw706A/s1600-R/AIbEiAIAAABECOP5xtyUoozZhwEiC3ZjYXJkX3Bob3RvKihhMWUwZmY4MTQzM2JhYjcxMmQ5OWYzMTY0N2YyZjk1MTExOGNhMzczMAFvd8hrPIJ5oYco5_oUBeY2wGftgA" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>50</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/JanssonConsulting" /><feedburner:info uri="janssonconsulting" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry gd:etag="W/&quot;A0IMRXo_eip7ImA9WhRWEUg.&quot;"><id>tag:blogger.com,1999:blog-2574712085639993348.post-8941392794454134430</id><published>2011-11-21T09:27:00.000+01:00</published><updated>2011-12-29T12:53:04.442+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-29T12:53:04.442+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="snippets" /><category scheme="http://www.blogger.com/atom/ns#" term="C++" /><title>A trivial character search and replace method in C++</title><content type="html">A very long time ago I was searching for ways to replace individual characters in a string and some of the methods was summarized in a small test program. I found that test program in an old folder on my computer which I almost forgot. So, I share that little code with the world. It follows.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="prettyprint"&gt;#include &amp;lt;algorithm&amp;gt;
#include &amp;lt;string&amp;gt;
#include &amp;lt;iostream&amp;gt;

using namespace std;

bool is_punct( const char&amp;amp; c )
{
 return ispunct( c );
}

bool is_l( const char&amp;amp; c )
{
 return 'l'==c;
}

struct mycomp
{
 bool operator()(const char&amp;amp; o)
 {
  return ispunct( o );
 }
};

int main()
{
 // Remove all characters that "ispunct" using a function.
 string s = "hello, world!";
 s.erase( remove_if( s.begin(), s.end(), &amp;amp;is_punct ), s.end() );
 cout &amp;lt;&amp;lt; s &amp;lt;&amp;lt; '\n';

 // Remove all characters that "ispunct" using a functor.
 s = "hello, world!";
 s.erase( remove_if( s.begin(), s.end(), mycomp() ), s.end() );
 cout &amp;lt;&amp;lt; s &amp;lt;&amp;lt; '\n';

 // Replace all 'l' with 'L' using a function.
 s = "hello, world!";
 replace_if( s.begin(), s.end(), &amp;amp;is_l, 'L' );
 cout &amp;lt;&amp;lt; s &amp;lt;&amp;lt; '\n';
}
&lt;/pre&gt;&lt;br /&gt;
&lt;style type="text/css"&gt;
@import url("http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.css");
pre.prettyprint { background: rgb(220,220,220);
&lt;/style&gt;&lt;br /&gt;
&lt;script src="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js" type="text/javascript"&gt;&lt;/script&gt;&lt;br /&gt;
&lt;script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"&gt;&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"&gt;$(document).ready(function(){prettyPrint();});&lt;/script&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2574712085639993348-8941392794454134430?l=blog.p-jansson.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/8nL-hxWxXii9z_ANNFdqRx3w3RQ/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/8nL-hxWxXii9z_ANNFdqRx3w3RQ/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/8nL-hxWxXii9z_ANNFdqRx3w3RQ/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/8nL-hxWxXii9z_ANNFdqRx3w3RQ/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JanssonConsulting/~4/Ms0sfB3lKnQ" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.p-jansson.com/feeds/8941392794454134430/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.p-jansson.com/2011/11/trivial-character-search-and-replace.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/8941392794454134430?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/8941392794454134430?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/JanssonConsulting/~3/Ms0sfB3lKnQ/trivial-character-search-and-replace.html" title="A trivial character search and replace method in C++" /><author><name>Peter Jansson</name><uri>http://www.blogger.com/profile/02543155564076384235</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_icY8aPexjCA/Sp63XsM3SLI/AAAAAAAAANI/VcVhqbw706A/s1600-R/AIbEiAIAAABECOP5xtyUoozZhwEiC3ZjYXJkX3Bob3RvKihhMWUwZmY4MTQzM2JhYjcxMmQ5OWYzMTY0N2YyZjk1MTExOGNhMzczMAFvd8hrPIJ5oYco5_oUBeY2wGftgA" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.p-jansson.com/2011/11/trivial-character-search-and-replace.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0ADR3s5fip7ImA9WhRWEUg.&quot;"><id>tag:blogger.com,1999:blog-2574712085639993348.post-4310593414493626257</id><published>2011-11-16T15:02:00.002+01:00</published><updated>2011-12-29T12:56:16.526+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-29T12:56:16.526+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="snippets" /><category scheme="http://www.blogger.com/atom/ns#" term="SQL" /><title>Creating a histogram in SQL using event data</title><content type="html">&lt;p&gt;Sometimes you may have gathered some data on event-by-event basis. For instance, the data may look like this when pulses from a radioactive decay have been processed by a peak sensing analog to digital converter (ADC): &lt;/p&gt;&lt;pre class="prettyprint"&gt;2
2
2
8
8
8
8
8
8
8
8
8
100
100
250
250
&lt;/pre&gt;&lt;p&gt;A simple table in a relational database may be created to store this data: &lt;/p&gt;&lt;pre class="prettyprint"&gt;CREATE TABLE samples( channel INTEGER NOT NULL );

BEGIN TRANSACTION;
INSERT INTO samples VALUES(2);
INSERT INTO samples VALUES(2);
INSERT INTO samples VALUES(2);
INSERT INTO samples VALUES(8);
INSERT INTO samples VALUES(8);
INSERT INTO samples VALUES(8);
INSERT INTO samples VALUES(8);
INSERT INTO samples VALUES(8);
INSERT INTO samples VALUES(8);
INSERT INTO samples VALUES(8);
INSERT INTO samples VALUES(8);
INSERT INTO samples VALUES(8);
INSERT INTO samples VALUES(100);
INSERT INTO samples VALUES(100);
INSERT INTO samples VALUES(250);
INSERT INTO samples VALUES(250);
COMMIT;
&lt;/pre&gt;&lt;p&gt;I found the following SQL statement somewhere on the net (if you find it, please let me know where so that I can pay the appropriate tribute to its source). It is a demonstration of how to create a 1024 channel histogram with the above data. I hope you find it useful. &lt;/p&gt;&lt;pre class="prettyprint"&gt;SELECT bin, COUNT(1) AS cnt
FROM (SELECT CAST((channel-mn) / (1.0*range/1024) AS INTEGER) + 1 AS bin
      FROM (SELECT MIN(channel) AS mn, MAX(channel)-MIN(channel)+1 AS range
            FROM samples) AS R
         CROSS JOIN
           (SELECT * FROM samples) AS S) AS RS
GROUP BY bin;
&lt;/pre&gt;&lt;p&gt;Using &lt;a href="http://www.sqlite.org" target="_blank"&gt;SQLite&lt;/a&gt; as database engine, I get the following output after executing the above SQL statements. &lt;/p&gt;&lt;pre class="prettyprint"&gt;1|3
25|9
404|2
1020|2
&lt;/pre&gt;&lt;br /&gt;
&lt;style type="text/css"&gt;
@import url("http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.css");
pre.prettyprint { background: rgb(220,220,220);
&lt;/style&gt;&lt;br /&gt;
&lt;script src="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js" type="text/javascript"&gt;&lt;/script&gt;&lt;br /&gt;
&lt;script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"&gt;&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"&gt;$(document).ready(function(){prettyPrint();});&lt;/script&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2574712085639993348-4310593414493626257?l=blog.p-jansson.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/kBm-KIF7oIY4Wx09Iph1nIyghi4/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/kBm-KIF7oIY4Wx09Iph1nIyghi4/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/kBm-KIF7oIY4Wx09Iph1nIyghi4/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/kBm-KIF7oIY4Wx09Iph1nIyghi4/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JanssonConsulting/~4/vmJ45-AmshE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.p-jansson.com/feeds/4310593414493626257/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.p-jansson.com/2011/11/creating-histogram-in-sql-using-event.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/4310593414493626257?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/4310593414493626257?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/JanssonConsulting/~3/vmJ45-AmshE/creating-histogram-in-sql-using-event.html" title="Creating a histogram in SQL using event data" /><author><name>Peter Jansson</name><uri>http://www.blogger.com/profile/02543155564076384235</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_icY8aPexjCA/Sp63XsM3SLI/AAAAAAAAANI/VcVhqbw706A/s1600-R/AIbEiAIAAABECOP5xtyUoozZhwEiC3ZjYXJkX3Bob3RvKihhMWUwZmY4MTQzM2JhYjcxMmQ5OWYzMTY0N2YyZjk1MTExOGNhMzczMAFvd8hrPIJ5oYco5_oUBeY2wGftgA" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.p-jansson.com/2011/11/creating-histogram-in-sql-using-event.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CE8BRHoyfSp7ImA9WhdRFEo.&quot;"><id>tag:blogger.com,1999:blog-2574712085639993348.post-5436015841508593939</id><published>2011-08-02T11:54:00.002+02:00</published><updated>2011-08-04T17:47:35.495+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-08-04T17:47:35.495+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="reactor" /><category scheme="http://www.blogger.com/atom/ns#" term="boyscout" /><category scheme="http://www.blogger.com/atom/ns#" term="nuclear" /><category scheme="http://www.blogger.com/atom/ns#" term="Am-241" /><title>Swedens first Radioactive Boyscout? Or, how to boil water with smoke detectors.</title><content type="html">&lt;p&gt;
On August 1, 2011, in Swedish on-line news paper Helsingborgs Dagblad, a &lt;a href="http://hd.se/angelholm/2011/08/01/forsokte-bygga-karnreaktor-i/" target="_blank"&gt;story was told&lt;/a&gt; about a 31 year old man who tried to build his own nuclear reactor using Americium-241 from smoke detectors and other chemicals. The story reminds us of the story from the 1990's about the &lt;a href="http://en.wikipedia.org/wiki/David_Hahn" target="_blank"&gt;"Radioactive Boyscout", David Hahn&lt;/a&gt;. There is &lt;a href="http://hd.se/angelholm/2011/08/02/behover-ganska-mycket-uran/" target="_blank"&gt;another story&lt;/a&gt; from the same source with an interview with Professor Janne Wallenius, Royal Institute of Technology in Sweden, who tries to explain the impossibility of the mans endeavour.
&lt;/p&gt;
&lt;p&gt;
I would like to present to you a small exercise in physics and show the impossibility from another perspective. A nuclear reactors fundamental purpose is to heat water. Most of the time that heated water is used to generate momentum in a turbine which generate electricity so that you can read this blog post. Sometimes that heated water is used as a direct source of heat. But, how many smoke detectors would we need to boil a bucket of water?
&lt;/p&gt;
&lt;strong&gt;Energy needed to boil water&lt;/strong&gt;
&lt;p&gt;
Let us start with a bucket of 1 dm&lt;sup&gt;3&lt;/sup&gt; of water (i.e. one liter) at 25&amp;deg; Centigrade at normal atmospheric pressure. In order to make it boil we need to raise its temperature with 75 degrees to 100&amp;deg;.
&lt;/p&gt;
&lt;p&gt;
Using measurements &lt;a href="http://en.wikipedia.org/wiki/Heat_capacity" target="_blank"&gt;performed by others&lt;/a&gt;, we know that the specific heat capacity of water at 25&amp;deg; is about 4.2 Joule per Gram per Kelvin. That is, it takes 4.2 Joules of energy to heat one gram of water one degree.
&lt;/p&gt;
&lt;p&gt;
To heat one liter (i.e. 1000 grams) of water 75 degrees from room temperature would take about
&lt;/p&gt;
&lt;pre&gt;
4.2 (J/g/K) * 75 (K) * 1000 (g) &amp;asymp; 315 kJ
&lt;/pre&gt;
&lt;p&gt;
So, using smoke detectors, we need to somehow transfer 315 kJ of energy into our bucket of water.
&lt;/p&gt;
&lt;strong&gt;Energy from smoke detectors&lt;/strong&gt;
&lt;p&gt;
An &lt;a href="http://en.wikipedia.org/wiki/Americium" target="_blank"&gt;ordinary smoke detector&lt;/a&gt; contain about 1 &amp;micro;Ci or 37 kBq of &lt;sup&gt;241&lt;/sup&gt;Am. This unit means that we get about 37000 decays of &lt;sup&gt;241&lt;/sup&gt;Am per second.
From one decay of &lt;sup&gt;241&lt;/sup&gt;Am we get about 5.5 MeV of energy. This is the same as about
&lt;/p&gt;
&lt;pre&gt;
5.5 (MeV) * 1.602&amp;sdot;10&lt;sup&gt;−13&lt;/sup&gt; (J/MeV) &amp;asymp; 8.8&amp;sdot;10&lt;sup&gt;−13&lt;/sup&gt; Joule
&lt;/pre&gt;
&lt;p&gt;
So an ordinary smoke detector generates about
&lt;/p&gt;
&lt;pre&gt;
8.8&amp;sdot;10&lt;sup&gt;−13&lt;/sup&gt; (J) * 37&amp;sdot;10&lt;sup&gt;3&lt;/sup&gt; (1/s) &amp;asymp; 325&amp;sdot;10&lt;sup&gt;−10&lt;/sup&gt; Watt
&lt;/pre&gt;
&lt;strong&gt;Conclusion: Boiling water with smoke detectors&lt;/strong&gt;
&lt;p&gt;
Lets say we have patience. We can wait one year for our bucket of water to boil. One year is about 315360000 seconds. So, we have this many seconds to generate 315 kJ. To do this we need
&lt;/p&gt;
&lt;pre&gt;
315 (kJ) / 315360000 (s) &amp;asymp; 0.001 Watt
&lt;/pre&gt;
&lt;p&gt;
Each smoke detector gives 325&amp;sdot;10&lt;sup&gt;−10&lt;/sup&gt; Watt so we need the following number of smoke detectors:
&lt;/p&gt;
&lt;pre&gt;
0.001 (W) / 325&amp;sdot;10&lt;sup&gt;−10&lt;/sup&gt; (Watt/detector) &amp;asymp; 30&amp;sdot;10&lt;sup&gt;3&lt;/sup&gt;
&lt;/pre&gt;
&lt;p&gt;
I.e. we would need some 30000 smoke detectors to boil our bucket of water if we can wait one year for it to boil. We could not drive a turbine with this.
&lt;/p&gt;
&lt;p&gt;
Say we were in a situation were we need to boil water quickly. For instance if we were lost in the forest and need to get a hot cup of tea made from the sprouts of spruce. Then we only have about one hour and we would need 24*365 times the number of smoke detectors, or about 250 millions. 
&lt;/p&gt;
&lt;p&gt;
Clearly, it is impossible to boil water with smoke detectors. You can't find 250 million smoke detectors laying around in the woods.
&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2574712085639993348-5436015841508593939?l=blog.p-jansson.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/DWWRwjQl3C96RqK5nj92c7sMOtM/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/DWWRwjQl3C96RqK5nj92c7sMOtM/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/DWWRwjQl3C96RqK5nj92c7sMOtM/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/DWWRwjQl3C96RqK5nj92c7sMOtM/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JanssonConsulting/~4/iGsu7Ji_JTY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.p-jansson.com/feeds/5436015841508593939/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.p-jansson.com/2011/08/swedens-first-radioative-boyscout-or.html#comment-form" title="4 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/5436015841508593939?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/5436015841508593939?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/JanssonConsulting/~3/iGsu7Ji_JTY/swedens-first-radioative-boyscout-or.html" title="Swedens first Radioactive Boyscout? Or, how to boil water with smoke detectors." /><author><name>Peter Jansson</name><uri>http://www.blogger.com/profile/02543155564076384235</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_icY8aPexjCA/Sp63XsM3SLI/AAAAAAAAANI/VcVhqbw706A/s1600-R/AIbEiAIAAABECOP5xtyUoozZhwEiC3ZjYXJkX3Bob3RvKihhMWUwZmY4MTQzM2JhYjcxMmQ5OWYzMTY0N2YyZjk1MTExOGNhMzczMAFvd8hrPIJ5oYco5_oUBeY2wGftgA" /></author><thr:total>4</thr:total><feedburner:origLink>http://blog.p-jansson.com/2011/08/swedens-first-radioative-boyscout-or.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A08FQnk_eSp7ImA9WhRWEUg.&quot;"><id>tag:blogger.com,1999:blog-2574712085639993348.post-2144811561896445520</id><published>2011-07-31T11:09:00.001+02:00</published><updated>2011-12-29T12:56:53.741+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-29T12:56:53.741+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Boost" /><category scheme="http://www.blogger.com/atom/ns#" term="timestamp" /><category scheme="http://www.blogger.com/atom/ns#" term="snippets" /><category scheme="http://www.blogger.com/atom/ns#" term="posix_time" /><category scheme="http://www.blogger.com/atom/ns#" term="C++" /><title>Convert a boost::posix_time::ptime to a std::time_t value</title><content type="html">&lt;p&gt;Often you need a std::time_t value or a UNIX timestamp which is the number of seconds elapsed since January 1&lt;sup&gt;st&lt;/sup&gt; 1970 but what you start with is a boost::posix_time::ptime (from the &lt;a href="http://www.boost.org" target="_blank"&gt;Boost C++ library&lt;/a&gt;). Here is how you can convert it: &lt;/p&gt;&lt;pre class="prettyprint"&gt;#include "ctime"
#include "boost/date_time/posix_time/posix_time_types.hpp"
std::time_t convert(const boost::posix_time::ptime&amp; t)
{
   static const boost::posix_time::ptime epoch(
         boost::gregorian::date(1970,1,1) );
   const boost::posix_time::time_duration::sec_type x(
         (t - epoch).total_seconds() );
   return x;
}
&lt;/pre&gt;&lt;p&gt;Here is a small test program that illustrates it's use by converting the current UTC time: &lt;/p&gt;&lt;pre class="prettyprint"&gt;#include "ctime"
#include "boost/date_time/posix_time/posix_time_types.hpp"
std::time_t convert(const boost::posix_time::ptime&amp; t)
{
   static const boost::posix_time::ptime epoch(
         boost::gregorian::date(1970,1,1) );
   const boost::posix_time::time_duration::sec_type x(
         (t - epoch).total_seconds() );
   return x;
}
#include "iostream"
int main()
{
   const boost::posix_time::ptime t(
         boost::posix_time::second_clock::universal_time() );
   std::cout &amp;lt;&amp;lt; convert(t) &amp;lt;&amp;lt; std::endl;
   return 0;
}
&lt;/pre&gt;&lt;br /&gt;
&lt;style type="text/css"&gt;
@import url("http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.css");
pre.prettyprint { background: rgb(220,220,220);
&lt;/style&gt;&lt;br /&gt;
&lt;script src="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js" type="text/javascript"&gt;&lt;/script&gt;&lt;br /&gt;
&lt;script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"&gt;&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"&gt;$(document).ready(function(){prettyPrint();});&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2574712085639993348-2144811561896445520?l=blog.p-jansson.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/fNlxXU7sSq4WkJZDo1ndau-xiZw/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/fNlxXU7sSq4WkJZDo1ndau-xiZw/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/fNlxXU7sSq4WkJZDo1ndau-xiZw/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/fNlxXU7sSq4WkJZDo1ndau-xiZw/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JanssonConsulting/~4/F-UoZ6vZRVg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.p-jansson.com/feeds/2144811561896445520/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.p-jansson.com/2011/07/convert-boostposixtimeptime-to-stdtimet.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/2144811561896445520?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/2144811561896445520?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/JanssonConsulting/~3/F-UoZ6vZRVg/convert-boostposixtimeptime-to-stdtimet.html" title="Convert a boost::posix_time::ptime to a std::time_t value" /><author><name>Peter Jansson</name><uri>http://www.blogger.com/profile/02543155564076384235</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_icY8aPexjCA/Sp63XsM3SLI/AAAAAAAAANI/VcVhqbw706A/s1600-R/AIbEiAIAAABECOP5xtyUoozZhwEiC3ZjYXJkX3Bob3RvKihhMWUwZmY4MTQzM2JhYjcxMmQ5OWYzMTY0N2YyZjk1MTExOGNhMzczMAFvd8hrPIJ5oYco5_oUBeY2wGftgA" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.p-jansson.com/2011/07/convert-boostposixtimeptime-to-stdtimet.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A08GSHs5cCp7ImA9WhRWEUg.&quot;"><id>tag:blogger.com,1999:blog-2574712085639993348.post-7856025541174573142</id><published>2011-06-06T10:41:00.003+02:00</published><updated>2011-12-29T12:57:09.528+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-29T12:57:09.528+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Boost" /><category scheme="http://www.blogger.com/atom/ns#" term="libssh2" /><category scheme="http://www.blogger.com/atom/ns#" term="SSH" /><category scheme="http://www.blogger.com/atom/ns#" term="Asio" /><category scheme="http://www.blogger.com/atom/ns#" term="C++" /><title>SSH communication using libssh2 and boost::asio</title><content type="html">&lt;p&gt;I once needed to create a small class to execute a SSH command on a remote server. The environment was Windows XP and Windows Vista and MinGW was the compiler system. So, what I did can be found below. It uses &lt;a href="http://www.boost.org" target="_blank"&gt;Boost::Asio&lt;/a&gt; and the &lt;a href="http://www.libssh2.org" target="_blank"&gt;libssh2&lt;/a&gt; library. Below the class code is a small program that make use of the class to execute the command &lt;tt&gt;uptime&lt;/tt&gt; on a remote (*NIX) server.  &lt;/p&gt;&lt;p&gt;My intention has been to write the code so that no or very few comments are needed. Let me know if you need more information. &lt;/p&gt;&lt;p&gt;To make this work you would need to compile the boost and libssh2 libraries and link them to your application. For libssh2, you will also need the &lt;a href="http://www.openssl.org" target="_blank"&gt;OpenSSL&lt;/a&gt; library (and the &lt;a href="http://www.zlib.net/" target="_blank"&gt;zlib&lt;/a&gt; library which is optional for OpenSSL). If you need help with this, my &lt;a href="http://www.p-jansson.com"&gt;consulting company&lt;/a&gt; can be of service. &lt;/p&gt;&lt;pre class="prettyprint"&gt;#include &amp;lt;boost/asio/io_service.hpp&amp;gt;
#include &amp;lt;boost/asio/ip/tcp.hpp&amp;gt;
#include &amp;lt;boost/utility.hpp&amp;gt;
#include &amp;lt;libssh2.h&amp;gt;
#include &amp;lt;ostream&amp;gt;
#include &amp;lt;stdexcept&amp;gt;
using namespace boost::asio;
/// @brief Class to use for communications via the
/// SSH protocol.
/// Dedicated to the public domain.
/// @author Peter Jansson
/// @date 2011-06-06
class SshComm : public boost::noncopyable
{
   typedef std::runtime_error re;
   public:
   /// @brief Create a SSH communications capable object.
   /// @details The SSH session will be initialized to
   /// communicate to the host:port specified in the
   /// arguments to this constructor, using the login
   /// credentials supplied.
   SshComm(
         const char* IP,
         const int &amp; PortNumber,
         const char* user,
         const char* pw)
      :io(),sck(io, ip::tcp::v4()),ss(libssh2_session_init())
   {
      sck.connect(
            ip::tcp::endpoint(
               ip::address::from_string(IP),
               PortNumber) );

      if( 0 &amp;gt; libssh2_session_startup(ss,sck.native()) )
      {
         throw re("Could not startup the SSH communication"
                  " session.");
      }
      if( libssh2_userauth_password(ss,user,pw) )
      {
         throw re("Access denied");
      }
   };
   /// @brief Deallocate memory needed for this object.
   virtual ~SshComm()
   {
      libssh2_session_disconnect(ss,"Goodbye.");
      libssh2_session_free(ss);
   };
   /// @brief Execute a command on the SSH server and expect
   /// a response.
   /// @param cmd[in] The command to execute.
   /// @param response_stream[in,out] The stream to write the
   /// expected response to.
   void ExecuteCmdResponse(
         const char* cmd,
         std::ostream &amp; response_stream) const
   {
      LIBSSH2_CHANNEL* ch = libssh2_channel_open_session(ss);
      if( NULL == ch )
      {
         throw re("Could not open SSH communication channel.");
      }
      libssh2_channel_set_blocking(ch,1);
      if( -1 == libssh2_channel_exec(ch,cmd))
      {
         throw re("Failed to execute command.");
      }
      char buf[1024];
      int num_of_read_bytes;
      do
      {
         num_of_read_bytes = libssh2_channel_read(ch,buf,1024);
         response_stream.write(buf,num_of_read_bytes);
      } while(1==libssh2_poll_channel_read(ch,0)
            || 1024==num_of_read_bytes );
      libssh2_channel_close(ch);
      libssh2_channel_free(ch);
   };
   private:
   /// @brief The io_service needed for boost::asio.
   io_service io;
   /// @brief The underlying socket used for ssh communication.
   ip::tcp::socket sck;
   /// @brief The SSH session structure to use in all
   /// communcations using this instance.
   LIBSSH2_SESSION* ss;
};
&lt;/pre&gt;&lt;pre class="prettyprint"&gt;#include &amp;lt;iostream&amp;gt;
#include &amp;lt;cstdlib&amp;gt;
#include &amp;lt;sstream&amp;gt;
int main(int ac,char** av)
{
   try
   {
      if( 5 != ac )
      {
         std::ostringstream o;
         o &amp;lt;&amp;lt; "Usage: " &amp;lt;&amp;lt; av[0] &amp;lt;&amp;lt; " IP username password port";
         throw std::invalid_argument(o.str());
      }
      const SshComm ssh(av[1],std::atoi(av[4]),av[2],av[3]);
      ssh.ExecuteCmdResponse("uptime",std::cout);
      return EXIT_SUCCESS;
   }
   catch( const std::exception&amp; e )
   {
      std::cerr &amp;lt;&amp;lt; e.what() &amp;lt;&amp;lt; '\n';
      return EXIT_FAILURE;
   }
}
&lt;/pre&gt;&lt;br /&gt;
&lt;style type="text/css"&gt;
@import url("http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.css");
pre.prettyprint { background: rgb(220,220,220);
&lt;/style&gt;&lt;br /&gt;
&lt;script src="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js" type="text/javascript"&gt;&lt;/script&gt;&lt;br /&gt;
&lt;script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"&gt;&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"&gt;$(document).ready(function(){prettyPrint();});&lt;/script&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2574712085639993348-7856025541174573142?l=blog.p-jansson.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/f0cwphbSchcM_z3yBtB94Qwz3Cs/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/f0cwphbSchcM_z3yBtB94Qwz3Cs/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/f0cwphbSchcM_z3yBtB94Qwz3Cs/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/f0cwphbSchcM_z3yBtB94Qwz3Cs/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JanssonConsulting/~4/aeUG62Fig_U" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.p-jansson.com/feeds/7856025541174573142/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.p-jansson.com/2011/06/ssh-communication-using-libssh2-and.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/7856025541174573142?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/7856025541174573142?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/JanssonConsulting/~3/aeUG62Fig_U/ssh-communication-using-libssh2-and.html" title="SSH communication using libssh2 and boost::asio" /><author><name>Peter Jansson</name><uri>http://www.blogger.com/profile/02543155564076384235</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_icY8aPexjCA/Sp63XsM3SLI/AAAAAAAAANI/VcVhqbw706A/s1600-R/AIbEiAIAAABECOP5xtyUoozZhwEiC3ZjYXJkX3Bob3RvKihhMWUwZmY4MTQzM2JhYjcxMmQ5OWYzMTY0N2YyZjk1MTExOGNhMzczMAFvd8hrPIJ5oYco5_oUBeY2wGftgA" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.p-jansson.com/2011/06/ssh-communication-using-libssh2-and.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A08HSX85fyp7ImA9WhRWEUg.&quot;"><id>tag:blogger.com,1999:blog-2574712085639993348.post-8600230185746443362</id><published>2011-04-19T14:53:00.001+02:00</published><updated>2011-12-29T12:57:18.127+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-29T12:57:18.127+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="snippets" /><category scheme="http://www.blogger.com/atom/ns#" term="C++" /><title>Search for a string and print N following lines.</title><content type="html">&lt;p&gt;A litte C++ code snippet to filter some text from standard input to standard output while keeping only N-1 lines following a search string. &lt;/p&gt;&lt;pre class="prettyprint"&gt;#include &amp;lt;sstream&amp;gt;
#include &amp;lt;iostream&amp;gt;
#include &amp;lt;string&amp;gt;
/*
 * If standard input contains a line with the string argv[1],
 * then print up to argv[2] lines, including the one found,
 * on standard output.
 * Dedicated to the public domain.
 * @author Peter Jansson
 * @date 2011-04-19
 */
int main(int argc,char** argv)
{
   using namespace std;
   const string argv1( argv[1] );
   istringstream iss( argv[2] );
   int N(0);
   iss &amp;gt;&amp;gt; N;
   for(string line; getline( cin, line );)
   {
      if( line.find( argv1 ) != string::npos )
      {
         for( ; N &amp;gt; 0 &amp;&amp; cin; N-- )
         {
            cout &amp;lt;&amp;lt; line &amp;lt;&amp;lt; '\n';
            getline( cin, line );
         }
         break;
      }
   }
   return 0;
}
&lt;/pre&gt;&lt;br /&gt;
&lt;style type="text/css"&gt;
@import url("http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.css");
pre.prettyprint { background: rgb(220,220,220);
&lt;/style&gt;&lt;br /&gt;
&lt;script src="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js" type="text/javascript"&gt;&lt;/script&gt;&lt;br /&gt;
&lt;script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"&gt;&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"&gt;$(document).ready(function(){prettyPrint();});&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2574712085639993348-8600230185746443362?l=blog.p-jansson.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/Ie5SED8_7MGxmE4iOpKShcX5rXs/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Ie5SED8_7MGxmE4iOpKShcX5rXs/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/Ie5SED8_7MGxmE4iOpKShcX5rXs/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Ie5SED8_7MGxmE4iOpKShcX5rXs/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JanssonConsulting/~4/UbV3w4IKju4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.p-jansson.com/feeds/8600230185746443362/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.p-jansson.com/2011/04/search-for-string-and-print-n-following.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/8600230185746443362?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/8600230185746443362?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/JanssonConsulting/~3/UbV3w4IKju4/search-for-string-and-print-n-following.html" title="Search for a string and print N following lines." /><author><name>Peter Jansson</name><uri>http://www.blogger.com/profile/02543155564076384235</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_icY8aPexjCA/Sp63XsM3SLI/AAAAAAAAANI/VcVhqbw706A/s1600-R/AIbEiAIAAABECOP5xtyUoozZhwEiC3ZjYXJkX3Bob3RvKihhMWUwZmY4MTQzM2JhYjcxMmQ5OWYzMTY0N2YyZjk1MTExOGNhMzczMAFvd8hrPIJ5oYco5_oUBeY2wGftgA" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.p-jansson.com/2011/04/search-for-string-and-print-n-following.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0IFRno9fip7ImA9WhZSGEk.&quot;"><id>tag:blogger.com,1999:blog-2574712085639993348.post-8720677588244655774</id><published>2011-04-03T11:05:00.016+02:00</published><updated>2011-04-03T18:51:57.466+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-04-03T18:51:57.466+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Accident" /><category scheme="http://www.blogger.com/atom/ns#" term="Fukushima" /><category scheme="http://www.blogger.com/atom/ns#" term="Cs-137" /><title>Cs-137 in ground level air in Stockholm (Sweden), before and after Fukushima.</title><content type="html">&lt;p&gt;
It is quite a long distance between Fukushima, Japan, and Stockholm (the capital of Sweden). Never the less, using large capacity air pumps to pump air through paper filters followed by gamma radiation measurements on the filters using high-purity Germanium detectors, very small concentrations of particulate bound radionuclides can be measured.
&lt;/p&gt;

&lt;p&gt;
Such measurements are routinely performed by the Swedish Defence Research Agency (FOI). After the Fukushima accident on March 11, 2011, some Cs-137 was evidently released and have been transported around the globe to reach Stockholm. A plot of wind trajectories calculated by the HYSPLIT program at &lt;a href="http://ready.arl.noaa.gov/HYSPLIT.php" target="_blank"&gt;ARL&lt;/a&gt; can be found below.
&lt;/p&gt;

&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://4.bp.blogspot.com/-N9wqJutrJK4/TZhSvJ71XcI/AAAAAAAAA_c/7Ieq5qK0tjA/s1600/348136_trj001.gif" imageanchor="1" style=""&gt;&lt;img border="0" height="400" width="322" src="http://4.bp.blogspot.com/-N9wqJutrJK4/TZhSvJ71XcI/AAAAAAAAA_c/7Ieq5qK0tjA/s400/348136_trj001.gif" /&gt;&lt;/a&gt;&lt;/div&gt;



&lt;p&gt;
The plot below show how the Cs-137 concentration in ground level air have increased the last few days. It is based on data and references to be found in a &lt;a href="https://spreadsheets.google.com/ccc?key=0Au8USLEBlbnrdGZwVDU4bzdWM0JEZnJFVDV6TjNscXc&amp;authkey=CMziqNYM" target="_blank"&gt;Google Docs spreadsheet&lt;/a&gt; (data &lt;a href="http://blog.p-jansson.com/2011/01/radioactivity-in-atmosphere.html" target="_blank"&gt;published by FOI&lt;/a&gt; and found on the &lt;a href="http://www.stralsakerhetsmyndigheten.se/Om-myndigheten/Aktuellt---Bilagor/Resultat-fran-matningarna-i-Sverige-/" target="_blank"&gt;home page&lt;/a&gt; of the Swedish Radiation Safety Authority).
&lt;/p&gt;

&lt;p&gt;
(Click on the 1m zoom to get a picture on the increase during the last few days.)
&lt;/p&gt;

&lt;script src="https://spreadsheets.google.com/gpub?url=http%3A%2F%2Ftbaoebshgeq225lhq2bam0m0a5mf6u0b-ss-opensocial.googleusercontent.com%2Fgadgets%2Fifr%3Fup_title%3DCs-137%2520concentration%2520in%2520ground%2520level%2520air%2520around%2520Stockholm%252C%2520Sweden%26up_scale%3Dfixed%26up_values_suffix%26up_annotations_width%3D25%26up_display_zoom_buttons%3D1%26up_display_exact_values%3D1%26up_display_annotations_filter%3D0%26up_display_legend_inNewline%3D0%26up__table_query_url%3Dhttps%253A%252F%252Fspreadsheets.google.com%252Ftq%253Frange%253DB%25253AD%2526gid%253D0%2526key%253D0Au8USLEBlbnrdGZwVDU4bzdWM0JEZnJFVDV6TjNscXc%2526authkey%253DCMziqNYM%2526pub%253D1%26url%3Dhttp%253A%252F%252Fwww.google.com%252Fig%252Fmodules%252Ftime-series-line.xml%26spreadsheets%3Dspreadsheets&amp;height=480&amp;width=600"&gt;&lt;/script&gt;


&lt;p&gt;
Here is a table showing the data used:
&lt;/p&gt;

&lt;iframe width='600' height='700' frameborder='0' src='https://spreadsheets.google.com/pub?key=0Au8USLEBlbnrdGZwVDU4bzdWM0JEZnJFVDV6TjNscXc&amp;single=true&amp;gid=5&amp;output=html&amp;widget=true'&gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2574712085639993348-8720677588244655774?l=blog.p-jansson.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/dauuXs17XaxD7gUrjc6OCOpq1cw/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/dauuXs17XaxD7gUrjc6OCOpq1cw/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/dauuXs17XaxD7gUrjc6OCOpq1cw/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/dauuXs17XaxD7gUrjc6OCOpq1cw/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JanssonConsulting/~4/fphOK480zSk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.p-jansson.com/feeds/8720677588244655774/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.p-jansson.com/2011/04/cs-137-in-ground-level-air-in-stockholm.html#comment-form" title="6 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/8720677588244655774?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/8720677588244655774?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/JanssonConsulting/~3/fphOK480zSk/cs-137-in-ground-level-air-in-stockholm.html" title="Cs-137 in ground level air in Stockholm (Sweden), before and after Fukushima." /><author><name>Peter Jansson</name><uri>http://www.blogger.com/profile/02543155564076384235</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_icY8aPexjCA/Sp63XsM3SLI/AAAAAAAAANI/VcVhqbw706A/s1600-R/AIbEiAIAAABECOP5xtyUoozZhwEiC3ZjYXJkX3Bob3RvKihhMWUwZmY4MTQzM2JhYjcxMmQ5OWYzMTY0N2YyZjk1MTExOGNhMzczMAFvd8hrPIJ5oYco5_oUBeY2wGftgA" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-N9wqJutrJK4/TZhSvJ71XcI/AAAAAAAAA_c/7Ieq5qK0tjA/s72-c/348136_trj001.gif" height="72" width="72" /><thr:total>6</thr:total><feedburner:origLink>http://blog.p-jansson.com/2011/04/cs-137-in-ground-level-air-in-stockholm.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkAMR30zcSp7ImA9WhdREU0.&quot;"><id>tag:blogger.com,1999:blog-2574712085639993348.post-5343725350483301976</id><published>2011-03-17T20:36:00.001+01:00</published><updated>2011-07-31T12:39:46.389+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-07-31T12:39:46.389+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Fukushima" /><category scheme="http://www.blogger.com/atom/ns#" term="BWR" /><title>Illustration of the BWR's at Fukushima</title><content type="html">&lt;p&gt;The &lt;a href="http://www.nei.org/" target="_blank"&gt;Nuclear Energy Institute&lt;/a&gt; in Washington have published a nice &lt;a href="http://nei.cachefly.net/static/images/BWR_illustration.jpg" target="_blank"&gt;illustration&lt;/a&gt; of the BWR design at Fukushima Daiichi:&lt;/p&gt;

&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-a4ZoD-PFjZQ/TYJiWO_STBI/AAAAAAAAA-4/YV6ns8NHhq4/s1600/BWR_Fukushima.jpg" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="345" width="400" src="http://3.bp.blogspot.com/-a4ZoD-PFjZQ/TYJiWO_STBI/AAAAAAAAA-4/YV6ns8NHhq4/s400/BWR_Fukushima.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2574712085639993348-5343725350483301976?l=blog.p-jansson.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/HaO2KXyu3Jc2gT6suXK4OTkbXMI/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/HaO2KXyu3Jc2gT6suXK4OTkbXMI/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/HaO2KXyu3Jc2gT6suXK4OTkbXMI/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/HaO2KXyu3Jc2gT6suXK4OTkbXMI/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JanssonConsulting/~4/jYJnFPA0g_8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.p-jansson.com/feeds/5343725350483301976/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.p-jansson.com/2011/03/illustration-of-bwrs-at-fukushima.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/5343725350483301976?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/5343725350483301976?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/JanssonConsulting/~3/jYJnFPA0g_8/illustration-of-bwrs-at-fukushima.html" title="Illustration of the BWR's at Fukushima" /><author><name>Peter Jansson</name><uri>http://www.blogger.com/profile/02543155564076384235</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_icY8aPexjCA/Sp63XsM3SLI/AAAAAAAAANI/VcVhqbw706A/s1600-R/AIbEiAIAAABECOP5xtyUoozZhwEiC3ZjYXJkX3Bob3RvKihhMWUwZmY4MTQzM2JhYjcxMmQ5OWYzMTY0N2YyZjk1MTExOGNhMzczMAFvd8hrPIJ5oYco5_oUBeY2wGftgA" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-a4ZoD-PFjZQ/TYJiWO_STBI/AAAAAAAAA-4/YV6ns8NHhq4/s72-c/BWR_Fukushima.jpg" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://blog.p-jansson.com/2011/03/illustration-of-bwrs-at-fukushima.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEYBRnc9eip7ImA9WhZTFUg.&quot;"><id>tag:blogger.com,1999:blog-2574712085639993348.post-3234422482565392860</id><published>2011-03-12T18:17:00.003+01:00</published><updated>2011-03-19T17:29:17.962+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-03-19T17:29:17.962+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="risk" /><title>Risks associated with nuclear power</title><content type="html">&lt;p&gt;In the aftermath of the events at the &lt;a href="http://en.wikipedia.org/wiki/Fukushima_I_Nuclear_Power_Plant" target="_blank"&gt;Fukushima Daiichi nuclear power&lt;/a&gt; plant following 11 March 2011, there will probably be a renewed debate on the use of nuclear power compared to other energy sources.&lt;/p&gt;
&lt;p&gt;I would like to recommend everybody interested to read the NEA report number 6861 entitled "&lt;a href="http://www.oecd-nea.org/ndd/reports/2010/nea6862-comparing-risks.pdf" target="_blank"&gt;Comparing Nuclear Accident Risks with Those from Other Energy Sources&lt;/a&gt;" (ISBN 978-92-64-99122-4):&lt;/p&gt;

&lt;iframe src="http://www.oecd-nea.org/ndd/reports/2010/nea6862-comparing-risks.pdf" width="600" height="800"&gt;&lt;/iframe&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2574712085639993348-3234422482565392860?l=blog.p-jansson.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/oxbwQbsmCQStRbNdvH6uTtjaAJ0/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/oxbwQbsmCQStRbNdvH6uTtjaAJ0/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/oxbwQbsmCQStRbNdvH6uTtjaAJ0/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/oxbwQbsmCQStRbNdvH6uTtjaAJ0/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JanssonConsulting/~4/P1fhPRZAZjw" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.p-jansson.com/feeds/3234422482565392860/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.p-jansson.com/2011/03/risks-associated-with-nuclear-power.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/3234422482565392860?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/3234422482565392860?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/JanssonConsulting/~3/P1fhPRZAZjw/risks-associated-with-nuclear-power.html" title="Risks associated with nuclear power" /><author><name>Peter Jansson</name><uri>http://www.blogger.com/profile/02543155564076384235</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_icY8aPexjCA/Sp63XsM3SLI/AAAAAAAAANI/VcVhqbw706A/s1600-R/AIbEiAIAAABECOP5xtyUoozZhwEiC3ZjYXJkX3Bob3RvKihhMWUwZmY4MTQzM2JhYjcxMmQ5OWYzMTY0N2YyZjk1MTExOGNhMzczMAFvd8hrPIJ5oYco5_oUBeY2wGftgA" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.p-jansson.com/2011/03/risks-associated-with-nuclear-power.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A08BRHw-cSp7ImA9WhRWEUg.&quot;"><id>tag:blogger.com,1999:blog-2574712085639993348.post-7589754733966439908</id><published>2011-02-28T12:41:00.005+01:00</published><updated>2011-12-29T12:57:35.259+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-29T12:57:35.259+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="locale" /><category scheme="http://www.blogger.com/atom/ns#" term="C++" /><title>Grouping and thousands separator in C++</title><content type="html">&lt;p&gt;Learn by doing... &lt;/p&gt;&lt;pre class="prettyprint"&gt;#include &amp;lt;locale&amp;gt;

template &amp;lt;class T&amp;gt;
struct formatter : std::numpunct&amp;lt;T&amp;gt;
{
   protected:
      T do_thousands_sep() const
      {
         return T('-');
      }
      std::basic_string&amp;lt;T&amp;gt do_grouping() const
      {
         return std::basic_string&amp;lt;T&amp;gt("\3\2\3");
      }
};

#include &amp;lt;iostream&amp;gt;

int main()
{
   std::locale fmt(std::locale::classic(), new formatter&amp;lt;char&amp;gt;);
   std::cout.imbue(fmt);

   std::cout &amp;lt;&amp;lt; 12345678 &amp;lt;&amp;lt; std::endl;
   return 0;
}
&lt;/pre&gt;&lt;p&gt;Output:&lt;br /&gt;
&lt;tt&gt;123-45-678&lt;/tt&gt; &lt;/p&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;style type="text/css"&gt;
@import url("http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.css");
pre.prettyprint { background: rgb(220,220,220);
&lt;/style&gt;&lt;br /&gt;
&lt;script src="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js" type="text/javascript"&gt;&lt;/script&gt;&lt;br /&gt;
&lt;script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"&gt;&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"&gt;$(document).ready(function(){prettyPrint();});&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2574712085639993348-7589754733966439908?l=blog.p-jansson.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/qVNWDiv82VEIWEsBLcZj8C11qAA/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/qVNWDiv82VEIWEsBLcZj8C11qAA/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/qVNWDiv82VEIWEsBLcZj8C11qAA/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/qVNWDiv82VEIWEsBLcZj8C11qAA/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JanssonConsulting/~4/-L8sFy-_FiM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.p-jansson.com/feeds/7589754733966439908/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.p-jansson.com/2011/02/grouping-and-thousands-separator-in-c.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/7589754733966439908?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/7589754733966439908?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/JanssonConsulting/~3/-L8sFy-_FiM/grouping-and-thousands-separator-in-c.html" title="Grouping and thousands separator in C++" /><author><name>Peter Jansson</name><uri>http://www.blogger.com/profile/02543155564076384235</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_icY8aPexjCA/Sp63XsM3SLI/AAAAAAAAANI/VcVhqbw706A/s1600-R/AIbEiAIAAABECOP5xtyUoozZhwEiC3ZjYXJkX3Bob3RvKihhMWUwZmY4MTQzM2JhYjcxMmQ5OWYzMTY0N2YyZjk1MTExOGNhMzczMAFvd8hrPIJ5oYco5_oUBeY2wGftgA" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.p-jansson.com/2011/02/grouping-and-thousands-separator-in-c.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEcNQ3w-eSp7ImA9Wx9QGUs.&quot;"><id>tag:blogger.com,1999:blog-2574712085639993348.post-6166770338555970329</id><published>2011-01-02T10:54:00.000+01:00</published><updated>2011-01-02T10:54:52.251+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-01-02T10:54:52.251+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Be-7" /><category scheme="http://www.blogger.com/atom/ns#" term="Radioactivity" /><category scheme="http://www.blogger.com/atom/ns#" term="Cs-137" /><title>Radioactivity in the atmosphere.</title><content type="html">&lt;p&gt;Plots of activity concentrations of &lt;sup&gt;7&lt;/sup&gt;Be and &lt;sup&gt;137&lt;/sup&gt;Cs in the ground level air around Grindsj&amp;ouml;n (In Sweden at &lt;a href="http://stable.toolserver.org/geohack/geohack.php?language=sv&amp;pagename=Grindsj%C3%B6n&amp;params=59_5_6.56_N_17_52_11.20_E_type:landmark" target="_blank"&gt;59°5′6,56″ N 17°52′11,20″ E&lt;/a&gt;) follows.&lt;/p&gt;
&lt;p&gt;
&lt;i&gt;Reference:&lt;/i&gt;&lt;br/&gt;
C. Söderström, R. Arntsing, P. Jansson, K. Lindh and K. Wilhelmsen. "History of the sampling station at Grindsj&amp;ouml;n with Quarterly report on measurements of radionuclides in ground level air in Sweden. Fourth quarter 2003." Scientific report no FOI-R--1262--SE from the Swedish Defence Research Agency (&lt;a href="http://www.foi.se" target="_blank"&gt;FOI&lt;/a&gt;). ISSN 1650-1942. June 2004.
&lt;/p&gt;

&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/_icY8aPexjCA/TSBJnkFxYQI/AAAAAAAAA9Q/v_uoak5Um14/s1600/Be7.jpg" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="286" width="400" src="http://2.bp.blogspot.com/_icY8aPexjCA/TSBJnkFxYQI/AAAAAAAAA9Q/v_uoak5Um14/s400/Be7.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/_icY8aPexjCA/TSBJsg6pGaI/AAAAAAAAA9Y/m-Uutu3L-yY/s1600/Cs137.jpg" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="299" width="400" src="http://2.bp.blogspot.com/_icY8aPexjCA/TSBJsg6pGaI/AAAAAAAAA9Y/m-Uutu3L-yY/s400/Cs137.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2574712085639993348-6166770338555970329?l=blog.p-jansson.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/MVBDvAMkzC6uILl9yf-uDYf74l4/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/MVBDvAMkzC6uILl9yf-uDYf74l4/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/MVBDvAMkzC6uILl9yf-uDYf74l4/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/MVBDvAMkzC6uILl9yf-uDYf74l4/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JanssonConsulting/~4/h83HSLGFIlQ" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.p-jansson.com/feeds/6166770338555970329/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.p-jansson.com/2011/01/radioactivity-in-atmosphere.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/6166770338555970329?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/6166770338555970329?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/JanssonConsulting/~3/h83HSLGFIlQ/radioactivity-in-atmosphere.html" title="Radioactivity in the atmosphere." /><author><name>Peter Jansson</name><uri>http://www.blogger.com/profile/02543155564076384235</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_icY8aPexjCA/Sp63XsM3SLI/AAAAAAAAANI/VcVhqbw706A/s1600-R/AIbEiAIAAABECOP5xtyUoozZhwEiC3ZjYXJkX3Bob3RvKihhMWUwZmY4MTQzM2JhYjcxMmQ5OWYzMTY0N2YyZjk1MTExOGNhMzczMAFvd8hrPIJ5oYco5_oUBeY2wGftgA" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_icY8aPexjCA/TSBJnkFxYQI/AAAAAAAAA9Q/v_uoak5Um14/s72-c/Be7.jpg" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://blog.p-jansson.com/2011/01/radioactivity-in-atmosphere.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A08DRn4zfCp7ImA9WhRWEUg.&quot;"><id>tag:blogger.com,1999:blog-2574712085639993348.post-1133831305008754476</id><published>2010-12-25T15:51:00.010+01:00</published><updated>2011-12-29T12:57:57.084+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-29T12:57:57.084+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Random" /><title>Random Points in a Triangle</title><content type="html">&lt;p&gt;Have you ever needed to generate random points in a triangle?&lt;/p&gt;&lt;p&gt;Quite often, such points are needed in compuler simulations and games. I found an article on the subject somwhere and wrote some simple JavaScript code to test it.&lt;/p&gt;&lt;p&gt;Here is the actual algorithm: Given a triangle with vertices A, B and C. Generate two random numbers a and b uniformly between 0 and 1. If the sum a+b is &amp;gt; 1, then set a=1-a and b=1-b. Let c=1-a-b. A random point P distributed uniformly within the triangle is then given by P=aA+bB+cC.&lt;/p&gt;&lt;p&gt;The a, b and c numbers are called the &lt;a href="http://en.wikipedia.org/wiki/Barycentric_coordinate_system_(mathematics)" target="_blank"&gt;barycentric coordinates&lt;/a&gt; of the triangle.&lt;/p&gt;&lt;p&gt;If you have JavaScript enabled in your browser, then you should see a plot below that demonstrates generation of 100 random points within random generated triangles. You can get the source code if you look at the source to this page.&lt;/p&gt;&lt;center&gt; &lt;div id="holder"&gt;&lt;/div&gt;&lt;/center&gt;  &lt;script src="http://github.com/DmitryBaranovskiy/raphael/raw/master/raphael-min.js"&gt;&lt;/script&gt; &lt;script&gt;
function tri(holderid)
{
   var W = 400;
   var xA = Math.floor(W*Math.random());
   var yA = Math.floor(W*Math.random());
   var xB = Math.floor(W*Math.random());
   var yB = Math.floor(W*Math.random());
   var xC = Math.floor(W*Math.random());
   var yC = Math.floor(W*Math.random());

   var paper = Raphael(holderid,W,W);

   var bound = paper.rect(0,0,W-1,W-1);
   bound.attr("fill","#fff");
   bound.attr("stroke","#000");

   var ps ="M"+xA+" "+yA+"L"+xB+" "+yB+"L"+xC+" "+yC+"L"+xA+" "+yA;
   var p = paper.path(ps);
   p.attr("stroke","#00f");

   for( var i=0;i&lt;100;i++)
   {
      var a = Math.random();
      var b = Math.random();
      var sum = a + b;
      if( sum &gt; 1.0 )
      {
         a = 1.0 - a;
         b = 1.0 - b;
      }
      var c = 1.0 - a - b;
      var x = a*xA + b*xB + c*xC;
      var y = a*yA + b*yB + c*yC;
      var dot = paper.circle(x,y,1);
      dot.attr("fill", "#f00");
      dot.attr("stroke", "#f00");
   }

   return paper;
};
var r;
var tick;
function ticker()
{
   r.remove();
   r = tri("holder");
   tick = setTimeout(ticker, 500 );
};
window.onload = function () {
   r = tri("holder");
   tick = setTimeout(ticker, 500 );
};
&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2574712085639993348-1133831305008754476?l=blog.p-jansson.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/A4RevevZKzB-_znS-IbUeVEbqZo/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/A4RevevZKzB-_znS-IbUeVEbqZo/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/A4RevevZKzB-_znS-IbUeVEbqZo/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/A4RevevZKzB-_znS-IbUeVEbqZo/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JanssonConsulting/~4/exIzAEBdWPQ" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.p-jansson.com/feeds/1133831305008754476/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.p-jansson.com/2010/12/random-points-in-triangle.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/1133831305008754476?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/1133831305008754476?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/JanssonConsulting/~3/exIzAEBdWPQ/random-points-in-triangle.html" title="Random Points in a Triangle" /><author><name>Peter Jansson</name><uri>http://www.blogger.com/profile/02543155564076384235</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_icY8aPexjCA/Sp63XsM3SLI/AAAAAAAAANI/VcVhqbw706A/s1600-R/AIbEiAIAAABECOP5xtyUoozZhwEiC3ZjYXJkX3Bob3RvKihhMWUwZmY4MTQzM2JhYjcxMmQ5OWYzMTY0N2YyZjk1MTExOGNhMzczMAFvd8hrPIJ5oYco5_oUBeY2wGftgA" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.p-jansson.com/2010/12/random-points-in-triangle.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A08NQHs5fip7ImA9WhRWEUg.&quot;"><id>tag:blogger.com,1999:blog-2574712085639993348.post-2462301951862326355</id><published>2010-11-21T11:59:00.011+01:00</published><updated>2011-12-29T12:58:11.526+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-29T12:58:11.526+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="mmap" /><category scheme="http://www.blogger.com/atom/ns#" term="streambuf" /><category scheme="http://www.blogger.com/atom/ns#" term="C++" /><title>Reading a memory mapped file as a normal C++ std::istream.</title><content type="html">&lt;p&gt;I was working on an entry to a programming challenge that was all about reading numbers from an file as fast as possible. In that work, I did some experimentation with specializing a std::streambuf object to be able to read from a &lt;a href="http://en.wikipedia.org/wiki/Memory-mapped_file" target="_blank"&gt;memory map&lt;/a&gt; of that file as if it was a normal C++ input stream (std::istream).&lt;/p&gt;&lt;p&gt;It turned out that it was not the fastest way to use the memory map since the istream machinery generated by my C++ compiler was not that very efficient compared to parsing the memory more directly. Nevertheless, I thought it was a neat solution so I would like to share the code with the world in case someone else needs it.&lt;/p&gt;&lt;p&gt;Here it is:&lt;/p&gt;&lt;a name='more'&gt;&lt;/a&gt;  &lt;pre  class="prettyprint"&gt;/// Streambuf specialization to read (only) from
/// a file using a memory map of the file.
/// This is Microsoft Windows specific but could
/// relatively easy be ported to a Linux variant.
/// Also, the whole file is mapped to memory. There
/// is room for optimization with reading only one
/// page at the time...
///
/// Usage example to read all lines from a file:
///
///     membuf mb("a_file.txt");
///     std::istream i(&amp;mb);
///     for( std::string line; std::getline(i,line); )
///     {
///        // do something with the line.
///     }
///
/// Author: Peter Jansson (&lt;a href="http://www.p-jansson.com"&gt;http://www.p-jansson.com&lt;/a&gt;)
/// Date: 2010-11-21
/// Dedicated to the public domain.
///
#include "streambuf"
#include "windows.h"
class membuf: public std::streambuf
{
   public:
      membuf(const char* filename)
         :std::streambuf()
      {
         hFile = CreateFileA(
               filename,
               GENERIC_READ,
               0,
               NULL,
               OPEN_EXISTING,
               FILE_ATTRIBUTE_READONLY,
               NULL);
         hFileMappingObject = CreateFileMapping(
               hFile,
               NULL,
               PAGE_READONLY,
               0,
               0,
               NULL);
         beg = MapViewOfFile(hFileMappingObject,
               FILE_MAP_READ,
               0,
               0,
               0);
         char* e = (char*)beg;
         e += GetFileSize( hFile, NULL );
         setg((char*)beg,(char*)beg,e);
         setp(&amp;outBuf,&amp;outBuf);
      }
      /// Close the memory mapping and the opened
      /// file.
      ~membuf()
      {
         UnmapViewOfFile(beg);
         CloseHandle( hFileMappingObject );
         CloseHandle( hFile );
      }
   private:
      /// We can't copy this.
      membuf(const membuf&amp;);
      membuf&amp; operator=(const membuf&amp;);
      /// Outbuf buffer that is not used since we
      /// don't write to the memory map.
      char outBuf;
      HANDLE hFile,hFileMappingObject;
      /// Pointer to the beginning of the mapped
      /// memory area.
      LPVOID beg;
};
&lt;/pre&gt;&lt;br /&gt;
&lt;style type="text/css"&gt;
@import url("http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.css");
pre.prettyprint { background: rgb(220,220,220);
&lt;/style&gt;&lt;br /&gt;
&lt;script src="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js" type="text/javascript"&gt;&lt;/script&gt;&lt;br /&gt;
&lt;script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"&gt;&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"&gt;$(document).ready(function(){prettyPrint();});&lt;/script&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/2574712085639993348-2462301951862326355?l=blog.p-jansson.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/L7oa-uFRQBjWCLse-IigcCXiSew/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/L7oa-uFRQBjWCLse-IigcCXiSew/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/L7oa-uFRQBjWCLse-IigcCXiSew/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/L7oa-uFRQBjWCLse-IigcCXiSew/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JanssonConsulting/~4/xANM11gMgxk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.p-jansson.com/feeds/2462301951862326355/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.p-jansson.com/2010/11/reading-memory-mapped-file-as-normal-c.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/2462301951862326355?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/2462301951862326355?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/JanssonConsulting/~3/xANM11gMgxk/reading-memory-mapped-file-as-normal-c.html" title="Reading a memory mapped file as a normal C++ std::istream." /><author><name>Peter Jansson</name><uri>http://www.blogger.com/profile/02543155564076384235</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_icY8aPexjCA/Sp63XsM3SLI/AAAAAAAAANI/VcVhqbw706A/s1600-R/AIbEiAIAAABECOP5xtyUoozZhwEiC3ZjYXJkX3Bob3RvKihhMWUwZmY4MTQzM2JhYjcxMmQ5OWYzMTY0N2YyZjk1MTExOGNhMzczMAFvd8hrPIJ5oYco5_oUBeY2wGftgA" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.p-jansson.com/2010/11/reading-memory-mapped-file-as-normal-c.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A04ESH89fyp7ImA9WhRWEUg.&quot;"><id>tag:blogger.com,1999:blog-2574712085639993348.post-3078654818934254658</id><published>2010-08-11T20:31:00.010+02:00</published><updated>2011-12-29T12:58:29.167+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-29T12:58:29.167+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Boost" /><category scheme="http://www.blogger.com/atom/ns#" term="Asio" /><category scheme="http://www.blogger.com/atom/ns#" term="C++" /><title>Traceroute in C++ using boost::asio</title><content type="html">&lt;p&gt;The other week, I was experimenting with raw sockets and learning the structure of IP packets (version 4). It is always good to learn by doing and to learn better in this case, I built a simple traceroute program. Of course, this version of traceroute is very simple compared to the more advanced version distributed with various *NIX systems but it demonstrates nicely how to work with raw sockets using boost::asio.&lt;/p&gt;&lt;p&gt;Traceroute works by sending IP packets with the time-to-live-field initially set to zero and then increasing it by one for each hop along the way to a target host. Routers along the route will reply with a ICMP packet with the time exceeded message code since the TTL field is too low. This is the reason why we can learn the address of routers along the route.&lt;/p&gt;&lt;p&gt;The program that can be found below read the raw data received on the wire and parses out the source IP address from the IP packet. Looking at the IP header structure, this information is located at bit offset 96 in the header: &lt;/p&gt;&lt;pre class="prettyprint"&gt;0               8               16                             31
 +-------+-------+---------------+------------------------------+      ---
 |       |       |               |                              |       ^
 |version|header |    type of    |    total length in bytes     |       |
 |  (4)  |length |    service    |                              |       |
 +-------+-------+---------------+-+-+-+------------------------+       |
 |                               | | | |                        |       |
 |        identification         |0|D|M|    fragment offset     |       |
 |                               | |F|F|                        |       |
 +---------------+---------------+-+-+-+------------------------+       |
 |               |               |                              |       |
 | time to live  |   protocol    |       header checksum        |   20 bytes
 |               |               |                              |       |
 +---------------+---------------+------------------------------+       |
 |                                                              |       |
 |                      source IPv4 address                     |       |
 |                                                              |       |
 +--------------------------------------------------------------+       |
 |                                                              |       |
 |                   destination IPv4 address                   |       |
 |                                                              |       v
 +--------------------------------------------------------------+      ---
&lt;/pre&gt;&lt;p&gt;I should mention that, even though boost::asio should be highly platform independent, I could not get this program to do its job properly on Windows (Vista). It turns out that setting the TTL fails on that system using boost version 1.43. On a Linux Ubuntu box with boost version 1.42 it works as expected. (You can read more about the evolution of this problem on the &lt;a href="https://svn.boost.org/trac/boost/ticket/4529" target="_blank"&gt;ticket created for it&lt;/a&gt;.) &lt;/p&gt;&lt;p&gt;The code follows. Please read it and you will understand what has been done. &lt;/p&gt;&lt;a name='more'&gt;&lt;/a&gt;  &lt;pre class="prettyprint"&gt;#include &amp;lt;iostream&amp;gt;
#include &amp;lt;sstream&amp;gt;
#include &amp;lt;stdexcept&amp;gt;
#include &amp;lt;vector&amp;gt;
#include &amp;lt;boost/asio.hpp&amp;gt;
#include "icmp_header.hpp"

using boost::asio::ip::icmp;

class traceroute: public boost::noncopyable
{
   public:
      traceroute(const char* host):
         io(),
         resolver(io),
         socket(io, icmp::v4()),
         sequence_number(0)
      {
        icmp::resolver::query query(icmp::v4(), host, "");
        destination = *resolver.resolve(query);
      }
      ~traceroute() { socket.close(); }
      void trace()
      {
         for( int ttl(1); ttl &amp;lt; 31 ; ttl++)
         {
            const boost::asio::ip::unicast::hops option( ttl );
            socket.set_option(option);

            boost::asio::ip::unicast::hops op;
            socket.get_option(op);
            if( ttl !=  op.value() )
            {
               std::ostringstream o;
               o &amp;lt;&amp;lt; "TTL not set properly. Should be "
                 &amp;lt;&amp;lt; ttl &amp;lt;&amp;lt; " but was set to "
                 &amp;lt;&amp;lt; op.value() &amp;lt;&amp;lt; '.';
               throw std::runtime_error(o.str());
            }

            // Create an ICMP header for an echo request.
            icmp_header echo_request;
            echo_request.type(icmp_header::echo_request);
            echo_request.code(0);
            echo_request.identifier(get_identifier());
            echo_request.sequence_number(++sequence_number);
            const std::string body("");
            compute_checksum(echo_request, body.begin(), body.end());

            // Encode the request packet.
            boost::asio::streambuf request_buffer;
            std::ostream os(&amp;request_buffer);
            os &amp;lt;&amp;lt; echo_request &amp;lt;&amp;lt; body;

            // Send the request.
            socket.send_to(request_buffer.data(), destination);

            // Recieve some data and parse it.
            std::vector&amp;lt;boost::uint8_t&amp;gt; data(64,0);
            const std::size_t nr(
               socket.receive(
                  boost::asio::buffer(data) ) );
            if( nr &amp;lt; 16 )
            {
               throw std::runtime_error("To few bytes returned.");
            }
            std::ostringstream remote_ip;
            remote_ip  
               &amp;lt;&amp;lt; (int)data[12] &amp;lt;&amp;lt; '.'
               &amp;lt;&amp;lt; (int)data[13] &amp;lt;&amp;lt; '.'
               &amp;lt;&amp;lt; (int)data[14] &amp;lt;&amp;lt; '.'
               &amp;lt;&amp;lt; (int)data[15];
            std::cout &amp;lt;&amp;lt; remote_ip.str() &amp;lt;&amp;lt; '\n';
            if( boost::asio::ip::address_v4::from_string( remote_ip.str() )
                  == destination.address() )
            {
               break;
            }
         }
      }
   private:
      static const int port = 33434;
      boost::asio::io_service io;
      boost::asio::ip::icmp::resolver resolver;
      boost::asio::ip::icmp::socket socket ;
      unsigned short sequence_number;
      boost::asio::ip::icmp::endpoint destination;
      static unsigned short get_identifier()
      {
#if defined(BOOST_WINDOWS)
         return static_cast&amp;lt;unsigned short&amp;gt;(::GetCurrentProcessId());
#else
         return static_cast&amp;lt;unsigned short&amp;gt;(::getpid());
#endif
      }
};

int main( int argc, char** argv)
{
   try
   {
      if( argc != 2 )
      {
         throw std::invalid_argument("Usage: traceroute host");
      }
      traceroute T( argv[1] );
      T.trace();
   }
   catch( const std::exception&amp; e )
   {
      std::cerr &amp;lt;&amp;lt; e.what() &amp;lt;&amp;lt; '\n';
   }
}
&lt;/pre&gt;&lt;p&gt;The class icmp_header that is included was simply &lt;a href="http://www.boost.org/doc/libs/1_43_0/doc/html/boost_asio/example/icmp/icmp_header.hpp" target="_blank"&gt;copied&lt;/a&gt; from the &lt;a href="http://www.boost.org" target="_blank"&gt;boost website&lt;/a&gt;:&lt;/p&gt;&lt;pre class="prettyprint"&gt;//
// icmp_header.hpp
// ~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//

#ifndef ICMP_HEADER_HPP
#define ICMP_HEADER_HPP

#include &amp;lt;istream&amp;gt;
#include &amp;lt;ostream&amp;gt;
#include &amp;lt;algorithm&amp;gt;

// ICMP header for both IPv4 and IPv6.
//
// The wire format of an ICMP header is:
// 
// 0               8               16                             31
// +---------------+---------------+------------------------------+      ---
// |               |               |                              |       ^
// |     type      |     code      |          checksum            |       |
// |               |               |                              |       |
// +---------------+---------------+------------------------------+    8 bytes
// |                               |                              |       |
// |          identifier           |       sequence number        |       |
// |                               |                              |       v
// +-------------------------------+------------------------------+      ---

class icmp_header
{
public:
  enum { echo_reply = 0, destination_unreachable = 3, source_quench = 4,
    redirect = 5, echo_request = 8, time_exceeded = 11, parameter_problem = 12,
    timestamp_request = 13, timestamp_reply = 14, info_request = 15,
    info_reply = 16, address_request = 17, address_reply = 18 };

  icmp_header() { std::fill(rep_, rep_ + sizeof(rep_), 0); }

  unsigned char type() const { return rep_[0]; }
  unsigned char code() const { return rep_[1]; }
  unsigned short checksum() const { return decode(2, 3); }
  unsigned short identifier() const { return decode(4, 5); }
  unsigned short sequence_number() const { return decode(6, 7); }

  void type(unsigned char n) { rep_[0] = n; }
  void code(unsigned char n) { rep_[1] = n; }
  void checksum(unsigned short n) { encode(2, 3, n); }
  void identifier(unsigned short n) { encode(4, 5, n); }
  void sequence_number(unsigned short n) { encode(6, 7, n); }

  friend std::istream&amp; operator&amp;gt;&amp;gt;(std::istream&amp; is, icmp_header&amp; header)
    { return is.read(reinterpret_cast&amp;lt;char*&amp;gt;(header.rep_), 8); }

  friend std::ostream&amp; operator&amp;lt;&amp;lt;(std::ostream&amp; os, const icmp_header&amp; header)
    { return os.write(reinterpret_cast&amp;lt;const char*&amp;gt;(header.rep_), 8); }

private:
  unsigned short decode(int a, int b) const
    { return (rep_[a] &amp;lt;&amp;lt; 8) + rep_[b]; }

  void encode(int a, int b, unsigned short n)
  {
    rep_[a] = static_cast&amp;lt;unsigned char&amp;gt;(n &amp;gt;&amp;gt; 8);
    rep_[b] = static_cast&amp;lt;unsigned char&amp;gt;(n &amp; 0xFF);
  }

  unsigned char rep_[8];
};

template &amp;lt;typename Iterator&amp;gt;
void compute_checksum(icmp_header&amp; header,
    Iterator body_begin, Iterator body_end)
{
  unsigned int sum = (header.type() &amp;lt;&amp;lt; 8) + header.code()
    + header.identifier() + header.sequence_number();

  Iterator body_iter = body_begin;
  while (body_iter != body_end)
  {
    sum += (static_cast&amp;lt;unsigned char&amp;gt;(*body_iter++) &amp;lt;&amp;lt; 8);
    if (body_iter != body_end)
      sum += static_cast&amp;lt;unsigned char&amp;gt;(*body_iter++);
  }

  sum = (sum &amp;gt;&amp;gt; 16) + (sum &amp; 0xFFFF);
  sum += (sum &amp;gt;&amp;gt; 16);
  header.checksum(static_cast&amp;lt;unsigned short&amp;gt;(~sum));
}

#endif // ICMP_HEADER_HPP
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;style type="text/css"&gt;
@import url("http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.css");
pre.prettyprint { background: rgb(220,220,220);
&lt;/style&gt;&lt;br /&gt;
&lt;script src="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js" type="text/javascript"&gt;&lt;/script&gt;&lt;br /&gt;
&lt;script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"&gt;&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"&gt;$(document).ready(function(){prettyPrint();});&lt;/script&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2574712085639993348-3078654818934254658?l=blog.p-jansson.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/kZ0gDxFZBY7uUc_5CUQ3fktOxpA/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/kZ0gDxFZBY7uUc_5CUQ3fktOxpA/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/kZ0gDxFZBY7uUc_5CUQ3fktOxpA/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/kZ0gDxFZBY7uUc_5CUQ3fktOxpA/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JanssonConsulting/~4/UXkukpt97LQ" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.p-jansson.com/feeds/3078654818934254658/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.p-jansson.com/2010/08/traceroute-in-c-using-boostasio.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/3078654818934254658?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/3078654818934254658?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/JanssonConsulting/~3/UXkukpt97LQ/traceroute-in-c-using-boostasio.html" title="Traceroute in C++ using boost::asio" /><author><name>Peter Jansson</name><uri>http://www.blogger.com/profile/02543155564076384235</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_icY8aPexjCA/Sp63XsM3SLI/AAAAAAAAANI/VcVhqbw706A/s1600-R/AIbEiAIAAABECOP5xtyUoozZhwEiC3ZjYXJkX3Bob3RvKihhMWUwZmY4MTQzM2JhYjcxMmQ5OWYzMTY0N2YyZjk1MTExOGNhMzczMAFvd8hrPIJ5oYco5_oUBeY2wGftgA" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.p-jansson.com/2010/08/traceroute-in-c-using-boostasio.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A04GR349eip7ImA9WhRWEUg.&quot;"><id>tag:blogger.com,1999:blog-2574712085639993348.post-1758432055844000492</id><published>2010-07-29T18:12:00.007+02:00</published><updated>2011-12-29T12:58:46.062+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-29T12:58:46.062+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="spectroscopy" /><category scheme="http://www.blogger.com/atom/ns#" term="peak-search" /><title>Peak search in a gamma-ray energy spectrum</title><content type="html">&lt;p&gt;In this post, a method for finding peaks in energy spectra obtained in high resolution gamma-ray spectroscopy is presented. The method is straightforward and involves no iterative procedures and is widely used in many software packages. The basic idea is to study the derivatives of the spectrum to find out where the peaks are located.&lt;/p&gt;&lt;p&gt;The method is presented by an example. We use one HPGe spectrum from the 2002 &lt;a href="http://www.iaea.org" target="_blank"&gt;IAEA&lt;/a&gt; inter-comparison spectra. This spectrum, identified by the name "mix2eq", was acquired during one hour with the detector aimed at at mixture of nuclides.&lt;/p&gt;&lt;style&gt;
div.spect {width:600px; height:300px }
div.plot { background: white; width:600px; height:320px }
div.plotlabel { height:20px; width:600px; text-align:center; color:black; font-size:smaller}
&lt;/style&gt;  &lt;div class="plot"&gt;&lt;div id="spectrum" class="spect"&gt;&lt;/div&gt;&lt;div class="plotlabel"&gt;Channel&lt;/div&gt;&lt;/div&gt;&lt;p&gt;The peak positions are located at places where the 1&lt;sup&gt;st&lt;/sup&gt; derivative of the spectrum is zero and the 2&lt;sup&gt;nd&lt;/sup&gt; derivative is negative. The 1&lt;sup&gt;st&lt;/sup&gt; and 2&lt;sup&gt;nd&lt;/sup&gt; derivative is approximated by &lt;a href="http://en.wikipedia.org/wiki/Finite_difference" target="_blank"&gt;finite differences&lt;/a&gt; as follows. In our spectrum, we have h = 1 since we are dealing with channels.&lt;br /&gt;
&lt;a href="http://www.codecogs.com/eqnedit.php?latex=f{}'\left ( x \right )\approx \frac{f\left ( x@plus;h \right )-f\left ( x \right )}{h} = f\left ( x@plus;1 \right )-f\left ( x \right )" target="_blank"&gt;&lt;img src="http://latex.codecogs.com/png.latex?f{}'\left ( x \right )\approx \frac{f\left ( x+h \right )-f\left ( x \right )}{h} = f\left ( x+1 \right )-f\left ( x \right )" title="f{}'\left ( x \right )\approx \frac{f\left ( x+h \right )-f\left ( x \right )}{h} = f\left ( x+1 \right )-f\left ( x \right )" /&gt;&lt;/a&gt; &lt;br /&gt;
&lt;a href="http://www.codecogs.com/eqnedit.php?latex=f{}''\left ( x \right )\approx \frac{f\left ( x@plus;h \right )-2 f\left ( x \right )@plus;f\left (x-h \right )}{h^2} = f\left ( x@plus;1 \right )-2 f\left ( x \right )@plus;f\left (x-1 \right )" target="_blank"&gt;&lt;img src="http://latex.codecogs.com/png.latex?f{}''\left ( x \right )\approx \frac{f\left ( x+h \right )-2 f\left ( x \right )+f\left (x-h \right )}{h^2} = f\left ( x+1 \right )-2 f\left ( x \right )+f\left (x-1 \right )" title="f{}''\left ( x \right )\approx \frac{f\left ( x+h \right )-2 f\left ( x \right )+f\left (x-h \right )}{h^2} = f\left ( x+1 \right )-2 f\left ( x \right )+f\left (x-1 \right )" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;p&gt;If you were to plot the 1&lt;sup&gt;st&lt;/sup&gt; or the 2&lt;sup&gt;nd&lt;/sup&gt; derivative and zoom in, you would notice a lot of noise where the data fluctuates around zero. To avoid detecting false peaks, we will only use 1&lt;sup&gt;st&lt;/sup&gt; derivative data that are within a band around zero and only use 2&lt;sup&gt;nd&lt;/sup&gt; derivative data that are below a certain negative threshold. For this example, you can experiment with the limits using the sliders below: &lt;/p&gt;&lt;script language="javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/jquery-ui.min.js"&gt;&lt;/script&gt; &lt;style type="text/css"&gt;
@import url("http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css");
div.demo { padding: 10px !important; };
&lt;/style&gt;   &lt;div class="demo"&gt;&lt;p&gt;&lt;label for="d1_limit"&gt;1&lt;sup&gt;st&lt;/sup&gt; derivative limit:&lt;/label&gt; &lt;input type="text" id="d1_limit" style="border:0;" /&gt; &lt;/p&gt;&lt;div id="slider-range-d1"&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="demo"&gt;&lt;p&gt;&lt;label for="d2_limit"&gt;2&lt;sup&gt;nd&lt;/sup&gt; derivative limit:&lt;/label&gt; &lt;input type="text" id="d2_limit" style="border:0;" /&gt; &lt;/p&gt;&lt;div id="slider-range-d2"&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;Plotting the 2&lt;sup&gt;nd&lt;/sup&gt; derivative data only for those channels that fulfill these limits provides a visual tool to see where the peaks are located. This plot is updated when the sliders above are moved. &lt;/p&gt;&lt;div class="plot"&gt;&lt;div id="spectrum_2nd" class="spect"&gt;&lt;/div&gt;&lt;div class="plotlabel"&gt;Channel&lt;/div&gt;&lt;/div&gt;&lt;p id="list"&gt;&lt;/p&gt;&lt;!--[if IE]&gt;&lt;script language="javascript" type="text/javascript" src="http://flot.googlecode.com/svn/trunk/excanvas.min.js"&gt;&lt;/script&gt;&lt;![endif]--&gt; &lt;script language="javascript" src="http://flot.googlecode.com/svn/trunk/jquery.flot.js"&gt;&lt;/script&gt; &lt;script language="javascript" src="http://flot.googlecode.com/svn/trunk/jquery.flot.navigate.js"&gt;&lt;/script&gt;  &lt;script language="javascript" type="text/javascript"&gt;
$(function () {
var mix2eq = new Array(
0,0,0,0,0,0,0,0,
0,0,0,5,2,1,11,11,
0,0,3,1570,2133,2229,2245,2136,
2120,2148,2187,2156,2152,2197,2116,2103,
2014,2022,2051,2044,2090,1986,2054,1937,
1970,1943,1935,1963,1913,1902,1972,1860,
1930,1940,1973,1873,1927,1950,1963,1888,
1974,1938,1873,1998,1985,1938,1862,1958,
1872,1945,1995,1957,1973,2054,1976,1935,
1990,2062,2178,2028,1989,1967,2063,2014,
1966,2010,2132,2064,2164,2132,2227,2407,
2956,3397,2957,2211,2075,2153,2143,2163,
2315,2423,2323,2281,2198,2371,2337,2543,
2949,2849,2536,2391,2461,2532,2503,2536,
2659,2625,2748,2826,2811,2874,3044,3024,
3041,3106,3116,3291,3376,3440,4140,5745,
6471,4665,3492,3260,3333,3237,3271,3309,
3492,3612,3872,3642,3520,3578,3651,3529,
3534,3649,3708,3636,3767,3913,4198,4286,
4787,8080,13779,12366,6815,4919,8797,18748,
20090,10539,4086,3181,3576,3750,3198,2912,
3185,3628,3164,2786,2704,2927,3763,4861,
4659,3738,3045,2832,3032,4314,6834,8387,
6550,3828,2921,3019,4437,5770,4921,3286,
2595,2989,5058,7895,8072,6003,4159,3067,
2857,2688,2383,2114,1989,2039,2175,2276,
2538,2500,2488,2518,2478,2219,2085,1891,
1901,2002,2043,2054,2001,2006,2124,2212,
2317,2541,2394,2192,2030,1937,2026,2151,
2225,2295,2295,2110,2122,2108,2114,2128,
2058,2212,2374,2237,2072,2086,1999,2196,
2148,2024,1914,1909,1915,1869,1876,1872,
1847,1977,1910,1865,1860,1909,1855,1954,
1922,1939,1901,1886,1881,1908,2006,2006,
1940,1898,1959,1894,1950,2029,2235,2860,
2918,2323,1989,1909,1913,1976,2010,1860,
1912,1932,1966,1920,1869,1948,1907,1930,
1911,1923,1952,1878,1962,1924,1934,1894,
1909,1963,1919,1903,1987,1895,2019,1856,
2045,2501,2709,2384,2003,1893,2028,1927,
1923,1876,1840,1898,1880,1919,1917,1897,
1897,1878,1869,1868,1907,1849,1881,1892,
2192,2492,2443,2044,1870,1915,1803,1850,
1738,1788,1880,1765,1858,1804,1715,1656,
1726,1753,1771,1647,1757,1740,1944,1977,
1901,1754,1671,1747,1627,1645,1724,1700,
1617,1654,1618,1644,1666,1651,1618,1643,
1574,1582,1601,1551,1650,1568,1602,1705,
1663,1588,1573,1580,1582,1593,1580,1645,
1524,1627,1551,1526,1569,1510,1557,1600,
1566,1613,1580,1601,1598,1578,1584,1685,
1914,3003,5717,7953,6616,3764,1869,1563,
1450,1461,1373,1427,1442,1367,1537,1399,
1497,1433,1461,1447,1499,1371,1414,1401,
1462,1459,1414,1391,1435,1392,1356,1398,
1407,1444,1561,1537,1349,1302,1367,1386,
1371,1331,1402,1371,1307,1386,1435,1526,
1643,1456,1407,1267,1245,1260,1376,1611,
2305,2622,2117,1490,1187,1247,1202,1231,
1196,1154,1209,1195,1157,1081,1219,1222,
1251,1216,1262,1177,1108,1078,1147,1070,
1167,1108,1109,1106,1183,1205,1161,1112,
1105,1147,1112,1116,1127,1096,1107,1114,
1055,1090,1069,1111,1096,1090,1105,1078,
1071,1056,1061,1106,1114,1061,1087,1136,
1164,1188,1144,1103,1163,1297,1562,1586,
1368,1350,2172,6333,14072,16593,9526,3160,
1528,1902,3113,5025,7796,7237,3850,1459,
989,873,887,876,811,919,846,905,
885,852,852,845,862,836,802,837,
874,827,871,875,863,867,832,813,
809,886,824,857,911,1076,1096,940,
807,913,1031,1276,1228,1004,823,766,
827,802,763,753,797,795,808,775,
827,663,750,741,770,767,757,738,
769,811,868,1227,1623,1970,1908,1631,
1274,1114,866,739,778,805,894,969,
952,1022,885,787,799,1072,1344,1157,
941,739,799,772,779,737,736,753,
751,744,748,749,798,712,759,688,
750,744,757,750,759,799,800,813,
782,736,683,706,674,701,716,699,
706,745,756,807,1159,2767,7943,14386,
13365,6526,2029,812,686,651,682,649,
739,983,1481,1565,1176,787,654,644,
693,647,662,614,627,638,646,637,
625,584,582,610,599,613,595,637,
592,549,600,600,582,593,603,585,
634,585,607,604,644,603,560,594,
612,555,544,548,558,523,611,594,
584,582,566,581,595,571,600,553,
622,704,702,658,634,571,556,574,
603,751,1079,1263,1178,805,658,715,
682,642,562,571,642,605,665,677,
635,619,617,612,563,596,578,599,
841,1463,2694,3430,2466,1270,668,574,
619,635,573,579,584,569,588,534,
573,567,564,537,539,529,583,577,
565,528,587,649,702,720,912,1782,
5099,13457,22788,20768,10230,2952,785,523,
472,511,455,494,476,508,438,477,
459,469,478,481,475,474,494,470,
457,436,465,491,457,493,520,476,
480,491,473,471,456,525,483,489,
465,491,491,428,442,474,449,460,
501,468,482,461,466,475,459,444,
480,491,461,457,475,459,470,426,
452,466,485,446,442,464,472,463,
472,430,433,415,488,493,445,451,
458,538,607,611,596,551,595,647,
660,555,520,506,507,456,430,469,
457,465,444,488,462,455,477,453,
451,434,498,457,460,469,494,472,
494,503,453,549,540,612,657,556,
460,444,492,508,559,563,589,545,
507,456,438,467,447,556,674,813,
766,587,471,426,472,466,477,457,
474,462,440,453,439,465,460,421,
441,479,446,448,445,465,453,457,
430,468,415,427,439,473,423,442,
411,426,451,460,453,479,409,458,
480,458,442,401,419,383,394,394,
391,378,365,407,353,344,369,340,
352,350,393,387,347,334,361,358,
350,349,367,349,369,357,383,380,
302,347,355,286,287,314,326,341,
366,364,378,319,349,333,343,311,
330,296,327,341,344,319,314,348,
354,340,397,395,387,359,367,384,
443,378,347,327,319,314,325,313,
330,343,303,350,319,320,382,356,
491,637,906,1027,813,513,319,289,
307,299,316,306,322,324,293,344,
325,334,362,341,338,297,305,305,
289,305,306,301,351,351,330,301,
290,305,272,265,324,301,292,327,
296,324,403,468,424,386,298,297,
270,267,287,284,287,296,301,290,
343,335,377,409,369,314,267,253,
285,268,264,280,264,308,242,287,
250,304,276,233,283,287,242,246,
278,231,271,248,259,286,250,254,
235,258,276,277,256,254,255,289,
262,284,281,242,236,276,260,289,
258,255,274,280,336,424,530,671,
1143,1419,1216,749,427,317,272,261,
264,251,212,279,242,254,244,266,
223,258,234,263,246,257,277,257,
211,232,243,234,269,260,243,281,
239,261,247,245,269,247,260,264,
247,236,257,242,260,235,275,271,
259,234,243,293,291,286,326,304,
277,260,235,246,243,258,278,251,
243,245,245,250,223,218,241,269,
233,256,223,287,250,237,280,241,
238,264,269,270,304,282,239,233,
267,253,275,233,240,224,251,233,
226,236,264,254,237,224,227,247,
253,255,247,226,236,234,233,261,
256,227,232,248,226,250,286,339,
345,365,302,265,249,265,251,233,
235,221,246,258,254,247,242,230,
253,247,235,250,271,235,236,271,
296,284,245,229,236,248,203,265,
248,210,243,256,199,230,259,290,
300,370,343,338,358,584,1274,2521,
3819,3642,2304,930,369,251,234,211,
257,239,244,229,195,255,218,203,
228,208,228,208,202,198,239,216,
219,222,233,216,220,226,225,225,
220,203,216,222,227,222,208,218,
207,253,265,234,217,218,253,231,
257,257,249,239,262,252,252,354,
549,1186,3086,7207,12366,14178,10139,4476,
1310,419,220,193,179,188,209,195,
190,185,202,224,207,202,202,214,
198,212,207,186,202,193,199,204,
178,177,170,205,182,189,204,189,
187,200,176,184,212,172,192,167,
216,181,198,202,186,233,177,188,
185,188,159,237,198,204,202,205,
190,197,186,173,183,168,189,186,
160,198,201,187,190,178,195,187,
188,199,210,192,177,218,194,176,
179,202,185,184,194,219,199,171,
215,171,174,204,176,185,203,190,
177,198,216,182,196,206,216,183,
192,197,202,170,183,188,196,210,
176,214,186,197,197,217,206,202,
187,183,199,267,306,425,558,551,
405,270,219,182,181,190,189,177,
182,195,204,192,196,196,158,182,
199,177,185,204,184,204,169,199,
166,195,183,203,191,209,192,170,
178,187,157,196,164,185,203,208,
206,190,176,171,192,169,161,199,
197,179,173,197,216,193,193,183,
151,167,178,180,166,175,207,211,
176,165,210,200,168,192,185,194,
195,173,206,213,196,195,189,219,
189,166,216,270,292,282,293,271,
191,198,185,218,185,182,183,193,
216,208,188,193,174,161,174,203,
190,178,198,167,172,169,177,177,
202,182,164,176,151,169,177,179,
167,184,189,238,273,224,186,199,
176,201,180,155,173,190,181,173,
196,208,307,464,733,945,787,492,
297,215,185,171,149,178,178,176,
165,185,155,181,173,171,161,159,
146,161,146,139,166,171,153,156,
165,159,179,167,208,180,177,192,
223,200,211,192,187,179,158,160,
171,170,159,161,150,154,159,153,
151,160,160,170,156,169,155,157,
163,203,172,175,207,233,231,223,
159,145,163,154,182,158,155,143,
140,161,172,148,160,157,160,204,
212,194,193,163,178,184,255,305,
308,442,748,1057,1218,1074,643,338,
226,180,193,174,263,296,253,202,
162,140,183,134,136,142,119,173,
155,152,156,141,164,148,129,122,
135,148,163,160,181,172,168,156,
177,210,312,400,503,485,334,216,
173,137,124,134,140,145,119,147,
137,134,133,128,155,166,171,274,
430,503,463,374,237,159,137,151,
152,142,155,148,118,130,121,138,
153,149,112,139,117,148,148,174,
163,188,308,382,366,288,201,135,
137,139,111,121,118,128,149,131,
121,143,131,129,141,114,121,117,
147,136,140,148,158,118,141,132,
127,137,113,141,145,163,172,145,
147,123,130,128,132,134,153,150,
162,156,148,152,130,129,119,129,
137,148,147,180,183,179,157,168,
164,156,173,154,139,178,235,253,
250,220,203,153,158,209,266,266,
263,285,224,214,162,147,147,127,
119,141,125,130,154,117,136,128,
138,133,122,121,118,113,118,139,
134,120,113,127,153,123,109,138,
135,119,124,127,144,131,117,132,
136,126,113,136,135,158,218,351,
479,505,429,264,186,152,116,117,
115,137,111,135,125,130,120,143,
127,116,135,131,116,126,127,138,
115,132,144,113,139,127,136,118,
138,146,128,148,123,129,115,135,
116,144,120,123,123,131,137,121,
124,128,130,116,140,133,131,147,
134,127,123,130,112,123,122,125,
140,129,124,126,128,112,140,144,
125,134,133,138,152,158,136,143,
125,151,127,130,123,145,137,112,
127,131,118,122,135,135,131,139,
138,135,136,160,159,160,186,188,
158,128,125,129,124,133,140,147,
176,233,445,789,1428,1995,2265,1681,
918,413,198,129,127,118,146,124,
117,120,111,112,117,104,104,101,
113,110,118,109,88,108,111,119,
99,92,99,118,101,117,102,114,
103,107,108,103,105,101,110,104,
152,124,102,132,117,120,145,185,
319,479,663,628,489,329,179,132,
96,91,99,77,98,99,113,128,
124,119,107,93,103,111,108,102,
100,114,106,119,111,94,122,115,
111,126,119,98,91,89,119,112,
105,102,104,105,106,103,89,114,
108,98,104,97,114,112,109,112,
108,133,129,129,103,123,95,122,
111,99,99,105,119,165,233,317,
410,486,453,328,218,173,173,253,
416,700,1121,1266,1161,724,358,211,
112,96,107,85,89,94,89,96,
102,96,95,102,113,108,99,91,
98,87,94,94,112,101,107,87,
102,104,111,103,85,107,88,84,
98,97,95,104,101,105,91,102,
99,111,93,99,91,90,94,97,
108,78,88,99,83,92,88,120,
100,95,91,108,88,90,96,105,
89,130,134,167,235,271,224,193,
140,104,100,105,90,82,74,89,
87,97,84,96,91,95,104,102,
94,77,71,88,91,99,94,92,
91,91,71,109,85,92,98,108,
105,85,78,86,82,79,89,87,
89,77,108,86,84,87,91,85,
74,85,84,91,77,83,84,82,
79,94,82,86,110,85,96,84,
86,89,89,97,99,98,110,106,
89,89,99,91,70,91,85,77,
78,69,75,95,85,86,81,86,
95,83,82,84,85,77,74,89,
83,81,95,80,69,88,78,100,
87,71,93,81,91,92,82,84,
86,126,121,155,111,104,92,81,
75,83,60,83,77,74,91,77,
81,78,81,91,84,69,91,70,
72,82,94,104,104,88,100,87,
95,115,87,89,89,82,85,86,
72,94,102,120,132,105,114,83,
89,100,77,86,107,93,72,72,
85,86,80,81,67,78,76,104,
97,102,94,98,79,73,75,68,
85,75,84,77,80,83,82,65,
94,74,86,86,80,98,88,77,
76,80,88,70,70,69,93,81,
84,92,110,120,117,107,114,82,
89,88,72,88,67,76,65,81,
94,62,82,78,67,72,89,86,
90,99,99,103,85,88,79,77,
76,93,81,88,73,73,85,100,
104,102,118,93,91,81,89,75,
81,86,80,76,85,101,105,80,
103,135,169,231,352,589,1144,1839,
2197,2183,1497,856,355,187,108,78,
95,67,86,71,72,76,67,65,
81,79,79,80,65,84,71,87,
89,93,68,93,84,88,97,117,
117,99,84,88,79,83,70,77,
83,78,60,86,72,75,66,66,
85,76,72,66,70,75,71,77,
82,87,88,95,70,75,69,76,
73,82,63,63,64,86,93,81,
76,87,92,83,111,136,167,233,
262,332,275,217,137,93,77,76,
88,65,75,68,70,68,81,78,
59,81,71,73,75,87,78,81,
78,81,54,71,88,71,73,78,
82,63,86,66,70,73,66,72,
75,87,82,71,73,79,80,82,
78,75,87,66,77,72,72,74,
79,55,75,77,69,98,94,101,
97,76,82,70,65,63,75,77,
66,74,75,78,69,80,48,75,
64,73,50,66,71,71,79,68,
61,88,69,61,62,71,69,63,
75,64,65,85,84,76,83,68,
61,72,66,60,67,95,74,65,
62,73,88,69,62,63,69,101,
108,120,108,114,90,81,78,72,
66,60,66,70,54,69,75,73,
59,64,65,60,54,64,67,71,
73,67,68,87,87,72,71,70,
65,74,72,74,56,62,77,76,
67,72,72,62,80,79,72,68,
90,61,72,77,72,69,67,74,
67,52,67,79,73,74,78,81,
70,91,121,130,209,287,502,681,
831,727,606,326,176,91,75,60,
77,52,70,61,64,69,75,88,
73,73,69,94,99,75,84,82,
79,71,85,79,66,77,86,66,
69,93,95,109,100,90,93,76,
81,69,67,64,65,56,68,61,
72,76,53,58,69,57,67,67,
52,75,67,53,68,67,58,77,
56,50,55,56,57,60,75,65,
63,75,60,66,65,79,69,66,
60,76,80,73,76,78,69,77,
62,68,63,59,78,68,75,91,
110,169,188,218,257,174,129,95,
63,72,62,67,59,69,65,76,
64,67,58,83,58,50,64,47,
64,53,60,54,82,65,54,57,
71,55,62,54,61,51,56,57,
64,57,60,75,56,43,59,69,
52,51,46,63,71,69,61,70,
76,68,64,64,52,57,58,56,
67,75,53,66,60,57,57,69,
61,43,60,59,64,74,73,53,
50,60,76,63,67,61,71,61,
67,43,60,57,56,55,49,58,
63,60,56,56,50,55,78,66,
59,55,65,63,66,64,75,60,
58,58,76,50,53,41,61,58,
67,60,49,66,56,55,53,54,
77,75,56,67,61,61,63,42,
49,56,50,55,57,58,69,70,
52,79,63,60,64,51,58,62,
61,44,62,48,46,60,51,55,
49,65,64,64,61,50,54,65,
44,70,66,57,68,66,62,67,
62,56,52,51,60,51,65,70,
55,54,57,60,65,64,46,56,
71,59,59,61,51,59,54,55,
53,60,55,54,59,62,57,65,
63,51,53,62,61,53,69,66,
64,70,85,85,93,113,190,231,
362,527,551,551,415,247,151,88,
49,64,59,65,68,39,53,64,
87,92,110,130,154,118,118,79,
60,68,68,69,78,53,77,58,
55,44,63,60,65,51,62,53,
60,61,57,48,65,46,72,66,
46,61,71,67,74,86,116,150,
173,247,217,175,123,71,71,62,
67,61,62,71,122,150,210,307,
347,296,220,167,89,78,55,43,
71,54,51,66,53,47,52,58,
56,63,58,60,58,55,49,63,
63,60,59,59,48,58,65,45,
57,56,44,51,65,67,58,58,
70,63,62,61,54,57,51,58,
47,48,65,52,60,56,53,83,
63,50,70,57,44,63,63,50,
56,52,61,62,41,63,56,61,
59,58,61,61,53,46,55,72,
57,63,51,53,61,55,39,55,
32,53,64,55,60,61,52,58,
69,56,55,73,47,65,46,50,
53,60,55,70,64,53,63,53,
44,56,70,87,104,121,145,184,
240,306,351,293,239,179,90,74,
59,54,46,64,48,52,47,63,
63,54,45,51,53,41,50,66,
56,46,54,52,50,63,51,63,
44,58,63,53,70,52,42,61,
68,57,56,65,56,67,75,62,
52,54,55,47,59,54,65,46,
40,57,50,58,57,51,54,41,
56,53,47,58,63,71,55,65,
48,47,50,64,53,62,76,58,
67,75,85,103,110,82,70,63,
67,55,56,60,60,76,75,79,
66,62,70,79,61,59,56,53,
53,64,67,67,93,109,118,180,
212,242,286,241,157,119,93,85,
61,85,86,65,80,62,53,61,
55,45,63,51,61,59,51,59,
39,55,50,61,47,54,59,61,
60,60,53,54,57,54,53,54,
53,71,56,46,58,74,53,48,
68,63,57,63,53,51,61,60,
62,56,64,66,60,63,36,51,
75,66,73,74,77,108,91,94,
75,71,65,55,67,74,87,92,
98,94,75,60,49,56,54,47,
45,39,57,37,48,40,44,50,
52,45,37,33,48,54,45,50,
37,40,39,54,31,41,48,59,
65,34,31,34,44,45,47,58,
53,36,46,43,47,44,34,48,
44,49,42,50,39,56,43,42,
44,36,27,39,47,35,54,44,
35,36,31,37,40,37,36,48,
56,42,44,42,30,34,54,43,
42,41,40,50,49,76,74,77,
68,68,65,94,98,114,103,74,
58,58,63,61,72,103,131,164,
175,150,123,96,71,63,78,97,
102,116,123,99,104,83,84,70,
62,51,49,53,53,39,49,48,
68,73,69,62,51,37,48,36,
42,37,33,39,38,33,38,39,
34,42,31,53,42,47,40,40,
40,37,39,43,37,38,36,42,
35,21,46,46,29,41,28,34,
31,32,30,46,46,42,31,49,
58,72,86,103,81,72,40,56,
48,33,31,43,37,57,49,51,
32,34,33,30,39,43,65,65,
87,87,110,77,68,49,45,31,
26,32,36,25,27,26,37,38,
30,38,46,57,52,37,32,45,
23,23,28,25,35,35,21,33,
23,28,22,16,29,32,23,30,
26,26,29,21,26,24,17,18,
22,28,21,22,32,27,28,26,
28,34,39,26,29,30,42,30,
30,30,30,43,60,60,76,99,
122,117,123,71,51,33,27,19,
27,24,33,42,30,26,22,28,
18,20,24,24,23,28,24,34,
26,24,22,24,26,14,21,23,
16,20,30,19,25,23,35,22,
24,30,33,26,30,34,30,27,
21,28,41,33,45,42,42,35,
36,30,31,33,23,24,31,24,
23,26,35,24,30,36,30,42,
46,33,53,38,38,31,32,24,
18,25,29,23,21,26,26,24,
27,23,23,31,20,24,29,19,
29,26,17,23,22,19,21,18,
24,17,25,15,21,22,21,19,
12,44,13,23,27,22,20,21,
20,28,22,19,32,32,22,17,
27,19,24,18,21,19,19,27,
12,23,18,15,16,17,22,22,
22,26,27,32,43,21,41,42,
58,84,108,188,243,317,339,312,
252,159,85,46,25,25,26,24,
19,19,19,25,26,30,24,23,
17,31,21,19,17,29,15,21,
18,28,21,21,18,20,28,25,
17,29,21,15,24,26,24,20,
22,31,73,1237,11964,35303,31302,8153,
689,61,34,30,33,20,30,32,
24,22,27,23,20,34,21,31,
32,37,27,42,40,68,88,102,
149,228,348,546,830,1105,1400,1452,
1250,921,489,228,79,53,24,20,
13,31,25,18,23,23,18,16,
17,21,18,20,22,24,23,23,
13,29,26,19,19,23,24,20,
24,20,16,19,27,13,22,19
);
var d = [];
var d1_abs = [];
var d2 = [];
var d_cut = [];
var ecal= [8.0939751E+000, 4.3677204E-001];
var d1_limit = 10;
var d2_limit = -50;
var peak_channels = "";

for( var i = 0; i &lt; mix2eq.length; i++ )
{
  d.push( [i+1, mix2eq[i]] );
}
for( var i = 0; i &lt; mix2eq.length-1; i++ )
{
  d1_abs.push( [i+1, Math.abs(mix2eq[i+1] - mix2eq[i])] );
}
for( var i = 1; i &lt; mix2eq.length-1; i++ )
{
  var derivative2 = mix2eq[i+1] - 2 * mix2eq[i] + mix2eq[i-1];
  d2.push( [i+1, derivative2] );
}

function getDCut()
{
  d_cut = [];
  peak_channels = ""
  for( var i = 0; i &lt; d2.length-1; i++ )
  {
    if( (d1_abs[i][1] &lt; d1_limit) &amp;&amp; (d2[i][1] &lt; d2_limit) )
    {
        d_cut.push( [i, d2[i][1]] );
        peak_channels += ", " + (i+1);
    }
  }
}

var options = {
        series: { bars: { show: true, fill: true } },
        bars: { barWidth: 1.0 },        
        xaxis: { min: 0,
                 zoomRange: [0, 4096],
                 panRange: [0, 4096],
                 color: "#000000" },
        yaxis: { min: 0,
                 zoomRange: [0, null],
                 panRange: [0, null],
                 color: "#000000" },
        zoom: { interactive: true },
        pan: { interactive: true },
        colors: ["#FF0000"]
    };
$.plot($("#spectrum"),[ d ],options);

var options_2nd = {
        series: { bars: { show: true, fill: true } },
        bars: { barWidth: 1.0 },        
        xaxis: { min: 0,
                 zoomRange: [0, 4096],
                 panRange: [0, 4096],
                 color: "#000000" },
        yaxis: { zoomRange: [null, null],
                 panRange: [null, null],
                 color: "#000000" },
        zoom: { interactive: true },
        pan: { interactive: true },
        colors: ["#0000FF"]
    };

getDCut();

$.plot($("#spectrum_2nd"),[ d_cut ],options_2nd);

function writeList()
{
  var list = "Here is the list of the channels that fulfills the above criteria: " + peak_channels.substr(1);
  $("#list").html(list);
}

writeList();

  $("#slider-range-d1").slider({
   value: 10,
   min: 1,
   max: 10000,
   slide: function(event, ui) {
    $("#d1_limit").val(""+ui.value);
                                d1_limit = ui.value;
                                getDCut();
                                writeList();
                                $.plot($("#spectrum_2nd"),[ d_cut ],options_2nd);
   }
  });
  $("#d1_limit").val($("#slider-range-d1").slider("value"));

  $("#slider-range-d2").slider({
   value: -50,
   min: -10000,
   max: -1,
   slide: function(event, ui) {
    $("#d2_limit").val(""+ui.value);
                                d2_limit = ui.value;
                                getDCut();
                                writeList();
                                $.plot($("#spectrum_2nd"),[ d_cut ],options_2nd);
   }
  });
  $("#d2_limit").val($("#slider-range-d2").slider("value"));
});
&lt;/script&gt;

&lt;p&gt;

The dynamic updating of the plot demonstrated above may not be necessary for your application. As it is implemented here, it may cause a bad flickering effect especially on slower computers.
&lt;/p&gt;&lt;p&gt;

This post contained one example of how peaks may be located in a high resolution gamma-ray energy spectrum. The interested reader may find the following list of references useful for further study:
&lt;/p&gt;&lt;ul&gt;
&lt;li&gt;A. Likar and T. Vidmar; "&lt;a href="http://iopscience.iop.org/0022-3727/36/15/323" target="_blank"&gt;A peak-search method based on spectrum convolution&lt;/a&gt;"; J. Phys. D: Appl. Phys. &lt;b&gt;36&lt;/b&gt; (2003) 1903–1909.&lt;/li&gt;
&lt;li&gt;K. Debertin and R. Helmer; "&lt;a href="http://www.amazon.com/gp/product/0444871071?ie=UTF8&amp;tag=httpwelcometopet&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=0444871071" target="_blank"&gt;Gamma- and X-Ray Spectrometry with Semiconductor Detectors&lt;/a&gt;"; North-Holland, 1988. ISBN-10: 0444871071, ISBN-13: 978-0444871077&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2574712085639993348-1758432055844000492?l=blog.p-jansson.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/rnvbV8ebTwNksL_RwINzXjchp7s/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/rnvbV8ebTwNksL_RwINzXjchp7s/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/rnvbV8ebTwNksL_RwINzXjchp7s/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/rnvbV8ebTwNksL_RwINzXjchp7s/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JanssonConsulting/~4/Yo4EvmxFytc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.p-jansson.com/feeds/1758432055844000492/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.p-jansson.com/2010/07/peak-search-in-gamma-ray-energy.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/1758432055844000492?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/1758432055844000492?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/JanssonConsulting/~3/Yo4EvmxFytc/peak-search-in-gamma-ray-energy.html" title="Peak search in a gamma-ray energy spectrum" /><author><name>Peter Jansson</name><uri>http://www.blogger.com/profile/02543155564076384235</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_icY8aPexjCA/Sp63XsM3SLI/AAAAAAAAANI/VcVhqbw706A/s1600-R/AIbEiAIAAABECOP5xtyUoozZhwEiC3ZjYXJkX3Bob3RvKihhMWUwZmY4MTQzM2JhYjcxMmQ5OWYzMTY0N2YyZjk1MTExOGNhMzczMAFvd8hrPIJ5oYco5_oUBeY2wGftgA" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.p-jansson.com/2010/07/peak-search-in-gamma-ray-energy.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D04BQX86cSp7ImA9Wx5TE0k.&quot;"><id>tag:blogger.com,1999:blog-2574712085639993348.post-1993735024840273151</id><published>2010-07-27T23:22:00.004+02:00</published><updated>2010-07-28T21:39:10.119+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-07-28T21:39:10.119+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Safeguards" /><title>Safeguards Glossary</title><content type="html">&lt;p&gt;Ever wondered what all those (nuclear) Safeguards words mean and really have no one to ask?&lt;/p&gt;
&lt;p&gt;Don't worry, be happy, the International Atomic Energy Agency (&lt;a href="http://www.iaea.org" target="_blank"&gt;IAEA&lt;/a&gt;) has put together a report in 2001 with a Safeguards Glossary that you can read &lt;a href="http://www-pub.iaea.org/MTCD/publications/PDF/NVS3_scr.pdf" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;!--
&lt;iframe width="600" height="730" src="http://www-pub.iaea.org/MTCD/publications/PDF/NVS3_scr.pdf"&gt;&lt;/iframe&gt;
--&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2574712085639993348-1993735024840273151?l=blog.p-jansson.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/1LZbLNtx_jq06gU0_FT6eHlmZf4/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/1LZbLNtx_jq06gU0_FT6eHlmZf4/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/1LZbLNtx_jq06gU0_FT6eHlmZf4/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/1LZbLNtx_jq06gU0_FT6eHlmZf4/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JanssonConsulting/~4/O7e_SD8qzOw" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.p-jansson.com/feeds/1993735024840273151/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.p-jansson.com/2010/07/safeguards-glossary.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/1993735024840273151?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/1993735024840273151?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/JanssonConsulting/~3/O7e_SD8qzOw/safeguards-glossary.html" title="Safeguards Glossary" /><author><name>Peter Jansson</name><uri>http://www.blogger.com/profile/02543155564076384235</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_icY8aPexjCA/Sp63XsM3SLI/AAAAAAAAANI/VcVhqbw706A/s1600-R/AIbEiAIAAABECOP5xtyUoozZhwEiC3ZjYXJkX3Bob3RvKihhMWUwZmY4MTQzM2JhYjcxMmQ5OWYzMTY0N2YyZjk1MTExOGNhMzczMAFvd8hrPIJ5oYco5_oUBeY2wGftgA" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.p-jansson.com/2010/07/safeguards-glossary.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkQHSHwzcCp7ImA9WxFaGUQ.&quot;"><id>tag:blogger.com,1999:blog-2574712085639993348.post-5318809090656649024</id><published>2010-07-24T17:19:00.003+02:00</published><updated>2010-07-24T18:52:19.288+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-07-24T18:52:19.288+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Boost" /><category scheme="http://www.blogger.com/atom/ns#" term="Asio" /><category scheme="http://www.blogger.com/atom/ns#" term="IPv6" /><title>Running out of IP v4 numbers.</title><content type="html">&lt;p&gt;As you may know, the number of available IP version 4 numbers are rapidly approaching zero. &lt;a href="http://twitter.com/IPv4Countdown" target="_blank"&gt;Some estimates&lt;/a&gt; that there is less than one year until the numbers run out. The American Registry for Internet Numbers (&lt;a href="https://www.arin.net/" target="_blank"&gt;ARIN&lt;/a&gt;) have produced &lt;a href="https://www.arin.net/knowledge/v4_deplete_v6_adopt.ppt"&gt;presentation material&lt;/a&gt; that can be used to spread the word about this issue. I would recommend you to influence your local internet service provider to take action to use IP version 6 if it is not already in place.&lt;/p&gt;
&lt;p&gt;
For an application developer involved in programming for communications over the wire, the future will most certainly contain requirements on software to be able to work over both IP v4 and v6.
If you are into Boost; The &lt;a href="http://www.boost.org/doc/libs/1_43_0/doc/html/boost_asio.html" target="_blank"&gt;Boost::Asio&lt;/a&gt; library provides a nice interface which is transparent with regards to what version of IP is used. The class &lt;a href="http://www.boost.org/doc/libs/1_43_0/doc/html/boost_asio/reference/ip__address.html" target="_blank"&gt;boost::asio::ip::address&lt;/a&gt; implements version-independent IP addresses.&lt;/p&gt;
&lt;p&gt;
Here are some articles from elsewhere on this issue:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/IPv4_address_exhaustion" target="_blank"&gt;IPv4 address exhaustion&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/IPv6#Transition_mechanisms" target="_blank"&gt;IPv6: Transition mechanisms&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.ipv4depletion.com/" target="_blank"&gt;The IPv4 Depletion site&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.ipv6actnow.org/" target="_blank"&gt;IPv6 Act Now!&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/p&gt;
&lt;div align="center"&gt;
&lt;script language="javascript" src="http://inetcore.com/project/ipv4ec/en-us/wolf_c.js" type="text/javascript"&gt;
&lt;/script&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2574712085639993348-5318809090656649024?l=blog.p-jansson.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/Wccuciwz8ukllnUk3UQSpjIW9mg/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Wccuciwz8ukllnUk3UQSpjIW9mg/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/Wccuciwz8ukllnUk3UQSpjIW9mg/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Wccuciwz8ukllnUk3UQSpjIW9mg/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JanssonConsulting/~4/EQ-G9-RttGU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.p-jansson.com/feeds/5318809090656649024/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.p-jansson.com/2010/07/running-out-of-ip-v4-numbers.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/5318809090656649024?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/5318809090656649024?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/JanssonConsulting/~3/EQ-G9-RttGU/running-out-of-ip-v4-numbers.html" title="Running out of IP v4 numbers." /><author><name>Peter Jansson</name><uri>http://www.blogger.com/profile/02543155564076384235</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_icY8aPexjCA/Sp63XsM3SLI/AAAAAAAAANI/VcVhqbw706A/s1600-R/AIbEiAIAAABECOP5xtyUoozZhwEiC3ZjYXJkX3Bob3RvKihhMWUwZmY4MTQzM2JhYjcxMmQ5OWYzMTY0N2YyZjk1MTExOGNhMzczMAFvd8hrPIJ5oYco5_oUBeY2wGftgA" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.p-jansson.com/2010/07/running-out-of-ip-v4-numbers.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A04AQH4-fip7ImA9WhRWEUg.&quot;"><id>tag:blogger.com,1999:blog-2574712085639993348.post-3273952189729387104</id><published>2010-07-06T19:27:00.000+02:00</published><updated>2011-12-29T12:59:01.056+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-29T12:59:01.056+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="PHP" /><title>Using the FileManager PHP class</title><content type="html">&lt;p&gt;Today, I had reasons for needing a file manager on one of the web sites that I maintain. The requirements on the file manager were as follows: &lt;/p&gt;&lt;ul&gt;&lt;li&gt;To enable upload and download of files from/to the hard drive of the client.&lt;/li&gt;
&lt;li&gt;To enable deletion and renaming of files on the web server.&lt;/li&gt;
&lt;li&gt;To enable folder creation and deletion on the web server.&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;After some research using a popular search engine, I ended up downloading the PHP application &lt;a href="http://www.gerd-tentler.de/tools/filemanager/" target="_blank"&gt;FileManager&lt;/a&gt;. This is a PHP class that uses AJAX techniques for communication between the client and the web server. &lt;/p&gt;&lt;p&gt;A quote from the readme file in the distribution: &lt;blockquote&gt;Use this software to manage files and directories on your webserver or on an FTP server. You can create, rename and delete directories, upload, download, edit, rename, delete and search files, and change file and directory permissions&lt;/blockquote&gt;&lt;/p&gt;&lt;p&gt;So, it seemed as though all the requirements should be fulfilled using FileManager. Installation was relatively easy: &lt;/p&gt;&lt;ol&gt;&lt;li&gt;Unzip an archive and copy the contents to some location on the web server.&lt;/li&gt;
&lt;li&gt;Configure the default behavior of the FileManager class using a config file.&lt;/li&gt;
&lt;li&gt;Set some directory permissions.&lt;/li&gt;
&lt;li&gt;Edit the page or pages where you want to have the functionality, include the FileManager.php class and create an instance of it. Make sure that you don't prematurely change the header information sent by PHP before you create a FileManager instance.&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;Objects of the FileManager class can be instantiated with an argument specifying the root folder of the hierarchy that you want to publish. In this way, it is relatively easy to have various root's depending on who is calling the PHP script. &lt;/p&gt;&lt;p&gt;I did came across one obstacle with the FileManager. I was using a specialized session handler on the web site that did not function well in cooperating with the FileManager's use of session cookies. So, I had to skip the special session handler and use the default one for the pages including the FileManager functionality. This was not a big loss since they could be nicely integrated into IFRAME's and using the normal session handling used for the rest of site was not needed. &lt;/p&gt;&lt;p&gt;I would recommend using the FileManager class for anybody with the same requirements as specified above. &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2574712085639993348-3273952189729387104?l=blog.p-jansson.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/tbmIuXhUeAdq7tCzipvG-YXTXRY/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/tbmIuXhUeAdq7tCzipvG-YXTXRY/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/tbmIuXhUeAdq7tCzipvG-YXTXRY/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/tbmIuXhUeAdq7tCzipvG-YXTXRY/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JanssonConsulting/~4/zWDTRVYfkgs" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.p-jansson.com/feeds/3273952189729387104/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.p-jansson.com/2010/07/using-filemanager-php-class.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/3273952189729387104?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/3273952189729387104?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/JanssonConsulting/~3/zWDTRVYfkgs/using-filemanager-php-class.html" title="Using the FileManager PHP class" /><author><name>Peter Jansson</name><uri>http://www.blogger.com/profile/02543155564076384235</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_icY8aPexjCA/Sp63XsM3SLI/AAAAAAAAANI/VcVhqbw706A/s1600-R/AIbEiAIAAABECOP5xtyUoozZhwEiC3ZjYXJkX3Bob3RvKihhMWUwZmY4MTQzM2JhYjcxMmQ5OWYzMTY0N2YyZjk1MTExOGNhMzczMAFvd8hrPIJ5oYco5_oUBeY2wGftgA" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.p-jansson.com/2010/07/using-filemanager-php-class.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A04BQn8zeCp7ImA9WhRWEUg.&quot;"><id>tag:blogger.com,1999:blog-2574712085639993348.post-3815256572028828754</id><published>2010-06-15T19:31:00.008+02:00</published><updated>2011-12-29T12:59:13.180+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-29T12:59:13.180+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Boost" /><category scheme="http://www.blogger.com/atom/ns#" term="Executables" /><category scheme="http://www.blogger.com/atom/ns#" term="Asio" /><category scheme="http://www.blogger.com/atom/ns#" term="C++" /><category scheme="http://www.blogger.com/atom/ns#" term="NTP" /><title>NTP client in C++ using boost::asio, Windows build</title><content type="html">&lt;p&gt;In a &lt;a href="http://blog.p-jansson.com/2010/03/ntp-client-using-boostasio.html"&gt;previous post&lt;/a&gt;, I published some code for a client NTP that can write the current date and time on standard output. Now, it has been compiled for Windows and you can download it &lt;a href="http://docs.google.com/uc?id=0B-8USLEBlbnrOWExZTNjNWMtYTIxNy00Y2QyLWEwYWUtYzQ1YjJmNjQ1YzZj&amp;export=download"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;The program was built with MinGW that includes g++ version 4.4.0 and using Boost version 1.43 with multithreading and static linking. The &lt;code&gt;_WIN32_WINNT&lt;/code&gt; variable is defined to be &lt;code&gt;0x0501&lt;/code&gt; which indicates that the program is built for a Windows XP target. The command line used was: &lt;/p&gt;&lt;pre class="prettyprint"&gt;g++ -D_WIN32_WINNT=0x0501 -s -O2 NtpClient.cpp -o NtpClient.exe \
   -IC:/Boost/include/boost-1_43 \
   -LC:/Boost/lib \
   -lboost_date_time-mgw44-mt-s-1_43 \
   -lboost_system-mgw44-mt-s-1_43 \
   -lwsock32 \
   -lws2_32
&lt;/pre&gt;&lt;/p&gt;&lt;p&gt;Of course, you have to copy and paste the code from the &lt;a href="http://blog.p-jansson.com/2010/03/ntp-client-using-boostasio.html"&gt;previous post&lt;/a&gt; into the file NtpClient.cpp  :-) &lt;/p&gt;&lt;br /&gt;
&lt;style type="text/css"&gt;
@import url("http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.css");
pre.prettyprint { background: rgb(220,220,220);
&lt;/style&gt;&lt;br /&gt;
&lt;script src="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js" type="text/javascript"&gt;&lt;/script&gt;&lt;br /&gt;
&lt;script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"&gt;&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"&gt;$(document).ready(function(){prettyPrint();});&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2574712085639993348-3815256572028828754?l=blog.p-jansson.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/Xm5mJLtTxOFCjDapLnk7zhzQUg4/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Xm5mJLtTxOFCjDapLnk7zhzQUg4/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/Xm5mJLtTxOFCjDapLnk7zhzQUg4/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Xm5mJLtTxOFCjDapLnk7zhzQUg4/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JanssonConsulting/~4/BiUJN6xk9BM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.p-jansson.com/feeds/3815256572028828754/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.p-jansson.com/2010/06/ntp-client-in-c-using-boostasio-windows.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/3815256572028828754?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/3815256572028828754?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/JanssonConsulting/~3/BiUJN6xk9BM/ntp-client-in-c-using-boostasio-windows.html" title="NTP client in C++ using boost::asio, Windows build" /><author><name>Peter Jansson</name><uri>http://www.blogger.com/profile/02543155564076384235</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_icY8aPexjCA/Sp63XsM3SLI/AAAAAAAAANI/VcVhqbw706A/s1600-R/AIbEiAIAAABECOP5xtyUoozZhwEiC3ZjYXJkX3Bob3RvKihhMWUwZmY4MTQzM2JhYjcxMmQ5OWYzMTY0N2YyZjk1MTExOGNhMzczMAFvd8hrPIJ5oYco5_oUBeY2wGftgA" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.p-jansson.com/2010/06/ntp-client-in-c-using-boostasio-windows.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A04CSH84fip7ImA9WhRWEUg.&quot;"><id>tag:blogger.com,1999:blog-2574712085639993348.post-6455121874186598405</id><published>2010-05-11T16:10:00.008+02:00</published><updated>2011-12-29T12:59:29.136+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-29T12:59:29.136+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Asio" /><category scheme="http://www.blogger.com/atom/ns#" term="C++" /><category scheme="http://www.blogger.com/atom/ns#" term="NTP" /><title>NTP client in C++ using boost::asio</title><content type="html">&lt;p&gt;For your convenience, I wrote a simple NTP client using nothing but standard C++ and the &lt;a href="http://www.boost.org/" target="_blank"&gt;boost::asio&lt;/a&gt; library. The code for it is attached below. Using the static method NtpClient::GetTime(), the current time as reported by &lt;a href="http://www.pool.ntp.org/" target="_blank"&gt;pool.ntp.org&lt;/a&gt; is retreaved as in the following program: &lt;/p&gt;&lt;pre class="prettyprint lang-cpp"&gt;#include &amp;lt;iostream&amp;gt;
#include "NtpClient.hpp"
#include &amp;lt;boost/date_time/posix_time/posix_time.hpp&amp;gt; // Need I/O.
int main(int argc,char** argv)
{
   if( 1 == argc )
   {
      std::cout &amp;lt;&amp;lt; NtpClient::GetTime() &amp;lt;&amp;lt; '\n';
   }
   else if( 2 == argc )
   {
      std::cout &amp;lt;&amp;lt; NtpClient::GetTime( argv[1] ) &amp;lt;&amp;lt; '\n';
   }
   else
   {
      std::cerr
        &amp;lt;&amp;lt; "Usage: " &amp;lt;&amp;lt; argv[0]
        &amp;lt;&amp;lt; " NTP-server\n  NTP-server is pool.ntp.org if not specified\n";
      return 1;
   }
   return 0;
}
&lt;/pre&gt;&lt;p&gt;The NtpClient class is coded as follows: &lt;/p&gt;&lt;pre class="prettyprint lang-cpp"&gt;// NTP client uaing Boost::Asio.
// 2010-05-11
// Jansson Consulting
// http://www.p-jansson.com
// Dedicated to the Public Domain.
#ifndef NTPCLIENT_HPP
#define NTPCLIENT_HPP
#include &amp;lt;boost/asio.hpp&amp;gt;
#include &amp;lt;boost/date_time/posix_time/posix_time_types.hpp&amp;gt;
class NtpClient
{
   public:
      static boost::posix_time::ptime GetTime()
      {
         return GetTime("pool.ntp.org");
      };
      static boost::posix_time::ptime GetTime( const char* ntpServer )
      {
         using boost::asio::ip::udp;
         boost::asio::io_service io_service;

         udp::resolver resolver(io_service);
         udp::resolver::query query(udp::v4(), ntpServer, "ntp");
         udp::endpoint receiver_endpoint = *resolver.resolve(query);

         udp::endpoint sender_endpoint;

         boost::uint8_t data[48] = {
            0x1B,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
            0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
         };

         udp::socket socket(io_service);
         socket.open(udp::v4());

         socket.send_to(
               boost::asio::buffer(data),
               receiver_endpoint);
         socket.receive_from(
               boost::asio::buffer(data),
               sender_endpoint);

         typedef boost::uint32_t u32;
         const u32 iPart(
               static_cast&amp;lt;u32&amp;gt;(data[40]) &amp;lt;&amp;lt; 24
               | static_cast&amp;lt;u32&amp;gt;(data[41]) &amp;lt;&amp;lt; 16
               | static_cast&amp;lt;u32&amp;gt;(data[42]) &amp;lt;&amp;lt; 8
               | static_cast&amp;lt;u32&amp;gt;(data[43])
               );
         const u32 fPart(
               static_cast&amp;lt;u32&amp;gt;(data[44]) &amp;lt;&amp;lt; 24
               | static_cast&amp;lt;u32&amp;gt;(data[45]) &amp;lt;&amp;lt; 16
               | static_cast&amp;lt;u32&amp;gt;(data[46]) &amp;lt;&amp;lt; 8
               | static_cast&amp;lt;u32&amp;gt;(data[47])
               );

         using namespace boost::posix_time;
         const ptime pt(
               boost::gregorian::date(1900,1,1),
               milliseconds(
                  iPart * 1.0E3
                  + fPart * 1.0E3 / 0x100000000ULL )
               );
         return pt;
      };
};
#endif
&lt;/pre&gt;&lt;p&gt;When linking, you have to include the boost_date_time and boost_system libraries. &lt;/p&gt;&lt;i&gt;Update 2010-06-15:&lt;/i&gt; I have built this program for Microsoft Windows in &lt;a href="http://blog.p-jansson.com/2010/06/ntp-client-in-c-using-boostasio-windows.html"&gt;another post&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;style type="text/css"&gt;
@import url("http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.css");
pre.prettyprint { background: rgb(220,220,220);
&lt;/style&gt;&lt;br /&gt;
&lt;script src="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js" type="text/javascript"&gt;&lt;/script&gt;&lt;br /&gt;
&lt;script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"&gt;&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"&gt;$(document).ready(function(){prettyPrint();});&lt;/script&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/2574712085639993348-6455121874186598405?l=blog.p-jansson.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/KjF0MhzNvMcAaWCauN-PAjGr6Hc/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/KjF0MhzNvMcAaWCauN-PAjGr6Hc/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/KjF0MhzNvMcAaWCauN-PAjGr6Hc/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/KjF0MhzNvMcAaWCauN-PAjGr6Hc/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JanssonConsulting/~4/rWOKtJEemNw" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.p-jansson.com/feeds/6455121874186598405/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.p-jansson.com/2010/03/ntp-client-using-boostasio.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/6455121874186598405?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/6455121874186598405?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/JanssonConsulting/~3/rWOKtJEemNw/ntp-client-using-boostasio.html" title="NTP client in C++ using boost::asio" /><author><name>Peter Jansson</name><uri>http://www.blogger.com/profile/02543155564076384235</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_icY8aPexjCA/Sp63XsM3SLI/AAAAAAAAANI/VcVhqbw706A/s1600-R/AIbEiAIAAABECOP5xtyUoozZhwEiC3ZjYXJkX3Bob3RvKihhMWUwZmY4MTQzM2JhYjcxMmQ5OWYzMTY0N2YyZjk1MTExOGNhMzczMAFvd8hrPIJ5oYco5_oUBeY2wGftgA" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.p-jansson.com/2010/03/ntp-client-using-boostasio.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0cESX08cSp7ImA9WxFQEUU.&quot;"><id>tag:blogger.com,1999:blog-2574712085639993348.post-2235008774139593925</id><published>2010-05-06T23:19:00.001+02:00</published><updated>2010-05-06T23:23:28.379+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-05-06T23:23:28.379+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="C++" /><title>Boost C++ Libraries version 1.43 released</title><content type="html">Just for your information: On May 6, 2010, version 1.43 of the &lt;a href="http://www.boost.org" target="_blank"&gt;Boost C++ Libraries&lt;/a&gt; was released.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2574712085639993348-2235008774139593925?l=blog.p-jansson.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/MqbC0hwjnxJNs8b0rVeWhGgBuzo/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/MqbC0hwjnxJNs8b0rVeWhGgBuzo/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/MqbC0hwjnxJNs8b0rVeWhGgBuzo/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/MqbC0hwjnxJNs8b0rVeWhGgBuzo/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JanssonConsulting/~4/euTAL23xY_A" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.p-jansson.com/feeds/2235008774139593925/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.p-jansson.com/2010/05/boost-c-libraries-version-143-released.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/2235008774139593925?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/2235008774139593925?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/JanssonConsulting/~3/euTAL23xY_A/boost-c-libraries-version-143-released.html" title="Boost C++ Libraries version 1.43 released" /><author><name>Peter Jansson</name><uri>http://www.blogger.com/profile/02543155564076384235</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_icY8aPexjCA/Sp63XsM3SLI/AAAAAAAAANI/VcVhqbw706A/s1600-R/AIbEiAIAAABECOP5xtyUoozZhwEiC3ZjYXJkX3Bob3RvKihhMWUwZmY4MTQzM2JhYjcxMmQ5OWYzMTY0N2YyZjk1MTExOGNhMzczMAFvd8hrPIJ5oYco5_oUBeY2wGftgA" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.p-jansson.com/2010/05/boost-c-libraries-version-143-released.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEYCRn8_eSp7ImA9WxBWEUU.&quot;"><id>tag:blogger.com,1999:blog-2574712085639993348.post-1376621693304164067</id><published>2010-02-03T08:29:00.001+01:00</published><updated>2010-02-03T08:29:27.141+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-02-03T08:29:27.141+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="C++" /><title>Boost C++ Libraries version 1.42.0 released</title><content type="html">Just for your information: On February 2, 2010, version 1.42.0 of the &lt;a href="http://www.boost.org/" target="_blank"&gt;Boost C++ Libraries&lt;/a&gt; was released.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2574712085639993348-1376621693304164067?l=blog.p-jansson.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/TF66UaD4nuTz0T7sbKf-L1xHFis/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/TF66UaD4nuTz0T7sbKf-L1xHFis/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/TF66UaD4nuTz0T7sbKf-L1xHFis/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/TF66UaD4nuTz0T7sbKf-L1xHFis/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JanssonConsulting/~4/0X2Zh_B_Wf0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.p-jansson.com/feeds/1376621693304164067/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.p-jansson.com/2010/02/boost-c-libraries-version-1420-released.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/1376621693304164067?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/1376621693304164067?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/JanssonConsulting/~3/0X2Zh_B_Wf0/boost-c-libraries-version-1420-released.html" title="Boost C++ Libraries version 1.42.0 released" /><author><name>Peter Jansson</name><uri>http://www.blogger.com/profile/02543155564076384235</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_icY8aPexjCA/Sp63XsM3SLI/AAAAAAAAANI/VcVhqbw706A/s1600-R/AIbEiAIAAABECOP5xtyUoozZhwEiC3ZjYXJkX3Bob3RvKihhMWUwZmY4MTQzM2JhYjcxMmQ5OWYzMTY0N2YyZjk1MTExOGNhMzczMAFvd8hrPIJ5oYco5_oUBeY2wGftgA" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.p-jansson.com/2010/02/boost-c-libraries-version-1420-released.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkINRn8yfip7ImA9WxBRGUg.&quot;"><id>tag:blogger.com,1999:blog-2574712085639993348.post-1268972228347847268</id><published>2010-01-08T14:41:00.001+01:00</published><updated>2010-01-08T14:49:57.196+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-01-08T14:49:57.196+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Crypto" /><title>RSA-768 is no longer secure</title><content type="html">&lt;p&gt;A quickie: You should probably go way beyond 1024 bits now that &lt;a href="http://eprint.iacr.org/2010/006.pdf" target="_blank"&gt;768-bit RSA encryption is factorable&lt;/a&gt;. I would not recommend using encryption that is scheduled to be decrypted within the next 10 years.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2574712085639993348-1268972228347847268?l=blog.p-jansson.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/owGhtzoh44Vv5BnRd3h-xoUUmg0/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/owGhtzoh44Vv5BnRd3h-xoUUmg0/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/owGhtzoh44Vv5BnRd3h-xoUUmg0/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/owGhtzoh44Vv5BnRd3h-xoUUmg0/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JanssonConsulting/~4/w3SfYaq3otw" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.p-jansson.com/feeds/1268972228347847268/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.p-jansson.com/2010/01/rsa-768-is-no-longer-secure.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/1268972228347847268?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/1268972228347847268?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/JanssonConsulting/~3/w3SfYaq3otw/rsa-768-is-no-longer-secure.html" title="RSA-768 is no longer secure" /><author><name>Peter Jansson</name><uri>http://www.blogger.com/profile/02543155564076384235</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_icY8aPexjCA/Sp63XsM3SLI/AAAAAAAAANI/VcVhqbw706A/s1600-R/AIbEiAIAAABECOP5xtyUoozZhwEiC3ZjYXJkX3Bob3RvKihhMWUwZmY4MTQzM2JhYjcxMmQ5OWYzMTY0N2YyZjk1MTExOGNhMzczMAFvd8hrPIJ5oYco5_oUBeY2wGftgA" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.p-jansson.com/2010/01/rsa-768-is-no-longer-secure.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkUFQHw4fyp7ImA9WhdREU0.&quot;"><id>tag:blogger.com,1999:blog-2574712085639993348.post-2569791336651395851</id><published>2009-12-19T18:26:00.002+01:00</published><updated>2011-07-31T12:30:11.237+02:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-07-31T12:30:11.237+02:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Intrusion" /><title>Detecting when you've been hacked</title><content type="html">&lt;p&gt;Suppose your LINUX box is being targeted by a clumsy adversary that does not hide tracks very well. How do you detect it?&lt;/p&gt;
&lt;p&gt;Put the following command in your login shell script, e.g /root/.bash_profile if your'e into Bash. It will report the root shell access to your email.&lt;/p&gt;

&lt;pre class="prettyprint"&gt;
echo 'ALERT - Root Shell Access on:' `date` `who` | \
  mail -s "Alert: Root Access from `who | awk '{print $6}'`" YOUR_EMAIL_HERE
&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2574712085639993348-2569791336651395851?l=blog.p-jansson.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/sJW23xwsV_8tdRhON9m13G8zDDs/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/sJW23xwsV_8tdRhON9m13G8zDDs/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/sJW23xwsV_8tdRhON9m13G8zDDs/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/sJW23xwsV_8tdRhON9m13G8zDDs/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JanssonConsulting/~4/qCX834pliXo" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.p-jansson.com/feeds/2569791336651395851/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.p-jansson.com/2009/12/detecting-when-youve-been-hacked.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/2569791336651395851?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/2569791336651395851?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/JanssonConsulting/~3/qCX834pliXo/detecting-when-youve-been-hacked.html" title="Detecting when you've been hacked" /><author><name>Peter Jansson</name><uri>http://www.blogger.com/profile/02543155564076384235</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_icY8aPexjCA/Sp63XsM3SLI/AAAAAAAAANI/VcVhqbw706A/s1600-R/AIbEiAIAAABECOP5xtyUoozZhwEiC3ZjYXJkX3Bob3RvKihhMWUwZmY4MTQzM2JhYjcxMmQ5OWYzMTY0N2YyZjk1MTExOGNhMzczMAFvd8hrPIJ5oYco5_oUBeY2wGftgA" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.p-jansson.com/2009/12/detecting-when-youve-been-hacked.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CE8DRnk6fCp7ImA9WxBTF00.&quot;"><id>tag:blogger.com,1999:blog-2574712085639993348.post-3259982530189258573</id><published>2009-12-13T12:14:00.002+01:00</published><updated>2009-12-13T12:14:37.714+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-12-13T12:14:37.714+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="C++" /><title>Do you want a C++ t-shirt?</title><content type="html">&lt;p&gt;If you do, you can buy one &lt;a href="http://jansson.spreadshirt.se/c-t-shirt-A11385108/customize/color/1" target="_blank"&gt;here&lt;/a&gt;:&lt;/p&gt;

&lt;div align="center"&gt;
&lt;iframe src="http://jansson.spreadshirt.se/c-t-shirt-A11385108/customize/color/1" width="600" height="900"&gt;&lt;/iframe&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2574712085639993348-3259982530189258573?l=blog.p-jansson.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/_XDHPBE_9rxGi_hMAxdAR4BJGks/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/_XDHPBE_9rxGi_hMAxdAR4BJGks/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/_XDHPBE_9rxGi_hMAxdAR4BJGks/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/_XDHPBE_9rxGi_hMAxdAR4BJGks/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JanssonConsulting/~4/oPiDMc9-ins" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.p-jansson.com/feeds/3259982530189258573/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.p-jansson.com/2009/12/do-you-want-c-t-shirt.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/3259982530189258573?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2574712085639993348/posts/default/3259982530189258573?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/JanssonConsulting/~3/oPiDMc9-ins/do-you-want-c-t-shirt.html" title="Do you want a C++ t-shirt?" /><author><name>Peter Jansson</name><uri>http://www.blogger.com/profile/02543155564076384235</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_icY8aPexjCA/Sp63XsM3SLI/AAAAAAAAANI/VcVhqbw706A/s1600-R/AIbEiAIAAABECOP5xtyUoozZhwEiC3ZjYXJkX3Bob3RvKihhMWUwZmY4MTQzM2JhYjcxMmQ5OWYzMTY0N2YyZjk1MTExOGNhMzczMAFvd8hrPIJ5oYco5_oUBeY2wGftgA" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.p-jansson.com/2009/12/do-you-want-c-t-shirt.html</feedburner:origLink></entry></feed>

