<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg-flat.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
  <title>outer haven</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <link rel="stylesheet" href="/static/style.css" type="text/css" />
  <link rel="alternate" type="application/rss+xml" title="outer haven RSS feed" href="/view/index.rss" />
  <link rel="alternate" type="text/plain" title="outer haven in plain text" href="/view/index.txt" />
	<script type="text/javascript" src="/static/mootools.js"></script>
</head>
<body>

<div id="main">
  <div id="header">
    <h1><a  href="http://qrunk.com/view/">outer haven</a></h1>
    
  </div>
  <div id="sidebar">

	  

    <h3>Authors</h3>
    <ul class="sidebar-list">
    
      <li><a class="author" href="http://qrunk.com/view/by/Mike+Stipicevic/">Mike&nbsp;Stipicevic</a>&nbsp;(11) </li>
    
    </ul>

    

    <h3>Other formats</h3>
    <ul class="sidebar-list">
    <li><a href="/view/index.rss"><img src="/static/rss-badge.png" alt="get in rss!"/></a></li>
    <li><a href="/view/index.txt">plain text version</a></li>
    </ul>
	  <h3><a href="http://qrunk.com/">back to qrunk.com</a></h3>
  </div>
  <div id="content">
    
  <h2><a  href="http://qrunk.com/view/adium-im-stats">Adium IM Stats</a></h2>
  <div class="byline">
    <a  href="http://qrunk.com/view/by/Mike+Stipicevic/">Mike Stipicevic</a>,
    <span title="7 months ago">January 17, 2010  9:16pm</span>
  </div>
  
  <p class='first'>Adium keeps its chat logs in a pretty regular <span class="caps">XML</span> format. This makes it easy to collect some stats without mucking around too much with <span class="caps">XML</span>. Below are some code snippets that will give you a sorted list of who has been IMing you the most:</p>
