<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>LokoNotes - All notes</title>
  <id>tag:notes.lokorin.org,2010:mephisto/</id>
  <generator version="0.7.2" uri="http://mephistoblog.com">Mephisto Noh-Varr</generator>
  <link href="http://notes.lokorin.org/feed/atom.xml" rel="self" type="application/atom+xml"/>
  <link href="http://notes.lokorin.org/" rel="alternate" type="text/html"/>
  <updated>2010-01-11T15:51:33Z</updated>
  <entry xml:base="http://notes.lokorin.org/">
    <author>
      <name>Lokorin</name>
    </author>
    <id>tag:notes.lokorin.org,2010-01-11:119</id>
    <published>2010-01-11T15:47:00Z</published>
    <updated>2010-01-11T15:51:33Z</updated>
    <category term="Linux"/>
    <link href="http://notes.lokorin.org/2010/1/11/cpulimit" rel="alternate" type="text/html"/>
    <title>cpulimit</title>
<content type="html">
            &lt;p&gt;&lt;a href='http://cpulimit.sourceforge.net/'&gt;cpulimit&lt;/a&gt; is a program that can be used to limit the peak cpu consumption of processes. It&#8217;s a piece of functionality that I would like to be standard. Sadly, cpulimit is a bit shaky &#8211; it works best if you start the process and then have cpulimit attach to it.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://notes.lokorin.org/">
    <author>
      <name>Lokorin</name>
    </author>
    <id>tag:notes.lokorin.org,2010-01-09:145</id>
    <published>2010-01-09T14:04:00Z</published>
    <updated>2010-01-09T14:05:54Z</updated>
    <category term="Linux"/>
    <link href="http://notes.lokorin.org/2010/1/9/following-a-stream" rel="alternate" type="text/html"/>
    <title>Following a Stream</title>
<content type="html">
            &lt;p&gt;Following a stream being written to a file is surprisingly easy.&lt;/p&gt;


	&lt;pre&gt;&lt;code&gt;tail -f &amp;lt;file&amp;gt;&lt;/code&gt;&lt;/pre&gt;


	&lt;p&gt;I didn&#8217;t know about the &lt;code&gt;-f&lt;/code&gt; flag before. It definitely seems useful.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://notes.lokorin.org/">
    <author>
      <name>Lokorin</name>
    </author>
    <id>tag:notes.lokorin.org,2010-01-06:147</id>
    <published>2010-01-06T12:11:00Z</published>
    <updated>2010-01-06T12:11:58Z</updated>
    <category term="Guides"/>
    <category term="Linux"/>
    <category term="Matlab"/>
    <link href="http://notes.lokorin.org/2010/1/6/how-to-debug-mex-files-in-matlab" rel="alternate" type="text/html"/>
    <title>How to Debug mex files in Matlab</title>
<content type="html">
            &lt;p&gt;I always have to look up the procedure for debugging code in compiled mex extensions in Matlab, so here it is:&lt;/p&gt;


	&lt;pre&gt;&lt;code&gt;shell&amp;gt; matlab -Dgdb
gdb&amp;gt; run -nodesktop -nojvm
matlab&amp;gt; dbmex on
matlab&amp;gt; foo()   % Execute the mex function being debugged
gdb&amp;gt; break foo.cpp:17   # Set up breakpoints
gdb&amp;gt; continue&lt;/code&gt;&lt;/pre&gt;
          </content>  </entry>
  <entry xml:base="http://notes.lokorin.org/">
    <author>
      <name>Lokorin</name>
    </author>
    <id>tag:notes.lokorin.org,2010-01-05:144</id>
    <published>2010-01-05T18:53:00Z</published>
    <updated>2010-01-05T18:54:12Z</updated>
    <category term="Linux"/>
    <link href="http://notes.lokorin.org/2010/1/5/reordering-screen-windows" rel="alternate" type="text/html"/>
    <title>Reordering Screen Windows</title>
