<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>blog.murph.ie</title>
	<atom:link href="http://blog.murph.ie/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.murph.ie</link>
	<description>murph.ie - with a y</description>
	<lastBuildDate>Wed, 21 Dec 2011 15:22:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>My first trie</title>
		<link>http://blog.murph.ie/2011/12/my-first-trie/</link>
		<comments>http://blog.murph.ie/2011/12/my-first-trie/#comments</comments>
		<pubDate>Wed, 21 Dec 2011 15:22:14 +0000</pubDate>
		<dc:creator>eoin</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[trie]]></category>

		<guid isPermaLink="false">http://blog.murph.ie/?p=132</guid>
		<description><![CDATA[Simon (or was it Aaron, those two classes have merged into one in my memory) would be proud. All it took was a casual glance at the description of a Trie on Wikipedia to remind me of what it actually was, allowing me to take a first stab at it. Not bad for something that [...]]]></description>
			<content:encoded><![CDATA[<p>Simon (or was it Aaron, those two classes have merged into one in my memory) would be proud. All it took was a casual glance at the description of a Trie on Wikipedia to remind me of what it actually was, allowing me to take a first stab at it. Not bad for something that I have only very vague recollections about learning over four years ago in a Data Structures and Algorithms lecture.</p>
<p>Regardless of who it was that taught us, they seem to have made a good job of it.</p>
<h2>Why trie?</h2>
<p>Currently for some work related to my PhD I&#8217;m looking at the initialisation of a large population of trees. One property of this initial population is that each tree should be unique, since (randomly) generating duplicate structures at the very beginning of a search is a little silly.</p>
<p>To date, I&#8217;ve been using Java&#8217;s builtin HashMap as a look up table to see if a specific tree structure already exists, and while this approach works, it might not be ideal. Erik, a colleague in the NCRA mentioned he had just coded up a Trie to do something similar but with Strings and chars as opposed to Trees and Nodes.</p>
<p>The code is available <a href="http://murph.ie/uploads/Trie.java" target="_blank">here</a> (and a sample Iterator to use it with <a href="http://murph.ie/uploads/TreeIterator.java" target="_blank">here</a>).</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;">import java.<span style="color: #007788;">util</span>.<span style="color: #007788;">ArrayList</span><span style="color: #008080;">;</span>
import java.<span style="color: #007788;">util</span>.<span style="color: #007788;">Iterator</span><span style="color: #008080;">;</span>
&nbsp;
<span style="color: #ff0000; font-style: italic;">/**
 * A Trie for Iterable Objects
 *
 * @author Eoin Murphy &lt;eoin.murphy@ucd.ie&gt;
 */</span>
<span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> Trie<span style="color: #000080;">&lt;</span>K extends Iterable, V<span style="color: #000080;">&gt;</span> extends ArrayList<span style="color: #000080;">&lt;</span>Trie<span style="color: #000080;">&lt;</span>K, V<span style="color: #000080;">&gt;&gt;</span> <span style="color: #008000;">&#123;</span>
&nbsp;
  <span style="color: #ff0000; font-style: italic;">/** The key for this node */</span>
  <span style="color: #0000ff;">private</span> Object key<span style="color: #008080;">;</span>
&nbsp;
  <span style="color: #ff0000; font-style: italic;">/** The value */</span>
  <span style="color: #0000ff;">private</span> V value<span style="color: #008080;">;</span>
&nbsp;
  <span style="color: #ff0000; font-style: italic;">/**
   * Creates a new empty trie. The root node is keyed and valued with
   * null
   */</span>
  <span style="color: #0000ff;">public</span> Trie<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    key <span style="color: #000080;">=</span> null<span style="color: #008080;">;</span>
    value <span style="color: #000080;">=</span> null<span style="color: #008080;">;</span>
  <span style="color: #008000;">&#125;</span>
&nbsp;
  <span style="color: #ff0000; font-style: italic;">/**
   * Creates a new trie node keyed with &lt;code&gt;key&lt;/key&gt; and with a
   * null &lt;code&gt;value&lt;/code&gt;
   *
   * @param key The partial key for this node
   */</span>
  <span style="color: #0000ff;">public</span> Trie<span style="color: #008000;">&#40;</span>Object key<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    <span style="color: #0000dd;">this</span>.<span style="color: #007788;">key</span> <span style="color: #000080;">=</span> key<span style="color: #008080;">;</span>
    value <span style="color: #000080;">=</span> null<span style="color: #008080;">;</span>
  <span style="color: #008000;">&#125;</span>
&nbsp;
  <span style="color: #ff0000; font-style: italic;">/**
   * Add a key-value pair to the trie, overwriting any previous value
   * that was asssociate with that key in the trie
   *
   * @param k The key 
   * @param value The value to store
   * @return If the key was already present, the previous value is returned. Otherwise, null.
   */</span>
  <span style="color: #0000ff;">public</span> V put<span style="color: #008000;">&#40;</span>K k, V value<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    Iterator<span style="color: #000080;">&lt;</span>K<span style="color: #000080;">&gt;</span> i <span style="color: #000080;">=</span> k.<span style="color: #007788;">iterator</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    <span style="color: #0000ff;">return</span> put<span style="color: #008000;">&#40;</span>i, value<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
  <span style="color: #008000;">&#125;</span>
&nbsp;
  <span style="color: #ff0000; font-style: italic;">/**
   * This is a private recursive method called initialy by its public
   * companion to iterate through the key, traversing the trie and
   * adding nodes when needed
   *
   * @param i The iterator for the key
   * @param value The value to store
   * @return If the key was already present, the previous value is returned. Otherwise, null.
   */</span>
  <span style="color: #0000ff;">private</span> V put<span style="color: #008000;">&#40;</span>Iterator<span style="color: #000080;">&lt;</span>K<span style="color: #000080;">&gt;</span> i, V value<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #000040;">!</span>i.<span style="color: #007788;">hasNext</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
      V returnValue <span style="color: #000080;">=</span> <span style="color: #0000dd;">this</span>.<span style="color: #007788;">value</span><span style="color: #008080;">;</span>
      <span style="color: #0000dd;">this</span>.<span style="color: #007788;">value</span> <span style="color: #000080;">=</span> value<span style="color: #008080;">;</span>
      <span style="color: #0000ff;">return</span> returnValue<span style="color: #008080;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    Trie<span style="color: #000080;">&lt;</span>K, V<span style="color: #000080;">&gt;</span> next<span style="color: #008080;">;</span>
    Object nextKey <span style="color: #000080;">=</span> i.<span style="color: #007788;">next</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
    <span style="color: #0000ff;">int</span> index <span style="color: #000080;">=</span> indexOf<span style="color: #008000;">&#40;</span>nextKey<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>index <span style="color: #000080;">==</span> <span style="color: #000040;">-</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
      next <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> Trie<span style="color: #008000;">&#40;</span>nextKey<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
      add<span style="color: #008000;">&#40;</span>next<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    <span style="color: #008000;">&#125;</span>
    <span style="color: #0000ff;">else</span> 
      next <span style="color: #000080;">=</span> get<span style="color: #008000;">&#40;</span>index<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
    <span style="color: #0000ff;">return</span> next.<span style="color: #007788;">put</span><span style="color: #008000;">&#40;</span>i, value<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
  <span style="color: #008000;">&#125;</span>
&nbsp;
  <span style="color: #ff0000; font-style: italic;">/**
   * Gets the value for the key from the trie.
   * If the key is absent, returns null
   *
   * @param i The key
   * @return The value for the key, or null if key is absent
   */</span>
  <span style="color: #0000ff;">public</span> V get<span style="color: #008000;">&#40;</span>K k<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    Iterator<span style="color: #000080;">&lt;</span>K<span style="color: #000080;">&gt;</span> i <span style="color: #000080;">=</span> k.<span style="color: #007788;">iterator</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    <span style="color: #0000ff;">return</span> get<span style="color: #008000;">&#40;</span>i<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
  <span style="color: #008000;">&#125;</span>
&nbsp;
  <span style="color: #ff0000; font-style: italic;">/**
   * Private recusive helper method called initialy by the public
   * version of the method
   *
   * @param i The key's iterator
   * @return The value for the key, or null if the is not present
   */</span>
  <span style="color: #0000ff;">private</span> V get<span style="color: #008000;">&#40;</span>Iterator<span style="color: #000080;">&lt;</span>K<span style="color: #000080;">&gt;</span> i<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #000040;">!</span>i.<span style="color: #007788;">hasNext</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
      <span style="color: #0000ff;">return</span> value<span style="color: #008080;">;</span>
&nbsp;
    Trie<span style="color: #000080;">&lt;</span>K, V<span style="color: #000080;">&gt;</span> next<span style="color: #008080;">;</span>
    Object nextKey <span style="color: #000080;">=</span> i.<span style="color: #007788;">next</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
    <span style="color: #0000ff;">int</span> index <span style="color: #000080;">=</span> indexOf<span style="color: #008000;">&#40;</span>nextKey<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>index <span style="color: #000080;">==</span> <span style="color: #000040;">-</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span>
      <span style="color: #0000ff;">return</span> null<span style="color: #008080;">;</span>
    <span style="color: #0000ff;">else</span> 
      next <span style="color: #000080;">=</span> get<span style="color: #008000;">&#40;</span>index<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
    <span style="color: #0000ff;">return</span> next.<span style="color: #007788;">get</span><span style="color: #008000;">&#40;</span>i<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
  <span style="color: #008000;">&#125;</span>
&nbsp;
  <span style="color: #ff0000; font-style: italic;">/**
   * Attempts to find the index of the child node keyed with
   * &lt;code&gt;o&lt;/code&gt;
   * 
   * @param o The key to find
   * @return The index of the trie node keyed with &lt;code&gt;o&lt;/code&gt; or -1 if it's absent
   */</span>
  <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">int</span> indexOf<span style="color: #008000;">&#40;</span>Object o<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    <span style="color: #0000ff;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> i <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span> i <span style="color: #000080;">&lt;</span> size<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> i<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span>
      <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>get<span style="color: #008000;">&#40;</span>i<span style="color: #008000;">&#41;</span>.<span style="color: #007788;">key</span>.<span style="color: #007788;">equals</span><span style="color: #008000;">&#40;</span>o<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #0000ff;">return</span> i<span style="color: #008080;">;</span>
    <span style="color: #0000ff;">return</span> <span style="color: #000040;">-</span><span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
  <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>The code is available <a href="http://murph.ie/uploads/Trie.java" target="_blank">here</a> (and a sample Iterator to use it with <a href="http://murph.ie/uploads/TreeIterator.java" target="_blank">here</a>).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.murph.ie/2011/12/my-first-trie/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Skype on Fedora 16 x86_64</title>
		<link>http://blog.murph.ie/2011/11/installing-skype-on-fedora-16-x86_64/</link>
		<comments>http://blog.murph.ie/2011/11/installing-skype-on-fedora-16-x86_64/#comments</comments>
		<pubDate>Sat, 12 Nov 2011 18:14:03 +0000</pubDate>
		<dc:creator>eoin</dc:creator>
				<category><![CDATA[*nix]]></category>
		<category><![CDATA[16]]></category>
		<category><![CDATA[64bit]]></category>
		<category><![CDATA[fedora]]></category>
		<category><![CDATA[libraries]]></category>
		<category><![CDATA[skype]]></category>
		<category><![CDATA[x86_64]]></category>

		<guid isPermaLink="false">http://blog.murph.ie/?p=155</guid>
		<description><![CDATA[First follow the link below to set up the repository and install Skype using yum. http://www.multimediaboom.com/install-skype-on-fedora/ Next install glibc.i686 so we can use the tool ldd. sudo yum install glibc.i686 We can now use ldd to find which library files are missing and yum is able to find which packages provide those files and install [...]]]></description>
			<content:encoded><![CDATA[<p>First follow the link below to set up the repository and install Skype using yum.<br />
<a href="http://www.multimediaboom.com/install-skype-on-fedora/ " target="_blank">http://www.multimediaboom.com/install-skype-on-fedora/</a></p>
<p>Next install glibc.i686 so we can use the tool ldd.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> yum <span style="color: #c20cb9; font-weight: bold;">install</span> glibc.i686</pre></div></div>

<p>We can now use ldd to find which library files are missing and yum is able to find which packages provide those files and install them for us.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">for</span> lib <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ldd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>skype <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">&quot;not found&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $1}'</span><span style="color: #000000; font-weight: bold;">`</span>; <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> yum <span style="color: #660033;">-y</span> <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #007800;">$lib</span>; <span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

<p>EDIT: It seems the audio playback was still not working, even after doing everything above. It took the following package to get it going.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> yum <span style="color: #c20cb9; font-weight: bold;">install</span> alsa-plugins-pulseaudio.i686</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.murph.ie/2011/11/installing-skype-on-fedora-16-x86_64/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Where can we use (a = b)? Examining lvalues and rvalues.</title>
		<link>http://blog.murph.ie/2011/09/where-can-we-use-a-b-examining-lvalues-and-rvalues/</link>
		<comments>http://blog.murph.ie/2011/09/where-can-we-use-a-b-examining-lvalues-and-rvalues/#comments</comments>
		<pubDate>Thu, 01 Sep 2011 09:44:24 +0000</pubDate>
		<dc:creator>eoin</dc:creator>
				<category><![CDATA[c++]]></category>
		<category><![CDATA[procrastination]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[=operator]]></category>
		<category><![CDATA[lvalue]]></category>
		<category><![CDATA[rvalue]]></category>

		<guid isPermaLink="false">http://blog.murph.ie/?p=90</guid>
		<description><![CDATA[Random thought today. I found myself thinking about these strange-looking things 1 2 3 &#40;a = 0&#41;++; ++&#40;a = 0&#41;; &#40;a = 0&#41; = 1; All of which produce the result of a containing the value 1. It&#8217;s kind of bizarre and I&#8217;m not overly surprised it works, but I can&#8217;t explain why. While I [...]]]></description>
			<content:encoded><![CDATA[<p>Random thought today.</p>
<p>I found myself thinking about these strange-looking things</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #008000;">&#40;</span>a <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span><span style="color: #000040;">++</span><span style="color: #008080;">;</span>
<span style="color: #000040;">++</span><span style="color: #008000;">&#40;</span>a <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#40;</span>a <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span> <span style="color: #000080;">=</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span></pre></td></tr></table></div>

<p>All of which produce the result of a containing the value <font face="courier">1</font>. It&#8217;s kind of bizarre and I&#8217;m not overly surprised it works, but I can&#8217;t explain why.</p>
<p>While I have seen examples of = operations being used as <em>rvalues</em> (see directly below), I hadn&#8217;t seen them being used as <em>lvalues</em> before. Since these operations are read from right to left, the result of each operation is used as an <em>rvalue</em> for the next. The parentheses break this assertion.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;">a <span style="color: #000080;">=</span> b <span style="color: #000080;">=</span> c <span style="color: #000080;">=</span> <span style="color: #0000dd;">6</span><span style="color: #008080;">;</span></pre></td></tr></table></div>

<p>Looking at the declaration of the operator we start to understand. The = operator returns a reference to our initial <em>lvalue</em>.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;">T<span style="color: #000040;">&amp;</span> T<span style="color: #008080;">::</span><span style="color: #007788;">operator</span> <span style="color: #000080;">=</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">const</span> T<span style="color: #000040;">&amp;</span> b<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></pre></td></tr></table></div>

<p>The <a href="http://publib.boulder.ibm.com/infocenter/comphelp/v7v91/index.jsp?topic=%2Fcom.ibm.vacpp7a.doc%2Flanguage%2Fref%2Fclrc05lvalue.htm">IBM compiler information center</a> (while for AIX should be fine for this example) tells us</p>
<blockquote><p>An object is a region of storage that can be examined and stored into. An <em>lvalue</em> is an expression that refers to such an object&#8230;</p></blockquote>
<p>and that</p>
<blockquote><p>The term <em>rvalue</em> refers to a data value that is stored at some address in memory. An <em>rvalue</em> is an expression that cannot have a value assigned to it&#8230;</p></blockquote>
<p>It goes on to say</p>
<blockquote><p>&#8230;in C++, a function call that returns a reference is an <em>lvalue</em>. Otherwise, a function call is an <em>rvalue</em> expression. In C++, every expression produces an <em>lvalue</em>, an <em>rvalue</em>, or no value.</p></blockquote>
<p>Going back and looking at the prototype of the = operator we can see that it does indeed return a reference, so in our example the expression <font face="courier">(a = 0)</font> is an <em>lvalue</em> and can then be used with the increment operators or the = operator and the <em>rvalue</em>, <font face="courier">1</font>.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;">T<span style="color: #000040;">&amp;</span> T<span style="color: #008080;">::</span><span style="color: #007788;">operator</span> <span style="color: #000080;">=</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">const</span> T<span style="color: #000040;">&amp;</span> b<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#40;</span>a <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span><span style="color: #000040;">++</span><span style="color: #008080;">;</span>
<span style="color: #000040;">++</span><span style="color: #008000;">&#40;</span>a <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#40;</span>a <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span> <span style="color: #000080;">=</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span></pre></td></tr></table></div>

<p>After all that, learning that an = operation produces an <em>lvalue</em>, how come they can also be used as <em>rvalues</em> like in the following example?</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;">a <span style="color: #000080;">=</span> b <span style="color: #000080;">=</span> c <span style="color: #000080;">=</span> <span style="color: #0000dd;">6</span><span style="color: #008080;">;</span></pre></td></tr></table></div>

<p>Well IBM also tell us that</p>
<blockquote><p>&#8230;When an lvalue appears in a context that requires a rvalue, the lvalue is implicitly converted to an rvalue. The reverse, however, is not true: an rvalue cannot be converted to an lvalue.
</p></blockquote>
<p>And there you have it. Pointless you say? Yes. Am I likely to use any of these expressions? Probably not. </p>
<p>That said, at least I have learnt something about <em>lvalues</em> and <em>rvalues</em> in C++, and I&#8217;m not likely to be confused by an &#8220;<font face="courier">lvalue required</font>&#8221; error message again.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.murph.ie/2011/09/where-can-we-use-a-b-examining-lvalues-and-rvalues/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Dog on a barstool</title>
		<link>http://blog.murph.ie/2011/05/dog-on-a-barstool/</link>
		<comments>http://blog.murph.ie/2011/05/dog-on-a-barstool/#comments</comments>
		<pubDate>Mon, 23 May 2011 14:17:08 +0000</pubDate>
		<dc:creator>eoin</dc:creator>
				<category><![CDATA[travel]]></category>
		<category><![CDATA[barstool]]></category>
		<category><![CDATA[dog]]></category>

		<guid isPermaLink="false">http://blog.murph.ie/2011/05/dog-on-a-barstool/</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p><img style="display:block;margin-right:auto;margin-left:auto;" alt="image" src="http://blog.murph.ie/wp-content/uploads/2011/05/wpid-IMG_20110520_172236.jpg" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.murph.ie/2011/05/dog-on-a-barstool/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Canvas Panorama</title>
		<link>http://blog.murph.ie/2011/05/canvas-panorama/</link>
		<comments>http://blog.murph.ie/2011/05/canvas-panorama/#comments</comments>
		<pubDate>Sun, 08 May 2011 22:01:25 +0000</pubDate>
		<dc:creator>eoin</dc:creator>
				<category><![CDATA[procrastination]]></category>
		<category><![CDATA[travel]]></category>
		<category><![CDATA[deals]]></category>
		<category><![CDATA[new york]]></category>
		<category><![CDATA[photo]]></category>

		<guid isPermaLink="false">http://blog.murph.ie/?p=71</guid>
		<description><![CDATA[Groupon is dangerous. I recently came across this deal for HelloCanvas.ie, €36 gets me €98 worth of canvas printing. Deal. I chose a panorama I took of NY city. It was taken at night, from the top of the Rockefeller Center, facing the Empire State Building. Since it is a panorama and quite long, their regular sizes [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://citydeal.ie">Groupon</a> is dangerous.</p>
<p>I recently came across this <a href="http://www.citydeal.ie/deals/dublin/hello-canvas/107833">deal</a> for <a href="http://www.hellocanvas.ie">HelloCanvas.ie</a>, €36 gets me €98 worth of canvas printing. Deal.</p>
<p>I chose a panorama I took of NY city. It was taken at night, from the top of the Rockefeller Center, facing the Empire State Building. Since it is a panorama and quite long, their regular sizes didn&#8217;t quite fit it, but their order process let me chose the dimensions that I wanted and add some comments on how I&#8217;d like the image printed.</p>
<p>The finished product is 40 x 140 cm and 3 cm deep. In the end I had to pay an extra €10 to get the dimensions I wanted but I am very happy with how it turned out.</p>
<p>Oh and it&#8217;s quite clear, apologies for the blurry photo. If you would like the original file, just let me know. It&#8217;s pretty big so I&#8217;m not going to put it up here&#8230;</p>
<p style="text-align: center;">&nbsp;</p>
<div id="attachment_72" class="wp-caption aligncenter" style="width: 624px"><a href="http://blog.murph.ie/wp-content/uploads/2011/05/P1020472.jpg"><img class="size-large wp-image-72 " title="New York at night" src="http://blog.murph.ie/wp-content/uploads/2011/05/P1020472-1024x306.jpg" alt="New York at night" width="614" height="184" /></a><p class="wp-caption-text">Night Panorama Of New York City</p></div>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.murph.ie/2011/05/canvas-panorama/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Torino to St. Andrews</title>
		<link>http://blog.murph.ie/2011/05/torino-to-st-andrews/</link>
		<comments>http://blog.murph.ie/2011/05/torino-to-st-andrews/#comments</comments>
		<pubDate>Sun, 01 May 2011 17:28:07 +0000</pubDate>
		<dc:creator>eoin</dc:creator>
				<category><![CDATA[travel]]></category>
		<category><![CDATA[tracking]]></category>

		<guid isPermaLink="false">http://blog.murph.ie/?p=45</guid>
		<description><![CDATA[Had a good day&#8217;s travelin&#8217; today. Duration: 16hours 30mins 06:30 Torino 07:20 Train Torino Porta Nuova &#8211; Milano Porta Garibaldi 08:20 Metro Milano Porta Garibaldi &#8211; Milano Central 08:30 Bus Milano Central &#8211; Milano Central 08:50 Taxi Milano Central &#8211; Milano Linate 10:20 Airplane Milano Linate &#8211; Dublin Airport 13:30 Taxi Dublin Airport &#8211; Home [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.murph.ie/wp-content/uploads/2011/05/SC20110501-174127.png"><img class="size-medium wp-image-60 alignright" title="Google is stalking me..." src="http://blog.murph.ie/wp-content/uploads/2011/05/SC20110501-174127-180x300.png" alt="Google is stalking me..." width="180" height="300" /></a></p>
<p>Had a good day&#8217;s travelin&#8217; today.</p>
<p><strong>Duration:</strong> 16hours 30mins</p>
<table>
<tbody>
<tr>
<td><strong>06:30</strong></td>
<td></td>
<td style="padding-left: 30px;">Torino</td>
</tr>
<tr>
<td><strong>07:20</strong></td>
<td style="padding-left: 30px;">Train</td>
<td style="padding-left: 30px;">Torino Porta Nuova &#8211; Milano Porta Garibaldi</td>
</tr>
<tr>
<td><strong>08:20</strong></td>
<td style="padding-left: 30px;">Metro</td>
<td style="padding-left: 30px;">Milano Porta Garibaldi &#8211; Milano Central</td>
</tr>
<tr>
<td><strong>08:30</strong></td>
<td style="padding-left: 30px;">Bus</td>
<td style="padding-left: 30px;">Milano Central &#8211; Milano Central</td>
</tr>
<tr>
<td><strong>08:50</strong></td>
<td style="padding-left: 30px;">Taxi</td>
<td style="padding-left: 30px;">Milano Central &#8211; Milano Linate</td>
</tr>
<tr>
<td><strong>10:20</strong></td>
<td style="padding-left: 30px;">Airplane</td>
<td style="padding-left: 30px;">Milano Linate &#8211; Dublin Airport</td>
</tr>
<tr>
<td><strong>13:30</strong></td>
<td style="padding-left: 30px;">Taxi</td>
<td style="padding-left: 30px;">Dublin Airport &#8211; Home</td>
</tr>
<tr>
<td><strong>14:30</strong></td>
<td style="padding-left: 30px;">Car</td>
<td style="padding-left: 30px;">Home &#8211; Belfast Port</td>
</tr>
<tr>
<td><strong>17:00</strong></td>
<td style="padding-left: 30px;">Ferry</td>
<td style="padding-left: 30px;">Belfast Port &#8211; Stranraer Port</td>
</tr>
<tr>
<td><strong>19:30</strong></td>
<td style="padding-left: 30px;">Car</td>
<td style="padding-left: 30px;">Stranraer Port &#8211; St Andrews</td>
</tr>
<tr>
<td><strong>23:00</strong></td>
<td></td>
<td style="padding-left: 30px;">St Andrews</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>And of course, Google followed me the whole way&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.murph.ie/2011/05/torino-to-st-andrews/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Counter Hacking</title>
		<link>http://blog.murph.ie/2011/03/counter-hacking/</link>
		<comments>http://blog.murph.ie/2011/03/counter-hacking/#comments</comments>
		<pubDate>Tue, 01 Mar 2011 13:45:40 +0000</pubDate>
		<dc:creator>eoin</dc:creator>
				<category><![CDATA[*nix]]></category>
		<category><![CDATA[procrastination]]></category>

		<guid isPermaLink="false">http://blog.murph.ie/?p=4</guid>
		<description><![CDATA[Yesterday, while procrastinating, I was looking through /var/log and happened upon a username brute-force attack. Any one with a static IP and ssh open to the world will be familiar to these. I was sitting there with tail -f /var/log/secure.log in front of me, watching this guy&#8217;s script try username after username to ssh into my [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday, while procrastinating, I was looking through <code>/var/log</code> and happened upon a username brute-force attack. Any one with a static IP and ssh open to the world will be familiar to these. I was sitting there with <code>tail -f /var/log/secure.log</code> in front of me, watching this guy&#8217;s script try username after username to ssh into my machine. I wasn&#8217;t worried, he was already up in the &#8216;h&#8217;s, well past the only username accessible on the machine. He wasn&#8217;t going to get lucky today.</p>
<p>Intrigued by this, and not knowing enough about OS X&#8217;s firewall rules to blacklist him, I checked out the IP address that the attack was coming from. GEOIP put him in Poland, but since it would be silly to do this from your own computer I figured that he might have borrowed someone else&#8217;s machine. Sure enough the website attached to the IP was someone&#8217;s (pretty terrible) company site. It got me wondering how he got access to the Polish machine, so I googled the IP. Bingo.<br />
<span id="more-4"></span><br />
The first hit was one of these dubious arabic hacker forums with a username/password dump for a few hundred servers. I found the Polish IP, pulled up a terminal and tried logging in. Success! <em><code>Have a lot of fun...</code></em> Oh dear, someone has been playing in here. I quickly checked who else was logged in and found somebody else was in using the same username that I had found online, not only that, but the scripts that were attacking my machine were running under this username!</p>
<p>Time to have some fun. First things first, I changed the password to the account, meaning my friend wouldn&#8217;t be getting back in anytime soon. Next was to kick him off the machine. I used:</p>
<ol>
<li><code>tty </code>to find out which tty I was on</li>
<li><code>ps -fu username </code>to find out the processes being run under my/his username</li>
<li><span style="font-family: monospace;">for  f in `ps -fu username | grep 2 | awk &#8216;{print $2}&#8217;`; do kill -9 $f; done<br />
</span>to kill his session. This should have kicked him off the server and with the password changed under his nose, he wasn&#8217;t getting back in.</li>
<li>And again with a &#8220;?&#8221;<br />
<span style="font-family: monospace;">for  f in `ps -fu username | grep &#8220;?&#8221; | awk &#8216;{print $2}&#8217;`; do kill -9 $f; done<br />
</span>to kill all of his processes. They were being run inside of a screen hence the ? for the tty value.</li>
</ol>
<p>As soon as I did this, with a last few default username login attempts from a new Russian IP, the attack stopped. <a href="http://4.bp.blogspot.com/__FIaozgXAJA/SnXYz_7ZJLI/AAAAAAAAAAw/A5l5raEaXnM/s1600/FEELS%2BGOOD%2BMAN%2BDOG%2BTEXT.jpg" target="_blank">Huzzah!</a> The new Russian IP is either him getting annoyed and came at me from his own PC or just the next server on his list, like the Polish one. Unfortunately I couldn&#8217;t find anything of interest out about the new one.</p>
<p>I&#8217;ll have to track down the Polish server&#8217;s admin and let him know that people have been playing in his machine. Thankfully all has been quiet since, but I&#8217;m sure it won&#8217;t be long before our friend is back.</p>
<p>I did the best I could with my limited script-fu, what would you have done differently?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.murph.ie/2011/03/counter-hacking/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