<pre><code>cd ~/Library/Application\ Support/Adium\ 2.0/Users/Default/Logs/
# for each folder (username) in this directory, run the following:
# (obviously change screenname to whatever your s/n is for each directory. note that screenname comes up twice)
grep -R "&lt;message sender=" ./AIM.billybob123/* | grep -v "&lt;message sender=\"billybob123\"" &gt;&gt; all_logs
cut -f1 -d " " all_logs | cut -f3 -d "/" | sort | uniq -c | sort -r -n -k1  &gt; yes
# yes will contain your sorted list of messages received
</code></pre>

  <h2><a  href="http://qrunk.com/view/macports-compilation-errors">macports compilation errors</a></h2>
  <div class="byline">
    <a  href="http://qrunk.com/view/by/Mike+Stipicevic/">Mike Stipicevic</a>,
    <span title="7 months ago">January 17, 2010  9:04pm</span>
  </div>
  
  <p class='first'>Recently, my macports have been going crazy: I wasn&#8217;t able to install anything because I kept running into &#8216;<code>"/lib/cpp" fails sanity check</code>&#8217; errors. I figured this was a config error because <code>/lib</code> doesn&#8217;t exist on <span class="caps">OSX</span>. Turns out, I had installed <a href="sourceforge.net/projects/mingw-w64/">MinGW64</a> header files into <code>/opt/local/include</code> which were Win32-only. When I built my ports, they would use those headers and invariably fail. The quick solution was to clean out that include directory and <a href="http://trac.macports.org/wiki/Migration">reinstall all Macports</a>.</p>

  <h2><a  href="http://qrunk.com/view/installing-from-a-cd-in-red-hat">Installing from a CD in Red Hat</a></h2>
  <div class="byline">
    <a  href="http://qrunk.com/view/by/Mike+Stipicevic/">Mike Stipicevic</a>,
    <span title="8 months ago">December 16, 2009 12:03am</span>
  </div>
  
  <p class='first'>I recently had to install a copy of Red Hat 5.4 for a client at work. Now, I needed to compile something, so I went to install <span class="caps">GCC</span>. However, since I used the VMWare easy install option, I was never prompted for my Red Hat Network account or password. Since I had the full <span class="caps">DVD</span>, I knew I could just install <span class="caps">GCC</span> from the repo on the disc. But how? Adding a source to yum gave me a weird error: &#8216;<span class="caps">URL</span> must be http, ftp, file or https not &quot;&quot;&#8217;. Given that my url started with file://, I couldn&#8217;t figure out what that meant. It turns out the spaces in the filename were the culprit: neither quoting, escaping, or replacing the spaces with %20 worked. Unfortunately, the Red Hat automounter mounted the disc using its volume name, which had spaces!</p>
<p>The conclusion I had: if you want to install <span class="caps">RHEL</span> packages from a <span class="caps">DVD</span> post-install, you need to unmount the disc (look in /media), remount it using a common location (/media/cd), and add the following to a .repo (my DVD&#8217;s repo was in Server/):</p>
<p><code>baseurl=file:///media/cd/Server</code></p>

  <h2><a  href="http://qrunk.com/view/implementing-lexical-closures-on-a-stack-machine">Implementing Lexical Closures on a Stack Machine</a></h2>
  <div class="byline">
    <a  href="http://qrunk.com/view/by/Mike+Stipicevic/">Mike Stipicevic</a>,
    <span title="9 months ago">December  9, 2009  5:31am</span>
  </div>
  
  <p class='first'>So, I&#8217;ve been studying how to implement things on <span class="caps">LLVM</span>, and I wanted to write down a key insight I had over the past few days. How the hell would I make <a href="http://en.wikipedia.org/wiki/Continuation">continuations</a>? A continuation is a <a href="http://en.wikipedia.org/wiki/Closure_(computer_science)">closure</a> of a function bound with the <strong>entire</strong> global state of the program. This lets you &#8216;warp back&#8217; to a program state at any time, which is surprisingly useful.</p>
<p>Now, the question arises: how to you provide such an environment as a data structure? If I was implementing a language with <a href="http://en.wikipedia.org/wiki/Scope_(programming)#Dynamic_scoping">dynamic scope</a>, the answer is simple: copy and restore the stack. However, most modern languages use <a href="http://en.wikipedia.org/wiki/Scope_(programming)#Static_scoping_.28also_known_as_lexical_scoping.29">lexical scoping</a>. This means that variables must be managed individually instead of &#8220;walking up the stack.&#8221;</p>
<p>My first idea was to hash out something like this:</p>
<ol>
	<li>Set up a global symbol structure</li>
	<li>Whenever these are modified in a block, make a copy of the structure and modify that element</li>
	<li>Pass the new modified environment structure to any called functions</li>
	<li>When the current block returns, flip the environment back</li>
</ol>
<p>Obviously, this involved a <strong>lot</strong> of copying, but I couldn&#8217;t see any other way of implementing this while making sure state propagated down. After all, if function <i>a</i> calls <i>b</i>, and function <i>a</i> locally modifies variable <i>x</i>, it <strong>has</strong> to propagate that change down somehow.</p>
<p>Or does it? Did you spot the error that was plaguing my implementation? I half-forgot that we are using lexical scoping &#8212; a statement like &#8220;a calls b, b must respect the local state of a&#8221; is <i>very</i> false. Luckily, this dramatically simplifies things for us! All we have to do now is keep <strong>one</strong> copy of the global environment around, if anything is locally changed this can be explicitly passed to the new function via an argument: internally, the function will ignore the global symbol and use the argument instead.</p>
<p>This is all very obvious looking back but it was very relieving to figure it out.</p>

  <h2><a  href="http://qrunk.com/view/llvm2cpp-forget-it">llvm2cpp &#8212; forget it</a></h2>
  <div class="byline">
    <a  href="http://qrunk.com/view/by/Mike+Stipicevic/">Mike Stipicevic</a>,
    <span title="9 months ago">December  9, 2009  5:28am</span>
  </div>
  
  <p>Instead of trying to resurrect llvm2cpp, I&#8217;ve just decided to write <span class="caps">LLVM</span> assembly directly to a text file. You lose the ability to do <span class="caps">JIT</span> and some automated stuff, but this is easier for now.</p>

  <h2><a  href="http://qrunk.com/view/accessing-array-pointers-in-llvm">Accessing Array Pointers in <span class="caps">LLVM</span></a></h2>
  <div class="byline">
    <a  href="http://qrunk.com/view/by/Mike+Stipicevic/">Mike Stipicevic</a>,
    <span title="9 months ago">December  3, 2009  4:35am</span>
  </div>
  
  <p class='first'>When using <span class="caps">LLVM</span>, it&#8217;s not immediately clear how to convert arrays into pointers. This may not be the best way to go about it, but this seems to work: use <code>getelementptr</code> on a pointer to the array, then dereference it twice. Let&#8217;s say you have the following array:</p>
<p><code>@cool = internal constant [2 x i64] [i64 1, i64 2]</code></p>
<p>and you want to get into the juicy bits of the array. The following will create an i64* for you based on the 0th element:</p>
<p><code>%intptr = getelementptr [2 x i64]* @cool, i32 0, i32 0</code></p>
<p>which you can then use with <code>load</code> and <code>store</code>.</p>

  <h2><a  href="http://qrunk.com/view/progressbar-marquee-fix">Progressbar Marquee Fix</a></h2>
  <div class="byline">
    <a  href="http://qrunk.com/view/by/Mike+Stipicevic/">Mike Stipicevic</a>,
    <span title="9 months ago">December  2, 2009 10:56pm</span>
  </div>
  
  <p class='first'>For work I needed to add a small screen with a progressbar using the Windows <span class="caps">API</span>. I wanted to use the marquee property to specify that the operation was running, but would take an indefinite amount of time. Now, I coded the progressbar and got it to display, but it wouldn&#8217;t marquee! If I set a position it would display fine, implying that most of the code was working properly. It turns out that the marquee property needs to be enabled by activating a newer version of a library. This <span class="caps">MSDN</span> <a href="http://msdn.microsoft.com/en-us/library/bb773175(VS.85).aspx#whistler_windows">page</a> shows several options to enable this, but it was a pretty annoying problem to solve.</p>

  <h2><a  href="http://qrunk.com/view/found-an-llvm-tip">Found an <span class="caps">LLVM</span> Tip</a></h2>
  <div class="byline">
    <a  href="http://qrunk.com/view/by/Mike+Stipicevic/">Mike Stipicevic</a>,
    <span title="9 months ago">December  1, 2009  7:04am</span>
  </div>
  
  <p class='first'>I found some better <a href="http://llvm.org"><span class="caps">LLVM</span></a> tips online: this <a href="http://www.mikeash.com/?page=pyblog/friday-qa-2009-04-17-code-generation-with-llvm-part-1-basics.html">tutorial</a> should be a bit more updated than the one on the site. Unfortunately there seems to be no specification of the virtual machine itself; I am currently determing how the <span class="caps">LLVM</span> stack works? Does it go up or down, what are the stack/frame pointers, and how is a frame saved?</p>

  <h2><a  href="http://qrunk.com/view/the-fate-of-llvm2cpp">The Fate of llvm2cpp</a></h2>
  <div class="byline">
    <a  href="http://qrunk.com/view/by/Mike+Stipicevic/">Mike Stipicevic</a>,
    <span title="9 months ago">November 27, 2009  9:20am</span>
  </div>
  
  <p class='first'>Since the <a href="http://llvm.org"><span class="caps">LLVM</span></a> docs are so out-of-whack, the best method to figure out how <span class="caps">LLVM</span> works seems to be through the <a href="http://llvm.org/demo/">live demo</a>. This lets you type in a (complete) C program and get <span class="caps">LLVM</span> bytecode and even C++ <span class="caps">API</span> output. The backend of the <span class="caps">API</span> output is a program called <a href="http://llvm.org/cmds/llvm2cpp.html">llvm2cpp</a>. However, it seems this tool has been deprecated for&#8230; nothing. The docs say <code>llc</code> may duplicate this functionality, but it currently does not. Unfortunately, the web demo doesn&#8217;t do a lot of things <code>llvm2cpp</code> does, mainly function-by-function <span class="caps">API</span> generation. This would have made my experimentation a lot easier; I guess I&#8217;ll try to piece together things with the web interface or get it to compile on its own.</p>

  <h2><a  href="http://qrunk.com/view/installing-whisper">Installing Whisper</a></h2>
  <div class="byline">
    <a  href="http://qrunk.com/view/by/Mike+Stipicevic/">Mike Stipicevic</a>,
    <span title="9 months ago">November 27, 2009  8:28am</span>
  </div>
  
  <p class='first'>After writing my own web publishing software, I&#8217;ve decided to use someone else&#8217;s for a while. I&#8217;ve settled on using William Morgan&#8217;s Whisper because I like doing things slightly different. There have been a few things I&#8217;ve been tweaking, but I&#8217;m leaving the design for a later date. Right now it&#8217;s a <strong>very</strong> abrupt change from my main site, but deal with it.</p>



  <div class="pageblock">
  
  
    <span class="currentpagelink">1</span>
  
    <a class="pagelink" href="http://qrunk.com/view/index/1">2</a>
  
  &nbsp;<a class="pageword" href="http://qrunk.com/view/index/1">Next</a>
  </div>


  </div>

  <div id="footer" style="margin: 0px;">
    Served up by <a href="http://masanjin.net/whisper/">Whisper</a>.
  </div>
</div>

<script type="text/javascript">
	var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
	document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
	var pageTracker = _gat._getTracker("UA-2212043-4");
	_setDomainName("none");
	_setAllowLinker(enable);
	_setAllowHash("false");
	_link();
	_linkByPost();
	pageTracker._trackPageview();
</script>
</body>
</html>