<content type="html">
            &lt;p&gt;Screen windows can be reordered by giving windows new numbers. This is accomplished by Ctrl-A, : to open the command prompt and then giving the command &lt;code&gt;:number &amp;lt;n&amp;gt;&lt;/code&gt;.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://notes.lokorin.org/">
    <author>
      <name>Lokorin</name>
    </author>
    <id>tag:notes.lokorin.org,2010-01-04:143</id>
    <published>2010-01-04T09:12:00Z</published>
    <updated>2010-01-04T09:12:47Z</updated>
    <category term="Linux"/>
    <link href="http://notes.lokorin.org/2010/1/4/dealing-with-nested-screens" rel="alternate" type="text/html"/>
    <title>Dealing with nested screens</title>
<content type="html">
            &lt;p&gt;The proper way to deal with nested screens (e.g. resulting from sshing from one remote computer to another) is to escape commands using Ctrl-A, as shown in &lt;a href='http://tuxtraining.com/wp-content/uploads/2009/01/screen_cheatsheet.pdf'&gt;this cheat sheat&lt;/a&gt;. To e.g. start a new window in the nested screen, use Ctrl-A, A, C .&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://notes.lokorin.org/">
    <author>
      <name>Lokorin</name>
    </author>
    <id>tag:notes.lokorin.org,2009-12-17:142</id>
    <published>2009-12-17T15:17:00Z</published>
    <updated>2009-12-17T15:18:48Z</updated>
    <category term="Linux"/>
    <link href="http://notes.lokorin.org/2009/12/17/screen-and-x-forwarding" rel="alternate" type="text/html"/>
    <title>Screen and X-Forwarding</title>
<content type="html">
            &lt;p&gt;After a bit of tinkering with screen I found two major annoyances. First: X-forwarding does not work despite the &lt;code&gt;-X&lt;/code&gt; flag being set when opening the ssh connection. Secondly: Shift-PgUp and Shift-PgDn do not work for scrolling (and scrolling is in general a pain).&lt;/p&gt;


	&lt;p&gt;The first problem seems to have &lt;a href='http://bbs.archlinux.org/viewtopic.php?id=41974'&gt;a rather simple solution&lt;/a&gt;. Just set the &lt;code&gt;DISPLAY&lt;/code&gt; environment variable in &lt;code&gt;.bash_profile&lt;/code&gt; once a screen session has been detected.&lt;/p&gt;


	&lt;pre&gt;&lt;code&gt;if [ -n $WINDOW ] ; then 
  export DISPLAY=localhost:10
fi&lt;/code&gt;&lt;/pre&gt;
          </content>  </entry>
  <entry xml:base="http://notes.lokorin.org/">
    <author>
      <name>Lokorin</name>
    </author>
    <id>tag:notes.lokorin.org,2009-12-16:141</id>
    <published>2009-12-16T17:19:00Z</published>
    <updated>2009-12-17T09:38:35Z</updated>
    <category term="Linux"/>
    <link href="http://notes.lokorin.org/2009/12/16/detaching-shell-commands-take-three" rel="alternate" type="text/html"/>
    <title>Detaching Shell Commands - Take Three</title>
<content type="html">
            &lt;p&gt;I have now run into a system for which neither of &lt;a href='http://notes.lokorin.org/2008/4/18/daemonize-shell-commands'&gt;the previous&lt;/a&gt; &lt;a href='http://notes.lokorin.org/2009/4/10/detaching-shell-commands-take-two'&gt;two methods&lt;/a&gt; mentioned seem to work. A third method is to use &lt;a href='http://www.gnu.org/software/screen/'&gt;&lt;span class='caps'&gt;GNU&lt;/span&gt; screen&lt;/a&gt;. Roughly it is done by:&lt;/p&gt;


	&lt;ol&gt;
	&lt;li&gt;executing &#8220;screen&#8221; &lt;/li&gt;
		&lt;li&gt;running the command&lt;/li&gt;
		&lt;li&gt;detaching the screen using Ctrl-A, Ctrl-D&lt;/li&gt;
	&lt;/ol&gt;


	&lt;p&gt;However, there is so much more to screen than that. I have had my eye on it for a while, but never made the leap to using it consistently. &lt;a href='http://magazine.redhat.com/2007/09/27/a-guide-to-gnu-screen/'&gt;A couple of handy&lt;/a&gt; &lt;a href='http://news.softpedia.com/news/GNU-Screen-Tutorial-44274.shtml'&gt;guides to screen&lt;/a&gt; should give some idea of what it can do. I&#8217;m going to try out &lt;a href='http://tlug.dnho.net/?q=node/239'&gt;automatically running screen when logging in&lt;/a&gt; in an attempt to start using it all the time.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://notes.lokorin.org/">
    <author>
      <name>Lokorin</name>
    </author>
    <id>tag:notes.lokorin.org,2009-10-24:140</id>
    <published>2009-10-24T21:15:00Z</published>
    <updated>2009-10-24T21:16:05Z</updated>
    <category term="Linux"/>
    <link href="http://notes.lokorin.org/2009/10/24/ssh-public-key-authentication" rel="alternate" type="text/html"/>
    <title>SSH Public Key Authentication</title>
