<?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>fleshyorgans &#187; code</title> <atom:link href="http://fleshy.org.nz/tag/code/feed/" rel="self" type="application/rss+xml" /><link>http://fleshy.org.nz</link> <description>Essays from a guy with too much pontification on his hands</description> <lastBuildDate>Fri, 27 Apr 2012 05:59:21 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>Link: A Brief, Incomplete, and Mostly Wrong History of Programming Languages</title><link>http://fleshy.org.nz/2010/05/11/link-a-brief-incomplete-and-mostly-wrong-history-of-programming-languages/</link> <comments>http://fleshy.org.nz/2010/05/11/link-a-brief-incomplete-and-mostly-wrong-history-of-programming-languages/#comments</comments> <pubDate>Tue, 11 May 2010 15:24:39 +0000</pubDate> <dc:creator>Jonathan Warner</dc:creator> <category><![CDATA[programming]]></category> <category><![CDATA[tumblr]]></category> <category><![CDATA[code]]></category> <category><![CDATA[computer science]]></category> <category><![CDATA[funlinks]]></category> <category><![CDATA[languages]]></category> <category><![CDATA[links]]></category> <guid
isPermaLink="false">http://fleshyorgans.tumblr.com/post/589786575</guid> <description><![CDATA[<a
href="http://james-iry.blogspot.com/2009/05/brief-incomplete-and-mostly-wrong.html">One Div Zero: A Brief, Incomplete, and Mostly Wrong History of Programming Languages</a>]]></description> <content:encoded><![CDATA[<p><a
href="http://james-iry.blogspot.com/2009/05/brief-incomplete-and-mostly-wrong.html">One Div Zero: A Brief, Incomplete, and Mostly Wrong History of Programming Languages</a><br
/></p> ]]></content:encoded> <wfw:commentRss>http://fleshy.org.nz/2010/05/11/link-a-brief-incomplete-and-mostly-wrong-history-of-programming-languages/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Been awhile, some fun Drupal code-related stuff</title><link>http://fleshy.org.nz/2008/04/14/been-awhile-some-fun-drupal-code-related-stuff/</link> <comments>http://fleshy.org.nz/2008/04/14/been-awhile-some-fun-drupal-code-related-stuff/#comments</comments> <pubDate>Mon, 14 Apr 2008 15:45:39 +0000</pubDate> <dc:creator>Jonathan Warner</dc:creator> <category><![CDATA[general]]></category> <category><![CDATA[code]]></category> <category><![CDATA[mysql]]></category> <category><![CDATA[php]]></category> <category><![CDATA[sqlserver]]></category> <category><![CDATA[work]]></category> <guid
isPermaLink="false">http://fleshy.org.nz/yum/2008/04/14/been-awhile-some-fun-drupal-code-related-stuff/</guid> <description><![CDATA[Been busy with the play and work. We switched to a 4 day, 9 hour work week. So that leaves me with about 2 hours each day for non-theater, non-work related stuff. Not counting the day off, I guess. Anyway, check this out. I have been tasked with writing a SQL Server database module for [...]]]></description> <content:encoded><![CDATA[<p>Been busy with the play and work. We switched to a 4 day, 9 hour work week. So that leaves me with about 2 hours each day for non-theater, non-work related stuff. Not counting the day off, I guess.</p><p>Anyway, check this out. I have been tasked with writing a SQL Server database module for Drupal 6. This is not fun. It&#8217;s slow, Drupal is written poorly for abstraction, and there are odd idiosyncracies one has to deal with. But that&#8217;s not what I want to tell you about.</p><p>This is the vargrind output between a semi-working mssql installation and a working mysql installation. That 400 number is the number of queries the MSSQL module needs to do to render the &#8216;My Account&#8217; page. For comparison, MySQL only requires about 40.</p><p><a
href='http://fleshy.org.nz/yum/wp-content/uploads/2008/04/drupal-mssqlvmysql.png' title='SQL Server versus MySQL'><img
src='http://fleshy.org.nz/yum/wp-content/uploads/2008/04/drupal-mssqlvmysql.thumbnail.png' alt='SQL Server versus MySQL' /></a><br
/> (The reason it&#8217;s so high is because one must select the error code to check for an error, then select the code meaning from the database if there was an actual error. For every query.)<br
/></p> ]]></content:encoded> <wfw:commentRss>http://fleshy.org.nz/2008/04/14/been-awhile-some-fun-drupal-code-related-stuff/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Coding: Rails Issues with :include</title><link>http://fleshy.org.nz/2008/02/23/coding-rails-issues-with-include/</link> <comments>http://fleshy.org.nz/2008/02/23/coding-rails-issues-with-include/#comments</comments> <pubDate>Sat, 23 Feb 2008 17:10:26 +0000</pubDate> <dc:creator>Jonathan Warner</dc:creator> <category><![CDATA[general]]></category> <category><![CDATA[programming]]></category> <category><![CDATA[code]]></category> <category><![CDATA[rails]]></category> <category><![CDATA[ruby]]></category> <guid
isPermaLink="false">http://fleshy.org.nz/yum/2008/02/23/coding-rails-issues-with-include/</guid> <description><![CDATA[This is a sort of code analysis and something I discovered with :include usage in Rails. (This is in rails 1.1.6, so YMMV. I believe the latest Rails opts to use inner SELECTs rather than JOIN statements. Also, this is kind of long.) I have the following association set that represents a document repository. User [...]]]></description> <content:encoded><![CDATA[<p>This is a sort of code analysis and something I discovered with :include usage in Rails. (This is in rails 1.1.6, so YMMV. I believe the latest Rails opts to use inner SELECTs rather than JOIN statements.</p><p> Also, this is kind of long.)<br
/> <span
id="more-805"></span></p><p> I have the following association set that represents a document repository.<br
/> <br/><br
/> User 1-n Folders<br
/> User 1-n Roles<br
/> Folder 1-n Documents<br
/> Documents n-n Brands<br
/> <br/><br
/> Folders n-n Viewer Roles<br
/> Folders n-n Manager Roles<br
/> <br/><br
/> Lastly, Users n -(polymorphic through)- n Brands</p><p> In order to display a tree of Folders a given user can view, that User must<br
/> be a manager or viewer of a Folder, and his Brands contain Brand of at<br
/> least one Document under that Folder (a Document associated with a Brand under a folder lets the user view that Folder iff that user has the Brand.)</p><p> So the way this was originally implemented was a recursive loop<br
/> something like this:</p><blockquote><p> def show_subfolders(folder)<br
/> User.folders.each do |folder|<br
/> show_subfolders(folder)<br
/> end<br
/> end</p><p>Class User<br
/> def folders<br
/> Folder.find(:all,:conditions => &#8216;parent = folder&#8217;,<br
/> :include => [:manager_roles, :viewer_roles, {:documents => :brands]]<br
/> ).each do<br
/> |folder|<br
/> if method_to_check_brands(folder) &#038;&#038; method_to_check_view_perms(folder)<br
/> yield(folder)<br
/> end<br
/> end<br
/> end</p></blockquote><p> The eventual problems that developed with this logic were the following:</p><ol><li>second-level includes are problematic in Rails, this generated<br
/> outer joins against seven tables</li><li>massive join, recursively called. I believe the Big O* is (c!)^n,<br
/> glancing quickly</li><li>Indexes don&#8217;t help, because the outer joins sort of blow the<br
/> performance gains away</li><li>All data is being selected, so just sheer amount of data transfer<br
/> slowed things down</li><li>The yield adds a lot of crap to the callstack</li><li>Brand and View/Manage permissioning was already happening in the code</li></ol><p> With 245 documents under 30 folders, mysql logged slow queries that<br
/> had to examine 320,000 rows &#8212; and that was multiple times.</p><p> The solution? Remove the :includes. Since permissioning and<br
/> restriction was already happening in code, I let Rails do its own<br
/> thing and select when necessary. This lowered the response time from<br
/> 10+ seconds for page view to 0.5 seconds. (And for what it&#8217;s worth,<br
/> doing the join statements manually, or removing the second-level :includes only brings it down to 2 or 3 seconds.)</p><p>By reducing the stuff that needs to join, indices are are used more<br
/> efficiently, and letting Rails do a find for Folder.documents on each<br
/> iteration ends up being a lot faster than trying to join with the<br
/> view/manage/brands permissions.</p><p> The More You Know!</p><p>* It&#8217;s been over a decade since I actually figured out the order of an algorithm. I&#8217;m sort of guessing, here.</p> ]]></content:encoded> <wfw:commentRss>http://fleshy.org.nz/2008/02/23/coding-rails-issues-with-include/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Code: Dynamically Insert HTML Into Any Rendered PHP Page</title><link>http://fleshy.org.nz/2008/02/15/code-dynamically-insert-html-into-any-rendered-php-page/</link> <comments>http://fleshy.org.nz/2008/02/15/code-dynamically-insert-html-into-any-rendered-php-page/#comments</comments> <pubDate>Fri, 15 Feb 2008 15:38:34 +0000</pubDate> <dc:creator>Jonathan Warner</dc:creator> <category><![CDATA[general]]></category> <category><![CDATA[code]]></category> <category><![CDATA[coding]]></category> <category><![CDATA[hacks]]></category> <category><![CDATA[php]]></category> <category><![CDATA[programming]]></category> <guid
isPermaLink="false">http://fleshy.org.nz/yum/2008/02/15/code-dynamically-insert-html-into-any-rendered-php-page/</guid> <description><![CDATA[So, this pleases me enough to post it. dynamic buffer insertion with PHP Needed to quickly add a notice to every page on a client&#8217;s site where there was a single include, but not single-included layout pages (teachers, *sigh*). I&#8217;ve never messed with output buffer stuff before, so this was just sort of surprising to [...]]]></description> <content:encoded><![CDATA[<p>So, this pleases me enough to post it.</p><p><script src='http://pastie.org/152702.js'></script></p><p><a
href="http://pastie.caboo.se/152702">dynamic buffer insertion with PHP</a></p><p>Needed to quickly add a notice to every page on a client&#8217;s site where there was a single include, but not single-included layout pages (teachers, *sigh*).</p><p>I&#8217;ve never messed with output buffer stuff before, so this was just sort of surprising to me. It&#8217;s <em>insanely</em> useful.</p><p>Only took about a minute to code, and two to deploy.</p> ]]></content:encoded> <wfw:commentRss>http://fleshy.org.nz/2008/02/15/code-dynamically-insert-html-into-any-rendered-php-page/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Operator Precedence (ruby et al.)</title><link>http://fleshy.org.nz/2008/02/01/operator-precedence-ruby-et-al/</link> <comments>http://fleshy.org.nz/2008/02/01/operator-precedence-ruby-et-al/#comments</comments> <pubDate>Fri, 01 Feb 2008 15:20:32 +0000</pubDate> <dc:creator>Jonathan Warner</dc:creator> <category><![CDATA[general]]></category> <category><![CDATA[code]]></category> <category><![CDATA[programming]]></category> <category><![CDATA[ruby]]></category> <guid
isPermaLink="false">http://fleshy.org.nz/yum/2008/02/01/operator-precedence-ruby-et-al/</guid> <description><![CDATA[Thought this was a little silly, but it generated a lot of discussion about precedence, short-circuiting of conditionals, and the value of syntactic sugar. http://pastie.caboo.se/146194]]></description> <content:encoded><![CDATA[<p>Thought this was a little silly, but it generated a lot of discussion about precedence, short-circuiting of conditionals, and the value of syntactic sugar.<br
/> <script src='http://pastie.org/146194.js'></script><br
/> <a
href="http://pastie.caboo.se/146194">http://pastie.caboo.se/146194</a></p> ]]></content:encoded> <wfw:commentRss>http://fleshy.org.nz/2008/02/01/operator-precedence-ruby-et-al/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Seriously Word Press, WTH?</title><link>http://fleshy.org.nz/2007/11/04/seriously-word-press-wth/</link> <comments>http://fleshy.org.nz/2007/11/04/seriously-word-press-wth/#comments</comments> <pubDate>Mon, 05 Nov 2007 04:30:16 +0000</pubDate> <dc:creator>Jonathan Warner</dc:creator> <category><![CDATA[general]]></category> <category><![CDATA[programming]]></category> <category><![CDATA[cats]]></category> <category><![CDATA[code]]></category> <category><![CDATA[php]]></category> <guid
isPermaLink="false">http://fleshy.org.nz/yum/archives/777</guid> <description><![CDATA[While trying to figure out how to remove formatting from &#8216;wp_list_cats&#8217; in Word Press, I discovered this awesome bit. Click the thumbnail for the full glory of the code. You will notice that in my screenshot, the final function call to &#8216;list_cats&#8217; at the end is truncated. This is because there are eighteen parameters. Again [...]]]></description> <content:encoded><![CDATA[<p>While trying to figure out how to remove formatting from &#8216;wp_list_cats&#8217; in Word Press, I discovered this awesome bit. Click the thumbnail for the full glory of the code.<br
/> <a
class="imagelink" href="http://fleshy.org.nz/yum/wp-content/uploads/2007/11/wp_list_cats.png" title="WP List Cats Insanity!"><img
id="image775" src="http://src.sencha.io//http://fleshy.org.nz/yum/wp-content/uploads/2007/11/wp_list_cats.thumbnail.png" alt="WP List Cats Insanity!" /></a></p><p>You will notice that in my screenshot, the final function call to &#8216;list_cats&#8217; at the end is truncated. This is because there are <strong>eighteen parameters</strong>. Again with the clicking.<br
/> <a
class="imagelink" href="http://fleshy.org.nz/yum/wp-content/uploads/2007/11/list_cats.png" title="list_cats even more insane!"><img
id="image776" src="http://src.sencha.io//http://fleshy.org.nz/yum/wp-content/uploads/2007/11/list_cats.thumbnail.png" alt="list_cats even more insane!" /></a></p><p>Also, there&#8217;s an awesome feature in the WP DB object such that if one requeries the same table on the same page, apparently pagination offset is lost. This means that the main index page listing posts cannot also have a recent posts list &#8212; because you either will have recent posts starting with whatever the main list offset is, or you will only ever have as many posts on the index page as the recent posts query returns.</p><p>WIN!<br
/></p> ]]></content:encoded> <wfw:commentRss>http://fleshy.org.nz/2007/11/04/seriously-word-press-wth/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Vim tip: keyboard shortcuts</title><link>http://fleshy.org.nz/2007/10/26/vim-tip-keyboard-shortcuts/</link> <comments>http://fleshy.org.nz/2007/10/26/vim-tip-keyboard-shortcuts/#comments</comments> <pubDate>Fri, 26 Oct 2007 15:32:23 +0000</pubDate> <dc:creator>Jonathan Warner</dc:creator> <category><![CDATA[general]]></category> <category><![CDATA[programming]]></category> <category><![CDATA[code]]></category> <category><![CDATA[keyboard]]></category> <category><![CDATA[vim]]></category> <guid
isPermaLink="false">http://fleshy.org.nz/yum/archives/771</guid> <description><![CDATA[Finally got around to learning how to define keyboard shortucts in vim. It&#8217;s easy! map &#60;desiredkey&#62; &#60;targetaction&#62; So, for example, I split windows vertically and want to navigate via ctrl+pagedown or pageup. Here&#8217;s what I did (include &#60; and &#62; when defining) map &#60;c-pageup&#62; &#60;c-w&#62;h map &#60;c-pagedown&#62; &#60;c-w&#62;l Found via a vim wiki search [ad#Google [...]]]></description> <content:encoded><![CDATA[<p>Finally got around to learning how to define keyboard shortucts in vim. It&#8217;s easy!</p><p><code><br
/> map &lt;desiredkey&gt; &lt;targetaction&gt;<br
/> </code><br
/> So, for example, I split windows vertically and want to navigate via ctrl+pagedown or pageup.</p><p>Here&#8217;s what I did (include &lt; and &gt; when defining)<br
/> <code><br
/> map &lt;c-pageup&gt; &lt;c-w&gt;h<br
/> map &lt;c-pagedown&gt; &lt;c-w&gt;l<br
/> </code></p><p>Found via <a
href="http://vim.wikia.com/wiki/Alternative_tab_navigation">a vim wiki search</a><br
/> [ad#Google Adsense small leaderboard]<br
/></p> ]]></content:encoded> <wfw:commentRss>http://fleshy.org.nz/2007/10/26/vim-tip-keyboard-shortcuts/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>ATI Radeon 9600 with Compiz and Dual-Head</title><link>http://fleshy.org.nz/2007/10/05/ati-radeon-9600-with-compiz-and-dual-head/</link> <comments>http://fleshy.org.nz/2007/10/05/ati-radeon-9600-with-compiz-and-dual-head/#comments</comments> <pubDate>Fri, 05 Oct 2007 12:36:27 +0000</pubDate> <dc:creator>Jonathan Warner</dc:creator> <category><![CDATA[general]]></category> <category><![CDATA[linux]]></category> <category><![CDATA[ati]]></category> <category><![CDATA[code]]></category> <category><![CDATA[config]]></category> <category><![CDATA[radeon]]></category> <category><![CDATA[video]]></category> <category><![CDATA[xorg]]></category> <guid
isPermaLink="false">http://fleshy.org.nz/yum/archives/765</guid> <description><![CDATA[This concerns configuring an ATI Radeon 9600 under Linux to be dual head and run compiz-fusion. I&#8217;m not going into detail on what options make compiz run faster, just how to get two screens working well with compiz. I&#8217;m posting this because I had a hell of a time finding all the info on it. [...]]]></description> <content:encoded><![CDATA[<p>This concerns configuring an ATI Radeon 9600 under Linux to be dual head and run compiz-fusion. I&#8217;m not going into detail on what options make compiz run faster, just how to get two screens working well with compiz.</p><p>I&#8217;m posting this because I had a hell of a time finding all the info on it.</p><p><span
style="color: red">Update:</span> This is the <a
href="http://pastie.caboo.se/108848">significant portion of my xorg.conf</a>.<br
/> <span
style="color: red">Update, a few years later:</span> <a
href="http://fleshy.org.nz/yum/2010/07/15/the-most-important-thing-ive-learned-about-the-radeon/">The most important thing I&#8217;ve learned about dealing with the radeon</a><br
/> <span
id="more-765"></span><br
/> <strong>Resources:</strong><br
/> <a
href="http://ftp.x.org/pub/X11R7.0/doc/html/radeon.4.html">Radeon driver xorg settings</a><br
/> <a
href="http://gentoo-wiki.com/HOWTO_XGL/Troubleshooting">XGL Troubleshooting</a><br
/> <a
href="http://wiki.opencompositing.org/ATI_with_AIGLX">Compiz wiki ATI notes</a></p><p>My desired setup: two CRTs side by side, each running at 1280&#215;1024, giving me an effective desktop of 2560&#215;1024.</p><p>For desktop effects to work, I had to run the &#8216;radeon&#8217; driver, not the &#8216;ati&#8217; nor &#8216;fglrx&#8217; drivers. If one uses fglrx, I guess one can get by running XGL instead of AIGLX, but that locked up my X.</p><p><strong>First important note:</strong> If fglrx was <em>ever</em> installed and you want to use ati or radeon, you <em>need</em> to fully remove fglrx (sudo apt-get remove &#8211;purge fglrx).</p><p><strong>Second important note:</strong> To get a desktop spanning across two monitors, you want to use the MergedFB option in your xorg.conf. This provides Xinerama-like functionality. There are several options with that mode to provide different resolutions on each monitor with spanning.</p><p><strong>Third important note:</strong> There is an apparent hardware limitation for these cards on texture sizes. The max texture size for 3D applications (including compiz) of 2048&#215;2048). This means that if you have a desktop wider than 2048, you&#8217;ll either</p><ol><li>have effects for half or 2/3 of the desktop/screen with white on the far right, or</li><li>a fully white screen with odd tearing on effects</li></ol><p>There&#8217;s not much way around this at this point. Some people can fix it messing with &#8216;driconf&#8217;.<br
/> My solution at this point is to have one screen &#8216;Above&#8217; instead of &#8216;RightOf&#8217; in my xorg.conf (the two heights combine to 2048, so they fit into memory).</p><p>Anyway, that&#8217;s about it. <del>I&#8217;ll add my xorg.conf to this post, later. I can&#8217;t cause I&#8217;m on the laptop right now.</del></p><p><code><br
/> # xorg.conf significant sections for dual head + compiz on radeon 9600 XT<br
/> # second screen on top of second screen, vertical orientation.</p><p>Section "Module"<br
/> Load	"bitmap"<br
/> Load	"ddc"<br
/> Load	"dri"<br
/> Load	"dbe"<br
/> Load	"extmod"<br
/> Load	"freetype"<br
/> Load	"glx"<br
/> Load	"int10"<br
/> Load	"type1"<br
/> Load	"vbe"<br
/> EndSection</p><p>Section "Device"<br
/> Identifier	"Radeon"<br
/> Driver "radeon"<br
/> BusID  "PCI:1:0:0"<br
/> Option "No2048Limit"<br
/> Option "MergedFB" "true"<br
/> Option "MergedXineramaCRT2IsScreen0" "true"<br
/> Option "CRT2Position" "Above"<br
/> Option "MetaModes" "1280x1024-1280x1024 1024x768-1024x768"</p><p> Option  "DDCMode" "true"<br
/> Option  "OpenGLOverlay" "Off"<br
/> Option  "VideoOverlay" "on"<br
/> Option  "GLOverlay" "false"<br
/> Option  "OverlayOnCRTC1" "on"<br
/> Option  "OverlayOnCRTC2" "on"<br
/> Option  "MergedDPI" "75 75"<br
/> Option  "AGPMode" "8"<br
/> Option  "DRI" "true"<br
/> Option  "ColorTiling" "on"<br
/> Option  "EnablePageFlip" "true"<br
/> #DO NOT USE WITH RADEON 9600 Option "AccelMethod" "EXA"<br
/> Option  "XAANoOffscreenPixmaps"<br
/> Option  "RenderAccel" "true"<br
/> EndSection</p><p>Section "Monitor"<br
/> Identifier	"Dell P991 [0]"<br
/> Option		"DPMS"<br
/> HorizSync       30-107<br
/> VertRefresh     48-85<br
/> EndSection</p><p>Section "Screen"<br
/> Identifier	"Screen0"<br
/> Device		"Radeon"<br
/> Monitor		"Dell P991 [0]"<br
/> DefaultDepth	24<br
/> SubSection "Display"<br
/> Virtual 1280 2048<br
/> Depth		24<br
/> Modes	"1280x1024" "1024x768"<br
/> EndSubSection<br
/> EndSection</p><p>Section "ServerLayout"<br
/> Identifier	"Default Layout"<br
/> Screen		"Screen0"<br
/> InputDevice	"Generic Keyboard"<br
/> InputDevice	"Configured Mouse"<br
/> InputDevice     "stylus" "SendCoreEvents"<br
/> InputDevice     "cursor" "SendCoreEvents"<br
/> InputDevice     "eraser" "SendCoreEvents"<br
/> Option          "AIGLX"         "true"<br
/> EndSection</p><p>Section "DRI"<br
/> Mode	0666<br
/> EndSection</p><p>Section "Extensions"<br
/> Option "Composite" "On"<br
/> EndSection<br
/> </code></p><p>[ad#Google Adsense-1 Block]<br
/></p> ]]></content:encoded> <wfw:commentRss>http://fleshy.org.nz/2007/10/05/ati-radeon-9600-with-compiz-and-dual-head/feed/</wfw:commentRss> <slash:comments>6</slash:comments> </item> <item><title>Vim awesomeness.</title><link>http://fleshy.org.nz/2007/09/28/vim-awesomeness/</link> <comments>http://fleshy.org.nz/2007/09/28/vim-awesomeness/#comments</comments> <pubDate>Fri, 28 Sep 2007 17:56:17 +0000</pubDate> <dc:creator>Jonathan Warner</dc:creator> <category><![CDATA[general]]></category> <category><![CDATA[programming]]></category> <category><![CDATA[code]]></category> <category><![CDATA[vim]]></category> <guid
isPermaLink="false">http://fleshy.org.nz/yum/archives/763</guid> <description><![CDATA[If you use Vim as your text editor, try this :TOhtml This will generate an HTML version of your source code, complete with color scheme. It&#8217;s pretty sweet. Example here (opens a new window) This just tickles me.]]></description> <content:encoded><![CDATA[<p>If you use Vim as your text editor, try this<br
/> :TOhtml</p><p>This will generate an HTML version of your source code, complete with color scheme. It&#8217;s pretty sweet.</p><p><a
target="_new" href="/part_item_rga.rb.html">Example here</a> (opens a new window)</p><p>This just tickles me.<br
/></p> ]]></content:encoded> <wfw:commentRss>http://fleshy.org.nz/2007/09/28/vim-awesomeness/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Odd SQL Server errors</title><link>http://fleshy.org.nz/2007/08/31/odd-sql-server-errors/</link> <comments>http://fleshy.org.nz/2007/08/31/odd-sql-server-errors/#comments</comments> <pubDate>Fri, 31 Aug 2007 18:01:13 +0000</pubDate> <dc:creator>Jonathan Warner</dc:creator> <category><![CDATA[general]]></category> <category><![CDATA[programming]]></category> <category><![CDATA[code]]></category> <category><![CDATA[sql]]></category> <guid
isPermaLink="false">http://fleshy.org.nz/yum/archives/759</guid> <description><![CDATA[Maybe someone will find this post and explain to me why SQL Server behaves like this. My question isn&#8217;t &#8220;how should I rewrite this query&#8221;, but &#8220;why does SQL Server act like this&#8221;. The behavior I see is that for some reason it&#8217;s easier to do TOP bignumber than TOP smallnumber. In my instance, TOP [...]]]></description> <content:encoded><![CDATA[<p>Maybe someone will find this post and explain to me why SQL Server behaves like this. My question isn&#8217;t &#8220;how should I rewrite this query&#8221;, but &#8220;why does SQL Server act like this&#8221;. The behavior I see is that for some reason it&#8217;s easier to do TOP bignumber than TOP smallnumber. In my instance, TOP 3 takes up to 2 minutes to return results, whereas TOP 5 is instantaneous.</p><p><span
id="more-759"></span><br
/> Situation, selecting the first 3 Announcements for particular User Roles at a particular Organization.</p><p>There is an announcement table and a meta table containing org/role join information.</p><p>The (somewhat crappy) query is like so:<br
/> <code>SELECT TOP 3 b.announcement_title FROM announcements b<br
/> WHERE b.anouncement_id IN (<br
/> SELECT<br
/> &nbsp;&nbsp;DISTINCT a.announcement_id<br
/> FROM<br
/> &nbsp;&nbsp;announcements b, announcement_role_org aro<br
/> WHERE<br
/> &nbsp;&nbsp;aro.announcement_id = b.announcement_id<br
/> &nbsp;&nbsp; AND<br
/> &nbsp;&nbsp;aro.role_id = $role_id<br
/> &nbsp;&nbsp; AND<br
/> &nbsp;&nbsp;aro.org_id = $org_id<br
/> )<br
/> </code></p><p>Yes, I know it should have been written as a join.</p><p>This is the problem:</p><ul><li>When the outer select says TOP 3, the server chugs forever and doesn&#8217;t return a result (at least, doesn&#8217;t return a result within 2 minutes, I killed the select after that time limit).</li><li>When the outer select says TOP 5 or TOP 6, it returns results fairly instantly</li></ul><p>WTF?<br
/> For the record, the inner select for the $role and $org I specified only ever return 6 results.</p><p>Oh, lastly&#8230; if I say NOT IN (returns 210 results), it doesn&#8217;t seem to matter what TOP value I have.</p><p>WHY???<br
/></p> ]]></content:encoded> <wfw:commentRss>http://fleshy.org.nz/2007/08/31/odd-sql-server-errors/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Ruby Braces vs. Do/End blocks</title><link>http://fleshy.org.nz/2007/07/23/ruby-braces-vs-doend-blocks/</link> <comments>http://fleshy.org.nz/2007/07/23/ruby-braces-vs-doend-blocks/#comments</comments> <pubDate>Mon, 23 Jul 2007 15:57:41 +0000</pubDate> <dc:creator>Jonathan Warner</dc:creator> <category><![CDATA[general]]></category> <category><![CDATA[code]]></category> <category><![CDATA[programming]]></category> <category><![CDATA[ruby]]></category> <guid
isPermaLink="false">http://fleshy.org.nz/yum/archives/748</guid> <description><![CDATA[When parentheses are important: So, braces have higher precedence over do/end blocks. According to Pickaxe, when calling a method with no parentheses, the braces will be applied to the last method parameter, do will be applied to the invocation. A Very Contrived Example: def string_to_integer &#160;&#160;if block_given? &#160;&#160;&#160;&#160;yield.to_i &#160;&#160;else &#160;&#160;&#160;&#160;0 &#160;&#160;end end a = [1,2,3] [...]]]></description> <content:encoded><![CDATA[<p><strong>When parentheses are important:</strong><br
/> So, braces have higher precedence over do/end blocks. According to Pickaxe, when calling a method with no parentheses, the braces will be applied to the last method parameter, do will be applied to the invocation.</p><p>A Very Contrived Example:<br
/> <code><br
/> def string_to_integer<br
/> &nbsp;&nbsp;if block_given?<br
/> &nbsp;&nbsp;&nbsp;&nbsp;yield.to_i<br
/> &nbsp;&nbsp;else<br
/> &nbsp;&nbsp;&nbsp;&nbsp;0<br
/> &nbsp;&nbsp;end<br
/> end<br
/> a = [1,2,3]<br
/> </code><br
/> A) a.inject string_to_integer { &#8217;5&#8242; } do |i,sum| i + sum end => 11<br
/> B) a.inject string_to_integer { |i,sum| i + sum }   => undefined method error<br
/> C) a.inject string_to_integer do  |i,sum| i + sum end   => 6</p><p>in A, the first brace is sent to the string_to_integer method<br
/> in B, the same happens, but the block was actually meant for inject<br
/> in C it works as intended.</p><p>Just food for thought.</p> ]]></content:encoded> <wfw:commentRss>http://fleshy.org.nz/2007/07/23/ruby-braces-vs-doend-blocks/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Ruby and processing character sets</title><link>http://fleshy.org.nz/2007/07/19/ruby-and-processing-character-sets/</link> <comments>http://fleshy.org.nz/2007/07/19/ruby-and-processing-character-sets/#comments</comments> <pubDate>Thu, 19 Jul 2007 19:52:18 +0000</pubDate> <dc:creator>Jonathan Warner</dc:creator> <category><![CDATA[general]]></category> <category><![CDATA[code]]></category> <category><![CDATA[ruby]]></category> <guid
isPermaLink="false">http://fleshy.org.nz/yum/archives/745</guid> <description><![CDATA[Posting this because it&#8217;s been difficult for me to find resources on how to convert between different character encodings, such as Windows-1252 (cp1252) to UTF-8 or ISO-8859-1. It took me about a day to discover some of these libraries. Maybe I wasn&#8217;t searching for the correct keywords &#8212; dunno. require 'iconv' require 'charguess' # Reads [...]]]></description> <content:encoded><![CDATA[<p>Posting this because it&#8217;s been difficult for me to find resources on how to convert between different character encodings, such as Windows-1252 (cp1252) to UTF-8 or ISO-8859-1. It took me about a day to discover some of these libraries. Maybe I wasn&#8217;t searching for the correct keywords &#8212; dunno.</p><p><code><br
/> require 'iconv'<br
/> require 'charguess'<br
/> # Reads an arbitrary file and attempts to convert to a new file in UTF-8<br
/> # Sort of quick and dirty<br
/> # You should note that Iconv.conv will barf if you specify<br
/> # a source encoding that doesn't match the actual source encoding<br
/> def poop_out_utf8(infile, outfile)<br
/> &nbsp;&nbsp;if infile == outfile<br
/> &nbsp;&nbsp;&nbsp;&nbsp;puts 'Source and destination are the same, silly!"<br
/> &nbsp;&nbsp;&nbsp;&nbsp;return<br
/> &nbsp;&nbsp;end<br
/> &nbsp;&nbsp;out_file = File.new outfile, 'w'<br
/> &nbsp;&nbsp;begin<br
/> &nbsp;&nbsp;&nbsp;&nbsp;File.open(infile, 'r') do |file|<br
/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;file.each_line{|line|<br
/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;out_file.puts Iconv.conv('UTF-8', CharGuess::guess(line),line) unless line.nil?<br
/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br
/> &nbsp;&nbsp;end<br
/> &nbsp;&nbsp;rescue Exception => e<br
/> &nbsp;&nbsp;&nbsp;&nbsp;puts e<br
/> &nbsp;&nbsp;ensure<br
/> &nbsp;&nbsp;&nbsp;&nbsp;out_file.close<br
/> &nbsp;&nbsp;end<br
/> end<br
/> </code></p><p>You should have iconv already. CharGuess you&#8217;ll need to install yourself, most likely. Grab the <a
href="http://libcharguess.sourceforge.net/">clib here</a>, and the <a
href="http://raa.ruby-lang.org/project/charguess">ruby binding here</a>.</p><p>Assuming you&#8217;ve extracted the clib to /home/user/libcharguess/ (and done the ./configure/make/sudo make install bit), install the ruby charguess bindings with<br
/> <code><br
/> ruby extconf.rb --with-charguess-include=/home/user/libcharguess/cpp/<br
/> make<br
/> make install<br
/> </code><br
/></p> ]]></content:encoded> <wfw:commentRss>http://fleshy.org.nz/2007/07/19/ruby-and-processing-character-sets/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Unix command line: Kill by pattern command</title><link>http://fleshy.org.nz/2007/07/17/unix-command-line-kill-by-pattern-command/</link> <comments>http://fleshy.org.nz/2007/07/17/unix-command-line-kill-by-pattern-command/#comments</comments> <pubDate>Tue, 17 Jul 2007 13:34:16 +0000</pubDate> <dc:creator>Jonathan Warner</dc:creator> <category><![CDATA[general]]></category> <category><![CDATA[code]]></category> <guid
isPermaLink="false">http://fleshy.org.nz/yum/archives/741</guid> <description><![CDATA[The following attempts to kill based on a pattern you specify. I wrote this because our network gets messed up while Amarok is attempting to load files, which causes it to hang and leave various pipes open. By specifying &#8220;amarok&#8221; where it says &#8220;pattern&#8221;, below, I can kill all the open Amarok processes in one [...]]]></description> <content:encoded><![CDATA[<p>The following attempts to kill based on a pattern you specify. I wrote this because our network gets messed up while Amarok is attempting to load files, which causes it to hang and leave various pipes open. By specifying &#8220;amarok&#8221; where it says &#8220;pattern&#8221;, below, I can kill all the open Amarok processes in one fell swoop.<br
/> <code><br
/> ps ax | grep pattern | awk '{print $0; system("kill " $1) }'<br
/> </code></p><p>Use with care &#8212; it doesn&#8217;t differentiate between partial names. So if you want to kill all processes with &#8216;mini&#8217; and you just specify &#8216;ini&#8217;, you will also attempt to kill &#8216;init&#8217; (though that shouldn&#8217;t work).</p><p>(Also: The process group flag for &#8216;killall&#8217; should do this, but it doesn&#8217;t work for Amarok, on my system.)<br
/></p> ]]></content:encoded> <wfw:commentRss>http://fleshy.org.nz/2007/07/17/unix-command-line-kill-by-pattern-command/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Jinzora Media Jukebox &#8211; Impressions</title><link>http://fleshy.org.nz/2007/05/30/jinzora-media-jukebox-impressions/</link> <comments>http://fleshy.org.nz/2007/05/30/jinzora-media-jukebox-impressions/#comments</comments> <pubDate>Thu, 31 May 2007 01:07:53 +0000</pubDate> <dc:creator>Jonathan Warner</dc:creator> <category><![CDATA[general]]></category> <category><![CDATA[code]]></category> <category><![CDATA[linux]]></category> <category><![CDATA[mysql]]></category> <category><![CDATA[php]]></category> <category><![CDATA[review]]></category> <category><![CDATA[sql]]></category> <guid
isPermaLink="false">http://fleshy.org.nz/yum/archives/726</guid> <description><![CDATA[I installed Jinzora, a music organizer/streamer/jukebox application, today. I have some interesting impressions. Quick summary: I&#8217;m not going to use it because it&#8217;s technically deficient. This isn&#8217;t really a comprehensive review, just an exclamation over the techniques involved in the implementation of the software. Jinzora is a PHP+Apache+(MySQL/Postgres/SQLite/etc) application that indexes and manages your music [...]]]></description> <content:encoded><![CDATA[<p>I installed <a
href="http://www.jinzora.org/">Jinzora</a>, a music organizer/streamer/jukebox application, today. I have some interesting impressions. Quick summary: I&#8217;m not going to use it because it&#8217;s technically deficient.</p><p>This isn&#8217;t really a comprehensive review, just an exclamation over the techniques involved in the implementation of the software.<br
/> <span
id="more-726"></span><br
/> Jinzora is a PHP+Apache+(MySQL/Postgres/SQLite/etc) application that indexes and manages your music library, and provides streaming access to said library over a network. It&#8217;s a great idea &#8212; you can have a music server set up in the house and let satellite computers stream a  music library from the network, without needing to set up anything aside from a webserver. Jinzora can also be configured as a jukebox such that (if the hosting computer has speakers) you can remotely control playback of any of your music.</p><p>The setup was fairly straightforward. There were a few technical issues configuring PHP to have enough memory and enough execution time to run; it certainly isn&#8217;t a plug and play experience. Specifically, for Jinzora to run well, it requests longer than 300 seconds on max execution time and 32+ megs for a memory limit.</p><p>Those two things gave me worries, because typically upping the execution time and memory limit are the lazy programmer&#8217;s way out. I actually <em>did</em> bump into a memory limit during the import of my music library and had to set it to 128M for things to go through.</p><p>Aside from that, the web-install was fairly easy. There weren&#8217;t any technical issues that stopped the show (aside from needing to bump up the memory limit). When the importer encountered oddly tagged or oddly named files (with special characters or whatever), it <em>did</em> throw errors, but it kept going. It took approximately an hour to import 15,000 files.</p><p>Once it was running, I was pleased with some neat things it provided: there are related artists links for any particular track/artist. These are broken apart into artists you have and ones you don&#8217;t. Searching seemed to work reasonably well. Streaming worked without a hitch &#8212; clicking a music link prompted me asking if I wanted to play what the site was sending (it sends .m3u files, so they should be playable by most modern music players.)</p><p>It finds album art if there is art in the music directory in question. I <em>think</em> there&#8217;s some mechanism for grabbing album art from external sources, but couldn&#8217;t find the setting.</p><p>You can configure Jinzora to send useage reports to <a
href="http://www.last.fm/">last.fm</a> if you use their services.</p><p>Unfortunately, I didn&#8217;t fully explore this application due to the one showstopper.</p><p>The showstopper, and reason why I won&#8217;t be using it, is this:it is <em>insanely</em> slow.</p><p>Granted, the machine I ran this on was a PII 300 w/ 256M RAM, but even so, it felt as if the application were iterating over the file structure each time I loaded a page. Page loads literally took up to 30 seconds to load. For comparison, a simple <a
href="http://www.rubyonrails.com">rails</a> application I wrote, working from a MySQL database over the same library, took half a second to load (with the crappy Rails paginator, no less.) As well, a PHP-based indexer I wrote that actually traverses the directory on each page load takes only 10 seconds to load. I realize that the hosting machine is crap, but it&#8217;s not <em>that</em> crap. Something is definitely wrong with the code.</p><p>(This is where it gets a little more technical.)</p><p><strong>So</strong>&#8230; I looked at the database Jinzora set up to see if I could optimize with indices or something. There <em>are</em> indices. The fields they are indexing are varchars. In fact, <strong>every single field</strong> is a varchar in any of the tables, with the exception of playcounts.</p><p>The <em>primary key</em> is a varchar. I repeat: the primary key is a varchar!</p><p>In despair, I looked at the PHP to see how rough it would be to fork Jinzora for proper design and normalization.</p><p>Every select that used the primary key (which was called &#8216;path&#8217; and used the file&#8217;s path, btw) used the LIKE statement. There was nothing that looked like a JOIN statement (and come to think of it, I don&#8217;t really know if you can join on text fields in all the databases it supports.)</p><p>Every single SELECT looked something like &#8220;SELECT foo WHERE path LIKE &#8216;$path%&#8217; &#8220;. It&#8217;s not just using text fields to index, it&#8217;s using <em>LIKE</em>, which is perhaps the slowest mechanism for accessing data in a database!</p><p>Searching on the net, I found some forum user asking how to speed up Jinzora. He reported that he was seeing 150 queries per second. FOR A SINGLE PAGELOAD.</p><p>No wonder my experience was so slow. (Aside: Actually, it&#8217;s kind of supportive of the Linux system&#8217;s configuration and PHP&#8217;s performance that it didn&#8217;t take 5 minutes to load with that kind of crap going on behind the scenes.)</p><p><em>Anyway</em>, that was my experience with Jinzora. I saw a Google cached post that hinted at database normalization in version 3, so maybe I&#8217;ll return to it at a later date. For now I&#8217;ll just write my own.</p> ]]></content:encoded> <wfw:commentRss>http://fleshy.org.nz/2007/05/30/jinzora-media-jukebox-impressions/feed/</wfw:commentRss> <slash:comments>5</slash:comments> </item> <item><title>Citrix connection under Linux</title><link>http://fleshy.org.nz/2007/05/17/citrix-connection-under-linux/</link> <comments>http://fleshy.org.nz/2007/05/17/citrix-connection-under-linux/#comments</comments> <pubDate>Thu, 17 May 2007 17:19:35 +0000</pubDate> <dc:creator>Jonathan Warner</dc:creator> <category><![CDATA[general]]></category> <category><![CDATA[code]]></category> <category><![CDATA[config]]></category> <category><![CDATA[howto]]></category> <category><![CDATA[linux]]></category> <category><![CDATA[ubuntu]]></category> <guid
isPermaLink="false">http://fleshy.org.nz/yum/archives/719</guid> <description><![CDATA[So, a few things about using Citrix under Ubuntu (7.04): Don&#8217;t use the client linked from your Citrix login page, it&#8217;s probably version 7 but the latest is version 10. Go here, instead You will need Open Motif. Use synaptic to search for &#8216;motif&#8217;. Install limbotif3, libmotif-dev, and motifnls You may need to set up [...]]]></description> <content:encoded><![CDATA[<p>So, a few things about using Citrix under Ubuntu (7.04):</p><ul><li>Don&#8217;t use the client linked from your Citrix login page, it&#8217;s probably version 7  but the latest is version 10. <a
href="http://www.citrix.com/English/SS/downloads/downloads.asp?dID=2755">Go here, instead</a></li><li>You will need Open Motif. Use synaptic to search for &#8216;motif&#8217;. Install limbotif3, libmotif-dev, and motifnls</li><li>You may need to set up your FontPath in your xorg.conf. This is the &#8220;Files&#8221; section of /etc/X11/xorg.conf<br
/> <code><br
/> FontPath "/usr/share/X11/fonts/cyrillic"<br
/> FontPath "/usr/share/X11/fonts/100dpi"<br
/> FontPath "/usr/share/X11/fonts/75dpi"<br
/> FontPath "/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType"<br
/> FontPath "/usr/share/fonts/X11/100dpi/:unscaled"<br
/> FontPath "/usr/share/fonts/X11/75dpi/:unscaled"<br
/> FontPath "/usr/share/fonts/X11/100dpi/:unscaled"<br
/> FontPath "/usr/share/fonts/X11/Type1"<br
/> FontPath "/usr/share/fonts/X11/misc"<br
/> </code></li><li>You also need the correct security certificates, because apparently they don&#8217;t all ship with the client (I kept getting errors about UTN-USERFirst-Hardware not being trusted). I copied all my mozilla certs and the cacerts.org and that seemed to do the trick:<br
/> <code><br
/> sudo cp /usr/share/ca-certificates/cacert.org/cacert.org.crt /usr/lib/ICAClient/keystore/cacerts/<br
/> sudo cp /usr/share/ca-certificates/mozilla/* /usr/lib/ICAClient/keystore/cacerts/<br
/> </code></li></ul><p>That worked for me. Good luck!<br
/></p> ]]></content:encoded> <wfw:commentRss>http://fleshy.org.nz/2007/05/17/citrix-connection-under-linux/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Observation: Code cleverness == Bad</title><link>http://fleshy.org.nz/2007/05/02/observation-code-cleverness-bad/</link> <comments>http://fleshy.org.nz/2007/05/02/observation-code-cleverness-bad/#comments</comments> <pubDate>Wed, 02 May 2007 19:06:01 +0000</pubDate> <dc:creator>Jonathan Warner</dc:creator> <category><![CDATA[general]]></category> <category><![CDATA[code]]></category> <category><![CDATA[programming]]></category> <category><![CDATA[ruby]]></category> <guid
isPermaLink="false">http://fleshy.org.nz/yum/archives/705</guid> <description><![CDATA[This is inspired by Ruby, but could apply to Perl as well. Situation: class with dynamic, on the fly class method definitions of the form What this does is defines some class methods role1_email_addresses, role2_email_addresses, etc on the fly. Works perfectly, until the first element returned in users is actually an empty email. This is [...]]]></description> <content:encoded><![CDATA[<p>This is inspired by Ruby, but could apply to Perl as well.</p><p>Situation: class with dynamic, on the fly class method definitions of the form<br
/> <script src='http://pastie.org/955714.js'></script></p><p>What this does is defines some class methods role1_email_addresses, role2_email_addresses, etc on the fly.</p><p>Works perfectly, until the first element returned in users is actually an empty email.</p><p>This is an example of writing clever code for succinctness (which is rampant in ruby circles). The problem is this code has bugs, and in order to fix it you have to rewrite it or add extra checks and workarounds. Which means the code is no longer succinct nor clever.</p><p>In my recent experience, that&#8217;s all that overly-clever code gets you. You just end up making extra work for yourself (or the maintainer) down the line.</code><br
/></p> ]]></content:encoded> <wfw:commentRss>http://fleshy.org.nz/2007/05/02/observation-code-cleverness-bad/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> <item><title>Fesity Ubuntu Vs. Edgy Ubuntu</title><link>http://fleshy.org.nz/2007/03/27/fesity-ubuntu-vs-edgy-ubuntu/</link> <comments>http://fleshy.org.nz/2007/03/27/fesity-ubuntu-vs-edgy-ubuntu/#comments</comments> <pubDate>Tue, 27 Mar 2007 23:47:44 +0000</pubDate> <dc:creator>Jonathan Warner</dc:creator> <category><![CDATA[general]]></category> <category><![CDATA[code]]></category> <category><![CDATA[linux]]></category> <category><![CDATA[ubuntu]]></category> <guid
isPermaLink="false">http://fleshy.org.nz/yum/archives/674</guid> <description><![CDATA[Yesterday I took the plunge and installed the Feisty Beta of Ubuntu on the laptop. It was a long, slow process &#8212; I installed via &#8220;update-manager -d&#8221; rather than from CD. What follows is a short analysis and rumination on the ordeal. First, the good: The settings migration was excellent. The installer transferred all my [...]]]></description> <content:encoded><![CDATA[<p>Yesterday I took the plunge and installed the Feisty Beta of Ubuntu on the laptop. It was a long, slow process &#8212; I installed via &#8220;update-manager -d&#8221; rather than from CD. What follows is a short analysis and rumination on the ordeal.<br
/> <span
id="more-674"></span><br
/> First, the good:</p><ul><li>The settings migration was excellent. The installer transferred all my settings like a charm. The only exception was the custom login screen and splash image. Not such a big deal, but worth noting.</li><li>Also awesome, it saw that I had one of the Broadcom-based wireless cards and automatically ran the firmware cutter to install the Windows driver for the Linux kernel. That was sort of handy, I must say.</li><li>Wireless configuration was way easier with fewer lags.</li><li>Compiz worked out of the box with no messing with settings.</li></ul><p>Now, the bad:</p><ul><li>Even though wireless was easily configured, it refused to work. I was never able to get the broadcom card to work with ndis nor the firmware cutter in the first place &#8212; at least not on networks requiring a WEP key. Furthermore, the USB wireless card I use instead requires a Realtek driver that is automatically blacklisted, due to hanging the kernel, apparently. So, no network for me. Wired works, but&#8230; meh, it&#8217;s a laptop you know?</li><li>Beryl appeared to work, but there was some tweaking necessary. Supposedly there&#8217;s an xorg.conf trick one can do to make the non-refreshing windows (that I was experiencing) go away, but I never tried it.</li><li>Even with a wired connection (which worked) I could not open an SSH network place in Nautilus to anywhere. It almost acted as if it were disabled.</li></ul><p>So, I blew all that away and reinstalled Edgy. I know that works and I know I can get network/beryl running correctly under that. Really all I was interested in with 7.04 was the networking stuff and virtualization support. I didn&#8217;t try the latter, but the former kind of put a kabosh on the whole thing.</p><p>One thing that&#8217;s interesting to note: now that I have 6.10 reinstalled I&#8217;m noting some neat things. Everything is a lot zippier. Wireless works at my workplace for the first time. I consistenly had problems with mysql working, and now I don&#8217;t. It&#8217;s pretty awesome.</p><p>Anyway, I guess the message I&#8217;m taking away is that the Feisty beta really is <em>beta</em> software. I suppose I&#8217;ve  had my view of &#8220;beta software&#8221; modified from companies like Google consistently releasing fully-functional beta code. This OS beta harkens back to the days when &#8220;beta&#8221; really meant something.</p><p>So take all that for what you will. My advice, though: wait until the April for the full release.<br
/></p> ]]></content:encoded> <wfw:commentRss>http://fleshy.org.nz/2007/03/27/fesity-ubuntu-vs-edgy-ubuntu/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Forgive me, Father, I have sinned&#8230;</title><link>http://fleshy.org.nz/2006/11/22/forgive-me-father-i-have-sinned/</link> <comments>http://fleshy.org.nz/2006/11/22/forgive-me-father-i-have-sinned/#comments</comments> <pubDate>Wed, 22 Nov 2006 21:53:05 +0000</pubDate> <dc:creator>Jonathan Warner</dc:creator> <category><![CDATA[general]]></category> <category><![CDATA[code]]></category> <category><![CDATA[php]]></category> <guid
isPermaLink="false">http://fleshy.org.nz/yum/archives/619</guid> <description><![CDATA[I have written code that looks like this. foreach ($row as $k => $v) { &#160;if (is_numeric($v)) &#160;&#160;continue; $row[$k] = preg_replace("/([\\xC0-\\xDF])([\w&#124;\W])/e", "'\\1'.chr(ord('\\2')-64) ", $v) ; } Incidentally, had to do som strange copy/paste action to get that line to not break wordpress. And FWIW, that preg_replace effectively converts windows-1252 characters out of the unused overlap [...]]]></description> <content:encoded><![CDATA[<p>I have written code that looks like this.</p><p><code><br
/> foreach ($row as $k => $v) {<br
/> &nbsp;if (is_numeric($v))<br
/> &nbsp;&nbsp;continue;<br
/> $row[$k] = preg_replace("/([\\xC0-\\xDF])([\w|\W])/e", "'\\1'.chr(ord('\\2')-64) ", $v) ;<br
/> }</p><p></code></p><p>Incidentally,  had to do som strange copy/paste action to get that line to not break wordpress.</p><p>And FWIW, that preg_replace effectively converts windows-1252 characters out of the unused overlap range in ISO 8859-1.<br
/></p> ]]></content:encoded> <wfw:commentRss>http://fleshy.org.nz/2006/11/22/forgive-me-father-i-have-sinned/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Cockrock gets a bad rap</title><link>http://fleshy.org.nz/2006/10/26/cockrock-gets-a-bad-rap/</link> <comments>http://fleshy.org.nz/2006/10/26/cockrock-gets-a-bad-rap/#comments</comments> <pubDate>Thu, 26 Oct 2006 15:46:07 +0000</pubDate> <dc:creator>Jonathan Warner</dc:creator> <category><![CDATA[general]]></category> <category><![CDATA[code]]></category> <guid
isPermaLink="false">http://fleshy.org.nz/yum/archives/602</guid> <description><![CDATA[You know, it really does. Autograph – Turn Up the Radio is just an excellent, nothought song. I mean, do you always want to analyze the lyrics or the intricacies of the melody/harmony/counterpoint? Sometimes you just want some Whitesnake or Ratt to rock out to. &#8220;Big, dumb music&#8221; as one of my buddies calls it. [...]]]></description> <content:encoded><![CDATA[<p>You know, it really does. <a
href="http://www.last.fm/music/Autograph/_/Turn+Up+the+Radio" class="bbcode_track">Autograph – Turn Up the Radio</a> is just an excellent, nothought song. I mean, do you always want to analyze the lyrics or the intricacies of the melody/harmony/counterpoint?</p><p>Sometimes you just want some <a
href="http://www.last.fm/music/Whitesnake" class="bbcode_artist">Whitesnake</a> or <a
href="http://www.last.fm/music/Ratt" class="bbcode_artist">Ratt</a> to rock out to. &#8220;Big, dumb music&#8221; as one of my buddies calls it. If you&#8217;re spending all your music time only listening to stuff that means something deep and profound, I kind of think that you&#8217;re taking it way too seriously.</p><p>It&#8217;s supposed to be fun and entertaining, yo.<br
/></p> ]]></content:encoded> <wfw:commentRss>http://fleshy.org.nz/2006/10/26/cockrock-gets-a-bad-rap/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>A couple WordPress 2 configuration things</title><link>http://fleshy.org.nz/2006/10/14/a-couple-wordpress-configuration-things/</link> <comments>http://fleshy.org.nz/2006/10/14/a-couple-wordpress-configuration-things/#comments</comments> <pubDate>Sat, 14 Oct 2006 14:00:53 +0000</pubDate> <dc:creator>Jonathan Warner</dc:creator> <category><![CDATA[general]]></category> <category><![CDATA[code]]></category> <guid
isPermaLink="false">http://fleshy.org.nz/yum/archives/593</guid> <description><![CDATA[Some things I&#8217;ve discovered about WordPress V2: Use the internal editor to edit your .htaccess. If you do it outside WP, appparently you lose your changes the next time you do ANY editing or posting. Seems like a bug that it resaves the .htaccess each time you post or edit a post. Dunno. This ends [...]]]></description> <content:encoded><![CDATA[<p>Some things I&#8217;ve discovered about WordPress V2:</p><ul><li><del>Use the internal editor to edit your .htaccess. If you do it outside WP, appparently you lose your changes the next time you do ANY editing or posting. Seems like a bug that it resaves the .htaccess each time you post or edit a post. Dunno.</del></li><li><del><br
/> This ends up being problematic, because if you mess up the .htaccess, you could get a 500 internal server error, preventing you from fixing the problem.</del></li><li>Toggle your .htaccess from Anyone Can Write to No One Can Write, if you need custom changes. WordPress <em>by design</em> overwrites this file whenever you do <strong>anything</strong>. This means when you change an option, post something, or edit something. It&#8217;s really stupid.</li><li>Make sure you set your blog address/wordpress address in the Options-&gt;General section.</li><li>Make sure your hosting provider or your .htaccess restrict to accessing this url. For example, if you have your address at http://www.foo.com/, make sure people cannot access or are redirected when they go to http://foo.com/, and vice versa. This solves a lot of problems with ajax stuff.</li><li>The rich editor is really nice, but if you have a lot of content and a lot of nested divs, sometimes it will incorrectly parse them and try to close what&#8217;s already been closed. Use that feature with caution if you handcode your html, frequently.</li></ul><p>For the .htaccess stuff, the following may be pasted to provide redirection. Use option 1 or 2 depending on your needs. This will only work if your host has mod_rewrite. You may need to put &#8220;RewriteEngine On&#8221; before the RewriteCond lines.<br
/> (Pretty much stolen from <a
href="http://httpd.apache.org/docs/1.3/misc/rewriteguide.html">here</a>):</p><p><code>#Option 1 Redirects domain.com to www.domain.com<br
/> RewriteCond %{HTTP_HOST}   !^www\.domain\.name [NC]<br
/> RewriteCond %{HTTP_HOST}   !^$<br
/> RewriteRule ^/(.*)         http://www.domain.name/$1 [L,R]<br
/> </code><br
/> <code># Option 2 Redirects www.domain.com to domain.com<br
/> RewriteCond %{HTTP_HOST}   ^www\.domain\.name [NC]<br
/> RewriteCond %{HTTP_HOST}   !^$<br
/> RewriteRule ^/(.*)      http://domain.name/$1 [L,R]<br
/> </code></p><p>Note that for wp2, you should make sure you have a way of deleting/modifying your .htaccess file in case you screw something up. If you try to edit the .htaccess outside of wordpress, wordpress2 won&#8217;t know about the changes and will overwrite them so you need to use the Manage->Files section to edit. However, if you break your rewrite because you mis-pasted, you&#8217;ll need a way to revert that doesn&#8217;t involve WP2.</p> ]]></content:encoded> <wfw:commentRss>http://fleshy.org.nz/2006/10/14/a-couple-wordpress-configuration-things/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>SQL Server and IN() Statements = Suck</title><link>http://fleshy.org.nz/2006/09/26/sql-server-and-in-statements-suck/</link> <comments>http://fleshy.org.nz/2006/09/26/sql-server-and-in-statements-suck/#comments</comments> <pubDate>Tue, 26 Sep 2006 18:09:31 +0000</pubDate> <dc:creator>Jonathan Warner</dc:creator> <category><![CDATA[general]]></category> <category><![CDATA[code]]></category> <guid
isPermaLink="false">http://fleshy.org.nz/yum/archives/568</guid> <description><![CDATA[Potentially. Example: SELECT t.* FROM table t WHERE t.id IN (SELECT DISTINCT f.id FROM table f, table e WHERE f.something = e.somethingelse AND f.someotherthing = e.somethingdifferent) In Postgres and MySQL, IN seems to be fairly efficient and treats the subselect as a simple list. In SQL Server, it appears that IN does some kind of [...]]]></description> <content:encoded><![CDATA[<p>Potentially.</p><p>Example:<br
/> <code>SELECT t.* FROM table t WHERE t.id IN (SELECT DISTINCT f.id FROM table f, table e WHERE f.something = e.somethingelse AND f.someotherthing = e.somethingdifferent)<br
/> </code></p><p>In Postgres and MySQL, IN seems to be fairly efficient and treats the subselect as a simple list. In SQL Server, it appears that IN does some kind of massive join, or perhaps a series of SELECTs times the number of rows in the superselect&#8217;s table.</p><p>All I know is that code works fine with little latency under pgsql and mysql, but at a certain row limit SQL Server is an order of magnitude different &#8212; we&#8217;re talking 10 seconds for a select versus half a second. The solution is to not use IN &#8212; do a JOIN, instead.</p><p>Just thought I&#8217;d pass that on to all you DB peeps.</p><p>(And for the record, I like IN statements because they seem more semantic and readable to me.)</p> ]]></content:encoded> <wfw:commentRss>http://fleshy.org.nz/2006/09/26/sql-server-and-in-statements-suck/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>How to add event listeners under the GMap2 API</title><link>http://fleshy.org.nz/2006/08/29/how-to-add-event-listeners-under-the-gmap2-api/</link> <comments>http://fleshy.org.nz/2006/08/29/how-to-add-event-listeners-under-the-gmap2-api/#comments</comments> <pubDate>Tue, 29 Aug 2006 15:40:55 +0000</pubDate> <dc:creator>Jonathan Warner</dc:creator> <category><![CDATA[general]]></category> <category><![CDATA[api]]></category> <category><![CDATA[code]]></category> <category><![CDATA[programming]]></category> <guid
isPermaLink="false">http://fleshy.org.nz/yum/?p=530</guid> <description><![CDATA[Some Javascript stuff here concerning Google Maps and coding for them. This took me a little bit to figure out, cause I was a little slow, last night. Also, the Google Map API documentation doesn&#8217;t seem to cover this sort of eventuality. Say that, for whatever reason, you have an array of GMarker objects and [...]]]></description> <content:encoded><![CDATA[<p>Some Javascript stuff here concerning Google Maps and coding for them.</p><p>This took me a little bit to figure out, cause I was a little slow, last night. Also, the Google Map API documentation doesn&#8217;t seem to cover this sort of eventuality.</p><p>Say that, for whatever reason, you have an array of GMarker objects and you want to programatically apply an info window to each of them.</p><p>Doing so is not as straightforward as this code:<br
/> <code><br
/> for (i in markers) {<br
/> ...<br
/> GEvent.addListener(markers[i], "mouseover", function() {<br
/> marker[i].openInfoWindowHtml(text_var);<br
/> } );<br
/> }<br
/> </code></p><p>This won&#8217;t work, because in the third parameter, &#8220;i&#8221; is passed in literally. In order to have the &#8220;i&#8221; successfully expanded to an index, you have to eval the function creation, like so:<br
/> <code><br
/> for (i in markers) {<br
/> ...<br
/> GEvent.addListener(marker[i], "mouseover", eval('function() {' +<br
/> 'marker[' + i + '].openInfoWindowHtml("' + text_var + '"); ' +<br
/> '} ')<br
/> );<br
/> }<br
/> </code></p><p>Just passing it on.<br
/></p> ]]></content:encoded> <wfw:commentRss>http://fleshy.org.nz/2006/08/29/how-to-add-event-listeners-under-the-gmap2-api/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>PHP XML functions are sucky</title><link>http://fleshy.org.nz/2006/08/06/php-xml-functions-are-sucky/</link> <comments>http://fleshy.org.nz/2006/08/06/php-xml-functions-are-sucky/#comments</comments> <pubDate>Sun, 06 Aug 2006 14:35:07 +0000</pubDate> <dc:creator>Jonathan Warner</dc:creator> <category><![CDATA[general]]></category> <category><![CDATA[code]]></category> <guid
isPermaLink="false">http://fleshy.org.nz/yum/archives/516</guid> <description><![CDATA[I mean, they&#8217;re cool and have a certain level of power to them; however, using them necessitates writing essentially unreadable code. If you have to write multi-line comments documenting the return value or behavior of a language function, that function is poorlyl named or poorly implemented. By way of example, I direct you to xml_parse_into_struct]]></description> <content:encoded><![CDATA[<p>I mean, they&#8217;re cool and have a certain level of power to them; however, using them necessitates writing essentially unreadable code.</p><p>If you have to write multi-line comments documenting the return value or behavior of a language function, that function is poorlyl named or poorly implemented.</p><p>By way of example, I direct you to <a
href="http://us2.php.net/manual/en/function.xml-parse-into-struct.php">xml_parse_into_struct</a><br
/></p> ]]></content:encoded> <wfw:commentRss>http://fleshy.org.nz/2006/08/06/php-xml-functions-are-sucky/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Ruby (rails) fun</title><link>http://fleshy.org.nz/2006/08/01/ruby-rails-fun/</link> <comments>http://fleshy.org.nz/2006/08/01/ruby-rails-fun/#comments</comments> <pubDate>Wed, 02 Aug 2006 04:34:47 +0000</pubDate> <dc:creator>Jonathan Warner</dc:creator> <category><![CDATA[general]]></category> <category><![CDATA[code]]></category> <guid
isPermaLink="false">http://fleshy.org.nz/yum/?p=513</guid> <description><![CDATA[This&#8217;ll only make sense to about three of my readers, but I just wanted to point out that it fills me with a certain glee to code something like: validates_something_of :foo, :if => Proc.new { breakpoint } When that breakpoint fires, it&#8217;s like you&#8217;re hanging off the edge of the universe. On a related note, [...]]]></description> <content:encoded><![CDATA[<p>This&#8217;ll only make sense to about three of my readers, but I just wanted to point out that it fills me with a certain glee to code something like:<br
/> <code><br
/> validates_something_of :foo,  :if => Proc.new { breakpoint } </code></p><p>When that breakpoint fires, it&#8217;s like you&#8217;re hanging off the edge of the universe.</p><p><span
id="more-513"></span><br
/> On a related note, I have the sneaking suspicion that this is bad news, but it solved a particularly vexing problem with validations firing on belongs_to models even when those models weren&#8217;t created yet in the build process (e.g. the leaf model needed to validate first, creation of the parent was dependent on the leaf. If the leaf didn&#8217;t validate, the parent necessarily won&#8217;t (and shouldn&#8217;t attempt to) validate because it hasn&#8217;t built the relation yet):</p><p>In the leaf<br
/> <code><br
/> validates_numericality_of   :some_value,<br
/> :allow_nil    => false,<br
/> :if => Proc.new { !self.reflect_on_association(:transactions).nil? }<br
/> </code><br
/> The scary thing for me is that I&#8217;m not sure why it necessarily works.<br
/></p> ]]></content:encoded> <wfw:commentRss>http://fleshy.org.nz/2006/08/01/ruby-rails-fun/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Comment Hilarity</title><link>http://fleshy.org.nz/2006/07/15/comment-hilarity/</link> <comments>http://fleshy.org.nz/2006/07/15/comment-hilarity/#comments</comments> <pubDate>Sat, 15 Jul 2006 12:06:47 +0000</pubDate> <dc:creator>Jonathan Warner</dc:creator> <category><![CDATA[general]]></category> <category><![CDATA[code]]></category> <guid
isPermaLink="false">http://fleshy.org.nz/yum/archives/498</guid> <description><![CDATA[I took my friend Drew&#8217;s advice and decided to close comments on old posts. If you need to automate closing comments in WordPress and aren&#8217;t afraid to get your hands a little dirty with some editing, read on. It&#8217;s a basic hack to the comments file. Go to wp_content/themes/&#60;themename&#62;/comments.php somewhere there should be two lines [...]]]></description> <content:encoded><![CDATA[<p>I took my friend <a
href="http://wyntermute.dyndns.org/">Drew&#8217;s</a> advice and decided to close comments on old posts.</p><p>If you need to automate closing comments in WordPress and aren&#8217;t afraid to get your hands a little dirty with some editing, read on.<br
/> <span
id="more-498"></span></p><p>It&#8217;s a basic hack to the comments file. Go to wp_content/themes/&lt;themename&gt;/comments.php</p><p>somewhere there should be two lines that look sort of like<br
/> <code>&lt;? if ('open' == $post->comment_status) : ?&gt;</code></p><p>Modify those lines to something like<br
/> <code>&lt;? if (('open' == $post-> comment_status) &#038;&#038; strtotime($post->post_date ." + 30 days") >= strtotime(date('F d, Y H:i:s'))) :  ?&gt;</code></p><p>Next, you need to change the post verification:<br
/> Go to wp_content/wp-comments-post.php. At the very top should be a line that includes<br
/> <code>"SELECT post_status, comment_status..."</code><br
/> click between post_status and comment_status, add<br
/> <code>post_date, </code><br
/> (include the comma)</p><p>Then a few lines down change<br
/> <code>} elseif ( 'closed' ==  $status-&gt;comment_status ) {</code></p><p>to</p><p><code><br
/> } elseif (<br
/> ('closed' ==  $status->comment_status) ||<br
/> (strtotime($status->post_date ." + 30 days") < strtotime(date('F d, Y H:i:s'))<br
/> )</p><p>Note that you can change the "30 days" to whatever interval you like. What this does is check if the post date is within 30 days of the current date as well as checking the status of comment posting. If it's not within 30 days, the test fails and the comments box isn't displayed.</p><p>I'm posting this not cause it's a neat hack, but because it's kind of daunting to find where crap is located in WordPress, sometimes.</p><p>Also, this kind of thing looks like it'll work under WP2 (the file looks the same to me). I don't have a working install to test it, though.</p><p>(p.s. Keep in mind that if you change your theme, you'll have to redo these changes in whatever theme folder you've selected.)</code><br
/></p> ]]></content:encoded> <wfw:commentRss>http://fleshy.org.nz/2006/07/15/comment-hilarity/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
