<?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>Geekchef.com &#187; Tips</title>
	<atom:link href="http://geekchef.com/category/tips/feed/" rel="self" type="application/rss+xml" />
	<link>http://geekchef.com</link>
	<description></description>
	<lastBuildDate>Sat, 09 Jul 2011 18:12:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>All Wikipedia roads lead to Philiosophy</title>
		<link>http://geekchef.com/all-wikipedia-roads-lead-to-philiosophy/</link>
		<comments>http://geekchef.com/all-wikipedia-roads-lead-to-philiosophy/#comments</comments>
		<pubDate>Fri, 27 May 2011 00:01:55 +0000</pubDate>
		<dc:creator>narc</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[wikipedia]]></category>
		<category><![CDATA[xkcd]]></category>

		<guid isPermaLink="false">http://geekchef.com/?p=234</guid>
		<description><![CDATA[Today&#8217;s xkcd called Extended Mind has a interesting tooltip: Wikipedia trivia: if you take any article, click on the first link in the article text not in parentheses or italics, and then repeat, you will eventually end up at "Philosophy". Too cool. Let&#8217;s try this: Potato Starch (starchy) Carbohydrate Organic compound Gas (gaseous) State of ]]></description>
			<content:encoded><![CDATA[<p>Today&#8217;s xkcd called <a href="http://xkcd.com/903/">Extended Mind</a> has a interesting tooltip:</p>
<pre>Wikipedia trivia: if you take any article, click on the first link
in  the article text not in parentheses or italics, and then repeat,
you  will eventually end up at "Philosophy".</pre>
<p>Too cool.  Let&#8217;s try this:</p>
<ul>
<li><em>Potato</em></li>
<li><em>Starch (starchy)</em></li>
<li><em>Carbohydrate</em></li>
<li><em>Organic compound</em></li>
<li><em>Gas (gaseous)</em></li>
<li><em>State of matter (The three classical states)</em></li>
<li><em>Phase (matter)</em></li>
<li><em>Outline of physical science (physical science)</em></li>
<li><em>Natural science</em></li>
<li><em>Science</em></li>
<li><em>Knowledge</em></li>
<li><em>Fact</em></li>
<li><em>Information</em></li>
<li><em>Sequence</em></li>
<li><em>Mathematics</em></li>
<li><em>Quantity</em></li>
<li><em>Property (philosophy)</em></li>
<li><em>Modern philosophy</em></li>
<li><em>Philosophy</em></li>
</ul>
<p>All right!</p>
<p>&nbsp;</p>
<p>Now, YMMV: There seems to be a movement of people of sorts editing Wikipedia, trying to break the loop to Philosophy (source: <a href="http://news.ycombinator.com/item?id=2584704">Hacker News</a>).</p>
<p>Boy, they have more time on their hands than me <img src='http://geekchef.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
]]></content:encoded>
			<wfw:commentRss>http://geekchef.com/all-wikipedia-roads-lead-to-philiosophy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Arduino: a board and a philosophy</title>
		<link>http://geekchef.com/arduino-a-board-and-a-philosophy/</link>
		<comments>http://geekchef.com/arduino-a-board-and-a-philosophy/#comments</comments>
		<pubDate>Thu, 10 Mar 2011 03:24:22 +0000</pubDate>
		<dc:creator>narc</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[hardware]]></category>
		<category><![CDATA[open-source]]></category>

		<guid isPermaLink="false">http://geekchef.com/?p=172</guid>
		<description><![CDATA[I&#8217;ve been working at my new job for over a year and what&#8217;s really different from all my previous jobs is the close relation that I have now with hardware.  Of course, programmers use computers, which is primarily &#8220;hardware&#8221; but most of the hardware I use now is built on the spot.  And meeting all ]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working at my new job for over a year and what&#8217;s really different from all my previous jobs is the close relation that I  have now with hardware.  Of course, programmers use computers, which is primarily &#8220;hardware&#8221; but most of the hardware I use now is built on the spot.  And meeting all the tech guys that actually handle the hardware (both on the building and programming sides) is really interesting: I can peek into one&#8217;s microscope to see the boards up close, ask them questions about things that I never learned in programming classes, about compilers, peripherals and all sorts of hacks &#8230;  This got me a little more interested in building my own small electonic projects but I didn&#8217;t know where to start.</p>
<p>So one of my colleagues directed me to a fine website called <a title="Hack a Day" href="http://hackaday.com" target="_blank">Hack a Day</a>, which, according to him, is a good start for an amateur like me.  They have all sorts of posts for beginners to look into, especially <a title="Dev Board Breakdown" href="http://hackaday.com/2011/02/01/what-development-board-to-use/" target="_blank">a great article on various development boards to choose from</a>.  I heard a lot about the <a title="Arduino official site" href="http://arduino.cc" target="_blank">Arduino</a> board, which claims to be &#8220;open-source&#8221;.  I got curious and read a little about it.  The site also featured <a title="Arduino: The documentary." href="http://arduinothedocumentary.org/" target="_blank">this wonderful documentary</a> on the Arduino: Yes!  Open-source hardware exists and it&#8217;s something that falls right into the kind of things I&#8217;m interested in.  This documentary didn&#8217;t just give me some bits of information, it explained to me a philosophy; something, I believe, should always be a part of the art of programming.</p>
<p>Now I haven&#8217;t really used one yet, mind you.  But this got me really interested on getting one very soon.</p>
<p>You can check out the documentary below (and use full screen) or check out <a title="Arduino: The documentary." href="http://arduinothedocumentary.org/" target="_blank">http://arduinothedocumentary.org</a> for other viewing / downloading options.</p>
<p><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="440" height="225"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="quality" value="high" /><param name="cachebusting" value="true" /><param name="bgcolor" value="#000000" /><param name="movie" value="http://www.archive.org/flow/flowplayer.commercial-3.2.1.swf" /><param name="flashvars" value="config={'key':'#$aa4baff94a9bdcafce8','playlist':['format=Thumbnail?.jpg',{'autoPlay':false,'url':'Arduino.The.Documentary.2010.English_512kb.mp4'}],'clip':{'autoPlay':true,'baseUrl':'http://www.archive.org/download/Arduino.TheDocumentary.English/','scaling':'fit','provider':'h264streaming'},'canvas':{'backgroundColor':'#000000','backgroundGradient':'none'},'plugins':{'controls':{'playlist':false,'fullscreen':true,'height':26,'backgroundColor':'#000000','autoHide':{'fullscreenOnly':true}},'h264streaming':{'url':'http://www.archive.org/flow/flowplayer.pseudostreaming-3.2.1.swf'}},'contextMenu':[{},'-','Flowplayer v3.2.1']}" /><embed type="application/x-shockwave-flash" width="400" height="225" src="http://www.archive.org/flow/flowplayer.commercial-3.2.1.swf" allowfullscreen="true" allowscriptaccess="always" cachebusting="true" bgcolor="#000000" quality="high" flashvars="config={'key':'#$aa4baff94a9bdcafce8','playlist':['format=Thumbnail?.jpg',{'autoPlay':false,'url':'Arduino.The.Documentary.2010.English_512kb.mp4'}],'clip':{'autoPlay':true,'baseUrl':'http://www.archive.org/download/Arduino.TheDocumentary.English/','scaling':'fit','provider':'h264streaming'},'canvas':{'backgroundColor':'#000000','backgroundGradient':'none'},'plugins':{'controls':{'playlist':false,'fullscreen':true,'height':26,'backgroundColor':'#000000','autoHide':{'fullscreenOnly':true}},'h264streaming':{'url':'http://www.archive.org/flow/flowplayer.pseudostreaming-3.2.1.swf'}},'contextMenu':[{},'-','Flowplayer v3.2.1']}"></embed></object></p>
<p>Happy hacking.</p>
]]></content:encoded>
			<wfw:commentRss>http://geekchef.com/arduino-a-board-and-a-philosophy/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Converting *.mp4 to *.wav with MPlayer</title>
		<link>http://geekchef.com/converting-mp4-to-wav-with-mplayer/</link>
		<comments>http://geekchef.com/converting-mp4-to-wav-with-mplayer/#comments</comments>
		<pubDate>Sun, 06 Jun 2010 14:12:24 +0000</pubDate>
		<dc:creator>narc</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[audacity]]></category>
		<category><![CDATA[mp4]]></category>
		<category><![CDATA[mplayer]]></category>
		<category><![CDATA[wav]]></category>

		<guid isPermaLink="false">http://geekchef.com/?p=74</guid>
		<description><![CDATA[Recently, my Japanese teacher has been sending me audio dictations in mp4 formats. It&#8217;s not a problem in itself since MPlayer or any other Linux player can read it. But nothing beats Audacity for listening and re-listening the hard parts (and change the tempo when things get really hard) but it doesn&#8217;t support MPA&#8217;s (or ]]></description>
			<content:encoded><![CDATA[<p>Recently, my Japanese teacher has been sending me audio dictations in mp4 formats.  It&#8217;s not a problem in itself since <a href="http://www.mplayerhq.hu">MPlayer</a> or any other Linux player can read it.  But nothing beats <a href="http://audacity.sourceforge.net/">Audacity</a> for listening and re-listening the hard parts (and change the tempo when things get really hard) but it doesn&#8217;t support MPA&#8217;s (or rather, it simply and unequivocally crashes). For the last 3 or 4 lessons, I still haven&#8217;t mastered this single line of Kung Fu to convert it with MPlayer:</p>
<pre>mplayer -ao pcm:file=&lt;out file&gt;.wav &lt;in file&gt;.mpa
</pre>
<p>Notice how the pcm:file replaces the old syntax.  MPlayer (on Ubuntu at least) will warn you about this.</p>
<p>Hopefully I&#8217;ll stop scouring the &#8216;Net and go straight to this page if my memory fails.  And I hope you do too <img src='http://geekchef.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://geekchef.com/converting-mp4-to-wav-with-mplayer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>More Doom obsession with Ubuntu PowerPC</title>
		<link>http://geekchef.com/more-doom-obsession-with-ubuntu-powerpc/</link>
		<comments>http://geekchef.com/more-doom-obsession-with-ubuntu-powerpc/#comments</comments>
		<pubDate>Sat, 24 Apr 2010 15:01:59 +0000</pubDate>
		<dc:creator>narc</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[compiling]]></category>
		<category><![CDATA[Doom]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PowerPC]]></category>

		<guid isPermaLink="false">http://geekchef.com/?p=57</guid>
		<description><![CDATA[Continuing with my obsession with Doom &#8211; as decribed in my previous post &#8211; I tried compiling my modified original source on a PowerPC running both Mac OS X and Ubuntu Linux. Since they both have the X Windows system, it should work. Today&#8217;s post will be about Ubuntu. Relevant libraries I guess I got ]]></description>
			<content:encoded><![CDATA[<p>Continuing with my obsession with Doom &#8211; as decribed in my <a href="http://geekchef.com/running-doom-under-linux/">previous post</a> &#8211; I tried compiling my modified original source on a PowerPC running both Mac OS X and Ubuntu Linux.  Since they both have the X Windows system, it should work.  Today&#8217;s post will be about Ubuntu.</p>
<h2>Relevant libraries</h2>
<p>I guess I got ahead of myself last time when I suggested to simply type &#8216;make&#8217; to compile.  In fact, they are a few packages that must be installed on Ubuntu.  So install the relevant X developement libraries like so:</p>
<pre>
sudo apt-get install xlibs-dev x11proto-xext-dev libxext-dev
</pre>
<p>Compiling linuxdoom will yield a new set of errors that I hadn&#8217;t notice the first time around on a Intel x86 PC.</p>
<h2>Endianess</h2>
<p>Endianess, for those who might not know, is how computer store numbers in the processor and, corollarily, on  other devices in the system. On a big endian system, like a PowerPC, the numbers are stored, byte per byte with the highest values first. On a little endian system, such as the Intel x86 family, it&#8217;s stored with the smallest values first. Originally, Doom used a little endian scheme under DOS, so a Linux port that runs on an x86 would have no trouble with it.  For big endian, you need to swap the values.  Not necessarily all of them but certainly those who affect the devices: video, filesystem, etc.  There are many references in linuxdoom to macros called SHORT() or LONG() that wrap certain values for this purpose. So the Doom porters added some extra pre-processor switches where a conversion will happen if you happen to compile on a big endian system.  But is this enough &#8230; ?</p>
<p>Here&#8217;s what you get in m_swap.h:</p>
<pre>

// Endianess handling.
// WAD files are stored little endian.
#ifdef __BIG_ENDIAN__
short	SwapSHORT(short);
long	SwapLONG(long);
#define SHORT(x)	((short)SwapSHORT((unsigned short) (x)))
#define LONG(x)         ((long)SwapLONG((unsigned long) (x)))
#else
#define SHORT(x)	(x)
#define LONG(x)     (x)
#endif
</pre>
<p>And here&#8217;s what you get in m_swap.c:</p>
<pre>

// Not needed with big endian.
#ifndef __BIG_ENDIAN__

// Swap 16bit, that is, MSB and LSB byte.
unsigned short SwapSHORT(unsigned short x)
{
    // No masking with 0xFF should be necessary.
    return (x>>8) | (x<<8);
}

// Swapping 32bit.
unsigned long SwapLONG( unsigned long x)
{
    return
	(x>>24)
	| ((x>>8) &#038; 0xff00)
	| ((x<<8) &#038; 0xff0000)
	| (x<<24);
}

#endif
</pre>
<p>First, even as #ifdef __BIG_ENDIAN__ in m_swap.h will set prototypes for the swap functions SwapSHORT() and SwapLONG(), it is incompatible with the fact that w_swap.c wraps these functions with #ifndef __BIG_ENDIAN__. We couldn't notice this error under x86 compilation - although the compiler could have warned us that the prototypes were missing - but on a PowerPC, it will fail.</p>
<p>So change the line in m_swap.c from</p>
<pre>
#ifndef __BIG_ENDIAN__
</pre>
<p>to</p>
<pre>
#ifdef __BIG_ENDIAN__
</pre>
<p>Next, the values between the prototypes and the definitions are all wrong.  In the header file, SwapSHORT() and SwapLONG() both take and return <u>signed</u> values, whereas in the .c file, they're all <u>unsigned</u>.  Change the signed ones in m_swap.h like so:</p>
<pre>
unsigned short   SwapSHORT(unsigned short);
unsigned long    SwapLONG(unsigned long);
</pre>
<p>These changes should make the linuxdoom code compile (with all its usual sets of warnings).</p>
<h2>The sound server</h2>
<p>What about the sound server ? It does compile and is set up to its right endianness.  But the sound comes out all scratchy. It is possible that the conversion process was not complete.  For the moment I have no solution for that.  You can still compile the main linuxdoom source without the -DSNDSERV flag in the Makefile.</p>
<h2>Final words</h2>
<p>So, just like the x86 version on my previous post, start a new X session in 8 bit colors, open a console, set the environment variable for DOOM, make sure your Doom IWAD is present (and the sound server if you like scratchy noises) and voilà.</p>
<p>Next stop: Mac OS X.</p>
]]></content:encoded>
			<wfw:commentRss>http://geekchef.com/more-doom-obsession-with-ubuntu-powerpc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Running Doom under Linux</title>
		<link>http://geekchef.com/running-doom-under-linux/</link>
		<comments>http://geekchef.com/running-doom-under-linux/#comments</comments>
		<pubDate>Thu, 15 Apr 2010 01:41:56 +0000</pubDate>
		<dc:creator>narc</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[compiling]]></category>
		<category><![CDATA[Doom]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://geekchef.com/?p=31</guid>
		<description><![CDATA[I love Doom. Actually, Doom II was the first PC game I ever got in my hands onto. The game was fast-paced, gritty and scary like hell, even with its 8 bit architecture. The sound was ominous, the levels and monsters were darn frikin&#8217; hard to go against &#8230; I totally agree with anyone that ]]></description>
			<content:encoded><![CDATA[<p>I love Doom.  Actually, Doom II was the first PC game I ever got in my hands onto.  The game was fast-paced, gritty and scary like hell, even with its 8 bit architecture.  The sound was ominous, the levels and monsters were darn frikin&#8217; hard to go against &#8230; I totally agree with anyone that would put it onto their top list of games since the beginning of that instrustry we call &#8220;gaming&#8221;.</p>
<p>This post is about compiling Doom on a modern Linux distro.</p>
<p>The source of the Doom engine (which ran Doom, Doom II, and Ultimate Doom) was released in 1997 as a Linux port that used X with a separate sound server.  It is still available <a href="ftp://ftp.idsoftware.com/idstuff/source/doomsrc.zip">here</a>.</p>
<p>I got interested in the source code in 2003 and started taking notes about compilation, PCX and 8bit paletting, and WAD (de)construction.  Now, in 2010, I re-read my notes and decided to give it a go again, this time putting those notes public, although there&#8217;s nothing really new here for anyone.  With so many ports of Doom that have spawned over the years, there are better options today in playing Doom with full screen graphics, perhaps in 3D, and MP3 sound and music instead using 16 bit mono WAVs and on board MIDI.</p>
<p>But I like retro stuff and this is as close as we can get to the original.  <a href="http://www.atomicgamer.com/files/1940/sdldoom-1-10-tar-gz">The SDL version</a>, made by SDL creator Sam Lantinga, is a straightfoward port of the original with sound and can run on 640 x 480 without palletting.  It&#8217;s a great way to see how SDL works. But before compiling that version, keep reading this post, there is at least one modification you should be aware of.</p>
<h3>Fixing errors and compiling</h3>
<p>The first thing about Doom, is that its creator, id software, did released the source code but not any of the data files to run it, called IWADs, which contain the images and sounds of the game. You must either have the commercial version of Doom, Doom II or Ultimate Doom, or the shareware version (a copy of the shareware IWAD is available <a href="http://firehead.org/~jessh/lsdldoom/">here</a>). Unzip it and put that file somewhere on your system.  We&#8217;ll need to point to it later on.</p>
<p>Unzipping the file gives you two packages, the source code of DOOM and a separate sound server that Doom will imbed at run time (apparrently, id licenced a copyrighted sound engine at the time, which is why there is no original DOS release: &#8216;A mistake&#8217; says John Carmack in the README.TXT file.)</p>
<p>Unzip the source code and make the following changes:</p>
<p>In i_video:49, replace</p>
<pre>
#include &lt;errnos.h&gt;
</pre>
<p>with</p>
<pre>
#include &lt;errno.h&gt;
</pre>
<p>In i_sound.c:166 and i_video.c:669, delete all declarations of</p>
<pre>
extern int errno;
</pre>
<p>and include this file somewhere at the top of i_sound.c:</p>
<pre>
#include &lt;errno.h&gt;
</pre>
<p>In s_sound.c:367, replace</p>
<pre>
#ifndef SNDSRV
</pre>
<p>with</p>
<pre>
#ifndef SNDSERV
</pre>
<p>In the Makefile, add the -DSNDSERV define for compilation.</p>
<p>Finally, <u>and this affects both the original and SDLDoom</u>, change d_main.c:587 from</p>
<pre>
doomuwad = malloc(strlen(doomwaddir)+1+8+1);
</pre>
<p>to</p>
<pre>
doomuwad = malloc(strlen(doomwaddir)+1+9+1);
</pre>
<p>This &#8220;off-by-one&#8221; error will generate a ASSERT error in malloc.c:3074 once the X display kicks in.  The gdb debugger will tell you so, and yet we are very far from any video initialization at this moment.  It took me a while to trap this.</p>
<p>Compile by simply calling &#8216;make&#8217; at the command line. Everything should compile under 30 seconds.  Don&#8217;t (?) worry about all the warnings you&#8217;ll see passing by.  They shouldn&#8217;t affect the game at this point.  Feel free to clean up the code if you like.</p>
<h3>Compiling the sound server</h3>
<p>Unzip the sound server&#8217;s package and change to that directory. Simply call &#8216;make&#8217; at the command line.</p>
<p>Move the &#8216;sndserver&#8217; binary located in the &#8216;linux&#8217; directory to the same directory you put your IWAD, mentionned above.</p>
<h3>Switching to 8 bit</h3>
<p>Doom runs in 8 bit (256 palettized colors) at a whoppin size of 320 x 200 pixels. It&#8217;s better to simply call another X desktop instead of ruining your current setup.</p>
<p>Issue the following on the command line.</p>
<pre>
sudo startx -- :1 -depth 8 vt8
</pre>
<p>This starts another desktop at vt8 (i.e. Ctrl-Alt-F8. You can return to your original desktop with Ctrl-Alt-F7 or loggin off from that session). You&#8217;ll notice how rough your desktop will look because of the 8 bit palette it&#8217;s running on.</p>
<p>Note that you will be running your new desktop with super-user privileges, so be VERY careful.</p>
<p>Open up a console and set an environment variable called DOOMWADDIR like so:</p>
<pre>
export DOOMWADDIR=&lt;my path&gt;
</pre>
<p>and replace &lt;my path&gt; with the location of the IWAD and sound server.  If you dip into the code, there always a way to set those changes to a permanent location without defining this value or doing it through some parameter. </p>
<p>You can now run the binary located at linux/linuxdoom in the source code directory.</p>
<p>You&#8217;ll see your desktop flashing because Doom will set up its palette to it.</p>
<p>Voilà.  Enjoy playing Doom on an itsy bitsy scale. <img src='http://geekchef.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>You can alway resize your desktop to 640 x 480 to see it a little larger.  Don&#8217;t forget to set it back to its original size.  I believe if you don&#8217;t, it will screw up your default settings once you run X again from a fresh boot.</p>
<p>If you don&#8217;t want to go through all this trouble, make the change I recommend to d_main.c:587 in SDLDoom, compile it and call the -fullscreen parameter to play Doom at a reasonable scale.</p>
]]></content:encoded>
			<wfw:commentRss>http://geekchef.com/running-doom-under-linux/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Eliminating those pesky ^M&#8217;s in Vim</title>
		<link>http://geekchef.com/eliminating-those-pesky-ms-in-vim/</link>
		<comments>http://geekchef.com/eliminating-those-pesky-ms-in-vim/#comments</comments>
		<pubDate>Mon, 05 Apr 2010 17:46:35 +0000</pubDate>
		<dc:creator>narc</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[EOL]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://s156557655.onlinehome.us/www/blog2/?p=8</guid>
		<description><![CDATA[One on my pet peeves is dealing with a file using the 0x0D end-of-line (EOL) marquer. Such is the legacy of the Mac standard. Unix variants use 0x0A generally but even though Mac OS X is based on Unix, its seems that software used in that environment continues to produce the same old format. But ]]></description>
			<content:encoded><![CDATA[<p>One on my pet peeves is dealing with a file using the 0x0D end-of-line (EOL) marquer.  Such is the legacy of the Mac standard.  Unix variants use 0x0A generally but even though Mac OS X is based on Unix, its seems that software used in that environment continues to produce the same old format.</p>
<p>But I&#8217;ve seen changes recently: one of my friends, an avid Mac user, updated a Web site lately, all pages with the correct EOL character &#8230; or at least his software does; I&#8217;m not sure if he noticed the difference anyways.</p>
<p><em>&lt;tone down&gt;</em>Shhhh. He <span style="text-decoration: underline;">still</span> uses ISO-8859-1 encoding<em>&lt;/tone down&gt;</em></p>
<p>Still, there are plenty of legacy files out there and it kills me when I have to edit one of those with my favorite editor, <a title="Vim" href="http://www.vim.org/" target="_blank">vim</a>, and see all the lines squeezed into one big mess, intercalated with <strong>^M</strong>&#8216;s .</p>
<p>It kills me because there is a simple trick to correct this &#8230; and I always forget it. Aaaaarrrrgh!</p>
<p>This is why blogs exist: to keep your own tips on-line so you can check them out once in a while (and if other people check them out too, that&#8217;s also a Good Thing ™).</p>
<p>Here&#8217;s vim&#8217;s quick shortcut to stop this nonsense: enter the usual colon (:) to enable the command mode and enter any typical search-and-replace command using <strong>{Ctrl-V}{Ctrl-M}</strong> as the search pattern. Replace with a newline code such as<strong> \r</strong>, or nothing if you suspect the ^M&#8217;s are doubled with extra line feeds, like so:</p>
<p><code>1,$s/{Ctrl-V}{Ctrl-M}/\r/g</code></p>
<p>What you&#8217;ll actually see is this:</p>
<p><code>1,$s/<strong>^M</strong>/\r/g</code></p>
<p>There.  I feel much better now.</p>
<p>Now, don&#8217;t get me started on Microsoft&#8217;s 0x0A 0x0D sequence. <img src='http://geekchef.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   Vim always dealt with it seamlessly as its &#8220;converted&#8221; mode. You can&#8217;t see the difference as you edit such file but you still output the same garbage once you save it. I wonder why no one thought about a similar filter for the 0x0D case. But my guess is that it will slowly phase out &#8230; event﻿ually.</p>
]]></content:encoded>
			<wfw:commentRss>http://geekchef.com/eliminating-those-pesky-ms-in-vim/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