<content type="html">
            &lt;p&gt;A minor heads up when &lt;a href='http://macnugget.org/projects/publickeys/'&gt;configuring ssh for public key authentication&lt;/a&gt; is that ssh on the local machine only checks &lt;code&gt;~/.ssh/id_rsa&lt;/code&gt; and &lt;code&gt;~/.ssh/id_dsa&lt;/code&gt; for private keys to use public key authentication. Hence, if you have multiple sets of key pairs then you might have to explicitly point to the correct private key using the &lt;code&gt;-i&lt;/code&gt; flag of the ssh command.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://notes.lokorin.org/">
    <author>
      <name>Lokorin</name>
    </author>
    <id>tag:notes.lokorin.org,2009-07-10:139</id>
    <published>2009-07-10T09:54:00Z</published>
    <updated>2009-07-10T10:01:04Z</updated>
    <category term="LaTeX"/>
    <category term="Linux"/>
    <link href="http://notes.lokorin.org/2009/7/10/exporting-from-dia-to-latex" rel="alternate" type="text/html"/>
    <title>Exporting from dia to LaTeX</title>
<content type="html">
            &lt;p&gt;Exporting diagrams from &lt;a href='http://live.gnome.org/Dia'&gt;Dia&lt;/a&gt; into LaTeX (with LaTeX fonts etc) is quite easy once you figure out how to do it. There are several TeX exporting options in Dia, but this is the only one that I could get to produce satisfying results.&lt;/p&gt;


	&lt;p&gt;Using Dia 0.97, or later, export the diagram as MetaPost. Then run &lt;code&gt;mptopdf&lt;/code&gt; on the exported metapost to get a shiny pdf to include in the LaTeX document.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://notes.lokorin.org/">
    <author>
      <name>Lokorin</name>
    </author>
    <id>tag:notes.lokorin.org,2009-07-08:138</id>
    <published>2009-07-08T14:29:00Z</published>
    <updated>2010-01-05T20:06:46Z</updated>
    <category term="Matlab"/>
    <link href="http://notes.lokorin.org/2009/7/8/exporting-graphs-from-matlab" rel="alternate" type="text/html"/>
    <title>Exporting Graphs from Matlab</title>
<content type="html">
            &lt;p&gt;Matlab can be nice for cobbling some plots together. Exporting said plots can be a pain though. Thankfully &lt;a href='http://www.mathworks.com/company/newsletters/digest/june00/export/'&gt;exportfig.m makes it a bit easier&lt;/a&gt; .&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://notes.lokorin.org/">
    <author>
      <name>Lokorin</name>
    </author>
    <id>tag:notes.lokorin.org,2009-04-10:137</id>
    <published>2009-04-10T16:31:00Z</published>
    <updated>2009-04-10T16:32:34Z</updated>
    <category term="Linux"/>
    <link href="http://notes.lokorin.org/2009/4/10/detaching-shell-commands-take-two" rel="alternate" type="text/html"/>
    <title>Detaching Shell Commands - Take Two</title>
<content type="html">
            &lt;p&gt;I previously made a note about how &lt;a href='http://notes.lokorin.org/2008/4/18/daemonize-shell-commands'&gt;one can close standard input to detach a shell command from the terminal&lt;/a&gt;. I recently discovered &lt;a href='http://en.wikipedia.org/wiki/Nohup'&gt;the nohup command&lt;/a&gt;, which has a similar purpose.&lt;/p&gt;


	&lt;p&gt;The nohup command seems to emulate an attached process better. I ran across some obscure behaviour where &lt;a href='http://www.ffmpeg.org/'&gt;ffmpeg&lt;/a&gt; would fail to decode a video file if standard input was closed, but not if it was left attached to a terminal or if nohup was used.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://notes.lokorin.org/">
    <author>
      <name>Lokorin</name>
    </author>
    <id>tag:notes.lokorin.org,2009-02-05:136</id>
    <published>2009-02-05T15:48:00Z</published>
    <updated>2009-02-05T15:48:41Z</updated>
    <category term="Misc"/>
    <link href="http://notes.lokorin.org/2009/2/5/including-date-and-time-in-thunderbird-reply" rel="alternate" type="text/html"/>
    <title>Including date and time in Thunderbird reply</title>
<content type="html">
            &lt;p&gt;It is possible to configure Thunderbird to include the date and time of the mail being replied to. I.e. to replace&lt;/p&gt;


&lt;pre&gt;Foo wrote:
&amp;gt; Hello Bar!&lt;/pre&gt;

	&lt;p&gt;with&lt;/p&gt;


&lt;pre&gt;On 02/05/2009 11:27 AM, Foo wrote:
&amp;gt; Hello Bar!&lt;/pre&gt;

	&lt;p&gt;It isn&#8217;t done through the configuration dialogs, rather &lt;a href='http://www.mozilla.org/support/thunderbird/tips#beh_replyheader'&gt;it is configured through user.js&lt;/a&gt; (which might have to be created). All one essentially has to do is create a file name &lt;code&gt;user.js&lt;/code&gt; containing&lt;/p&gt;


&lt;pre&gt;user_pref(&quot;mailnews.reply_header_type&quot;, 2);&lt;/pre&gt;

	&lt;p&gt;in the Thunderbird profile directory.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://notes.lokorin.org/">
    <author>
      <name>Lokorin</name>
    </author>
    <id>tag:notes.lokorin.org,2009-02-02:135</id>
    <published>2009-02-02T11:40:00Z</published>
    <updated>2009-02-02T11:48:34Z</updated>
    <category term="Web"/>
    <link href="http://notes.lokorin.org/2009/2/2/complete-referrals-in-google-analytics" rel="alternate" type="text/html"/>
    <title>Complete referrals in Google Analytics</title>
<content type="html">
            &lt;p&gt;Referring urls in Google Analytics are stripped from query parameters. This makes it hard to know e.g. what thread a referral came from, since that information is typically contained in the referrer&#8217;s query parameters. There exists &lt;a href='http://www.reubenyau.com/google-analytics-hack-obtaining-full-referring-url/'&gt;a couple of workarounds to the problem&lt;/a&gt;, which &lt;a href='http://www.savio.no/blogg/a/26/google-analytics-vis-fullstendig-refererende-url'&gt;a Norweigan blogger&lt;/a&gt; has improved upon.&lt;/p&gt;


	&lt;p&gt;The final remedy is to edit the analytics account and add a filter. The filter should have the following settings:&lt;/p&gt;


&amp;lt;dl&gt;
&lt;dt&gt;Filter Type&lt;/dt&gt;&lt;dd&gt;Custom filter, select Advanced&lt;/dd&gt;
&lt;dt&gt;Field A -&amp;gt; Extract A&lt;/dt&gt;&lt;dd&gt;Referral: (.*)&lt;/dd&gt;
&lt;dt&gt;Field B -&amp;gt; Extract B&lt;/dt&gt;&lt;dd&gt;Campaign Medium: (^referral$)|(^organic$)&lt;/dd&gt;
&lt;dt&gt;Output To -&amp;gt; Constructor&lt;/dt&gt;&lt;dd&gt;Campaign Content: $A1&lt;/dd&gt;
&lt;dt&gt;Field A Required&lt;/dt&gt;&lt;dd&gt;Yes&lt;/dd&gt;
&lt;dt&gt;Field B Required&lt;/dt&gt;&lt;dd&gt;Yes&lt;/dd&gt;
&lt;dt&gt;Override Output Field&lt;/dt&gt;&lt;dd&gt;Yes&lt;/dd&gt;
&amp;lt;/dl&gt;
          </content>  </entry>
  <entry xml:base="http://notes.lokorin.org/">
    <author>
      <name>Lokorin</name>
    </author>
    <id>tag:notes.lokorin.org,2008-08-17:134</id>
    <published>2008-08-17T19:50:00Z</published>
    <updated>2009-02-02T11:46:43Z</updated>
    <category term="Linux"/>
    <link href="http://notes.lokorin.org/2008/8/17/search-and-replace-in-multiple-files" rel="alternate" type="text/html"/>
    <title>Search and replace in multiple files</title>
<content type="html">
            &lt;p&gt;This is always a nice snippet to have around:&lt;/p&gt;


&lt;pre&gt;for i in `find . -name '*.ext'`; do perl -pi -e 's/foo/bar/' &quot;$i&quot;; done&lt;/pre&gt;

	&lt;p&gt;It searches the current directory and all children recursively and replaces &#8220;foo&#8221; with &#8220;bar&#8221; in all files with names matching &#8221;*.ext&#8221;.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://notes.lokorin.org/">
    <author>
      <name>Lokorin</name>
    </author>
    <id>tag:notes.lokorin.org,2008-07-28:133</id>
    <published>2008-07-28T20:32:00Z</published>
    <updated>2008-07-28T20:33:49Z</updated>
    <category term="Ruby"/>
    <link href="http://notes.lokorin.org/2008/7/28/upgrading-rubygems-and-building-binary-windows-distributions" rel="alternate" type="text/html"/>
    <title>Upgrading RubyGems and building binary Windows distributions</title>
<content type="html">
            &lt;p&gt;I have been using RubyGems 0.9.4 for quite a while, putting off upgrading to 1.* due to the problems it brings with building &lt;a href='http://gecoder.rubyforge.org/'&gt;Gecode/R&lt;/a&gt;. The problem is that Gecode/R has a binary distribution with pre-compiled binaries for Windows. The binary distribution has to be marked with its platform to keep it separate from the source distributions. Before RubyGems 1.* this was done by setting the gemspec&#8217;s platform attribute as follows&lt;/p&gt;


	&lt;pre&gt;&lt;code&gt;spec.platform = Gem::Platform::WIN32&lt;/code&gt;&lt;/pre&gt;


	&lt;p&gt;This however stopped working in 1.*, returning the following error message.&lt;/p&gt;


	&lt;pre&gt;&lt;code&gt;WIN32 has been removed, use CURRENT instead&lt;/code&gt;&lt;/pre&gt;


	&lt;p&gt;All &lt;code&gt;Gem::Platform::&lt;/code&gt; constants other than &lt;span class='caps'&gt;RUBY&lt;/span&gt; and &lt;span class='caps'&gt;CURRENT&lt;/span&gt; were removed.&lt;/p&gt;


	&lt;p&gt;&lt;a href='http://www.rubygems.org/'&gt;The RubyGems user documentation website&lt;/a&gt; hasn&#8217;t been updated since 0.8.7, so it isn&#8217;t easy to find information on why this change was made or how one should now build binary packages for platforms other than the host platform. Looking at the RubyGems source code however reveals that there is still some legacy support; one just has to avoid using the removed constants. The solution is to set the platform in the gemspec using&lt;/p&gt;


	&lt;pre&gt;&lt;code&gt;spec.platform = 'mswin32'&lt;/code&gt;&lt;/pre&gt;


	&lt;p&gt;and things will be back to normal (until the legacy support is removed).&lt;/p&gt;
          </content>  </entry>
</feed>
