<?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>Everybody Staze... &#187; Coding</title> <atom:link href="http://www.staze.org/coding/feed/" rel="self" type="application/rss+xml" /><link>http://www.staze.org</link> <description>Nobody leavz...</description> <lastBuildDate>Sat, 31 Jul 2010 01:52:42 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3483</generator> <item><title>URL Shortener</title><link>http://www.staze.org/url-shortener/</link> <comments>http://www.staze.org/url-shortener/#comments</comments> <pubDate>Mon, 01 Mar 2010 05:02:39 +0000</pubDate> <dc:creator>staze</dc:creator> <category><![CDATA[Coding]]></category> <category><![CDATA[Base60]]></category> <category><![CDATA[URL Shortener]]></category> <category><![CDATA[Wordpress]]></category><guid isPermaLink="false">http://www.staze.org/?p=588</guid> <description><![CDATA[So, it&#8217;s been a desire of mine for a while to make up a URL shortener. It seems like such a trivial coding experiment, but a fun one. The first hurdle, getting something better than base10 for the URLs. That&#8217;s fairly easy, in that you can look here. The code he lists isn&#8217;t complete, as [...]]]></description> <content:encoded><![CDATA[<p>So, it&#8217;s been a desire of mine for a while to make up a URL shortener. It seems like such a trivial coding experiment, but a fun one.</p><p>The first hurdle, getting something better than base10 for the URLs. That&#8217;s fairly easy, in that you can look <a href="http://tantek.pbworks.com/NewBase60" rel="nofollow" >here</a>. The code he lists isn&#8217;t complete, as you need some other stuff. So, go grab the <a href="http://tantek.pbworks.com/CassisProject" rel="nofollow" >Cassis project</a> code instead.</p><p>Note: when you &#8220;include_once&#8221; that code, you&#8217;ll want to do it like:</p><pre>ob_start();
include_once("./cassis.js");
ob_end_clean();</pre><p>Next you&#8217;ll need to code up something to add URLs to your database. That&#8217;s also easy enough. My suggestion would be a simple table that would have &#8220;id&#8221;, &#8220;shortcode&#8221;, and &#8220;url&#8221;. Make id a primary key, and add an index on the &#8220;shortcode&#8221;. Maybe one on the &#8220;url&#8221; if your going to be using the system heavily enough to require checking to see if a URL exists already before blindly creating a new short-url.</p><p>The last hurdle is to write the decoder. Basically, just have it look for &#8220;GET&#8221;, and look that up in the DB table, then set the &#8220;header(location: )&#8221; to be the URL in the for that short code.</p><p>Now, normally, you&#8217;d have a mod_rewrite rule that looked something like this:</p><pre>RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule shortener.php?url=$1 [L]</pre><p>Except, WordPress permalinks use something similar, and the two don&#8217;t play nice. Now, it would be cool to pass all URLs on to the decoder, and if it didn&#8217;t exist in the DB, you&#8217;d pass it on to the wordpress index.php. I haven&#8217;t quite figured out how to do that, but I found a pretty decent work around.</p><pre>RewriteRule ^z(.*) shortener.php?url=$1 [L]</pre><p>Stick that before the WordPress rewrite rules. What that will do is, if there&#8217;s a URL that starts with &#8220;z&#8221;, it&#8217;ll pass whatever comes after that &#8220;z&#8221; on to the decoder. Personally, I don&#8217;t have any pages, or files on my website that start with &#8220;z&#8221;, so it&#8217;s safe for me to do. Your experience may vary. If the decoder doesn&#8217;t find the url in the table, it simply redirects to my main page. I think I&#8217;ll change that to a 404 here once I am further along.</p><p>I&#8217;m going to keep playing with this. And hopefully, make some pretty spiffy use of it, but for now, it&#8217;s &#8220;basically&#8221; working. I&#8217;ll try to remember to post back on this topic when I have more to report on it. =)</p><p>Special thanks to my friend <a href="http://aaron.pk/" rel="nofollow" >Aaron</a> for the advice on this one.</p><p><strong>UPDATE 1</strong>: I got 404&#8242;s to work for non-existant short codes. So, the key with wordpress is to use something like this</p><pre>
header("HTTP/1.1 404 Not Found");
include("index.php");
</pre><p>Basically, I was trying all kinds of other things, then realized that index.php for wordpress will look for the header state, and redirect appropriately. So, that&#8217;s it. It now throws a 404 (which, without that include, it would throw a 404, but it was just a blank page)&#8230; Cheers!</p> ]]></content:encoded> <wfw:commentRss>http://www.staze.org/url-shortener/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Finally got SVN going&#8230;</title><link>http://www.staze.org/finally-got-svn-going/</link> <comments>http://www.staze.org/finally-got-svn-going/#comments</comments> <pubDate>Sat, 13 Feb 2010 04:47:59 +0000</pubDate> <dc:creator>staze</dc:creator> <category><![CDATA[Coding]]></category> <category><![CDATA[10.6]]></category> <category><![CDATA[SVN]]></category> <category><![CDATA[webdav]]></category><guid isPermaLink="false">http://www.staze.org/?p=531</guid> <description><![CDATA[I finally got svn working. So the &#8220;Code&#8221; tab on the title bar now works. This is mainly thanks to this article on Apple&#8217;s developer website. It doesn&#8217;t seem to have any wrong data, even though it&#8217;s for 10.5. I&#8217;ve updated the few links on my site, as well as the InstallRRD script I posted [...]]]></description> <content:encoded><![CDATA[<p>I finally got svn working. So the &#8220;Code&#8221; tab on the title bar now works.</p><p>This is mainly thanks to <a href="http://developer.apple.com/mac/articles/server/subversionwithxcode3.html" rel="nofollow" >this</a> article on Apple&#8217;s developer website. It doesn&#8217;t seem to have any wrong data, even though it&#8217;s for 10.5.</p><p>I&#8217;ve updated the few links on my site, as well as the InstallRRD script I posted yesterday to reflect the change in location for these files.</p><p>Now if I could just get a resume posted, all the above links work be &#8220;valid&#8221;. Maybe in a week or two.</p> ]]></content:encoded> <wfw:commentRss>http://www.staze.org/finally-got-svn-going/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Dokuwiki Highlight plugin</title><link>http://www.staze.org/dokuwiki-highlight-plugin/</link> <comments>http://www.staze.org/dokuwiki-highlight-plugin/#comments</comments> <pubDate>Mon, 21 Sep 2009 04:40:09 +0000</pubDate> <dc:creator>staze</dc:creator> <category><![CDATA[Coding]]></category> <category><![CDATA[DokuWiki]]></category> <category><![CDATA[Highlight]]></category><guid isPermaLink="false">http://www.staze.org/?p=350</guid> <description><![CDATA[Just posting a quick note. Dokuwiki is my wiki of choice, and one of the plugins I use is called &#8220;Highlight&#8221;. The problem is, it&#8217;s kinda hard to get ahold of anymore, and it hasn&#8217;t been updated in forever. The Dokuwiki plugin page for Highlight is here. I have a copy that I have fixed [...]]]></description> <content:encoded><![CDATA[<p>Just posting a quick note. Dokuwiki is my wiki of choice, and one of the plugins I use is called &#8220;Highlight&#8221;. The problem is, it&#8217;s kinda hard to get ahold of anymore, and it hasn&#8217;t been updated in forever.</p><p>The Dokuwiki plugin page for Highlight is <a href="http://www.dokuwiki.org/plugin:highlight" rel="nofollow" >here</a>.</p><p>I have a copy that I have fixed to include the anti-XSS code posted on the plugin page. You can grab a zip of the plugin code <a href="https://www.staze.org/svn/staze/dokuwiki/highlight.zip" rel="nofollow" >here</a>.</p><p>Thanks.</p> ]]></content:encoded> <wfw:commentRss>http://www.staze.org/dokuwiki-highlight-plugin/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Quick note</title><link>http://www.staze.org/quick-note/</link> <comments>http://www.staze.org/quick-note/#comments</comments> <pubDate>Sun, 20 Sep 2009 00:56:34 +0000</pubDate> <dc:creator>staze</dc:creator> <category><![CDATA[Coding]]></category> <category><![CDATA[Energy]]></category> <category><![CDATA[MySQL]]></category> <category><![CDATA[TED]]></category><guid isPermaLink="false">http://www.staze.org/?p=340</guid> <description><![CDATA[So, just a quick note. I just updated the code for the power summary (which is on the left), and fixed the &#8220;current meter reading&#8221;. There were a couple issues, one of which was a bad sql query (not sure why the previous one didn&#8217;t work, but oh well), and for some reason, 2 days [...]]]></description> <content:encoded><![CDATA[<p>So, just a quick note. I just updated the code for the power summary (which is on the left), and fixed the &#8220;current meter reading&#8221;. There were a couple issues, one of which was a bad sql query (not sure why the previous one didn&#8217;t work, but oh well), and for some reason, 2 days of data were missing (which you&#8217;d see if you clicked the &#8220;history&#8221;, and saw two &#8220;0&#8243; graph points.</p><p>Anyway, after fixing those problems, it turns out the &#8220;current meter reading&#8221; is dead on. I&#8217;m not sure how&#8230; and maybe it&#8217;s just a coincidence, but the meter reads exactly what the webpage says. Not too shabby. That means the drift for about 33 days is less than 1KWH, or less than about 300W per day, which given a 30KWH day, that&#8217;s less than 1% inaccuracy.</p><p>So, that&#8217;s it. Just thought I&#8217;d share. =) More actual interesting info later today, or tomorrow.</p> ]]></content:encoded> <wfw:commentRss>http://www.staze.org/quick-note/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Missing OD Attributes</title><link>http://www.staze.org/missing-od-attributes/</link> <comments>http://www.staze.org/missing-od-attributes/#comments</comments> <pubDate>Sat, 19 Sep 2009 05:02:55 +0000</pubDate> <dc:creator>staze</dc:creator> <category><![CDATA[Coding]]></category> <category><![CDATA[System Administration]]></category> <category><![CDATA[10.6]]></category> <category><![CDATA[authAuthority]]></category> <category><![CDATA[GeneratedUID]]></category> <category><![CDATA[iCal Server]]></category> <category><![CDATA[Kerberos]]></category> <category><![CDATA[Open Directory]]></category> <category><![CDATA[UUID]]></category> <category><![CDATA[uuidgen]]></category><guid isPermaLink="false">http://www.staze.org/?p=338</guid> <description><![CDATA[A while back, when 10.5 first shipped, my boss and I were intrigued by iCal Server. And after getting it going, we found that for some reason, we couldn&#8217;t set a calendar server for our users. We&#8217;d set the calendar in Workgroup Manager (WGM hereafter), hit save, and right after that, WGM would uncheck the [...]]]></description> <content:encoded><![CDATA[<p>A while back, when 10.5 first shipped, my boss and I were intrigued by iCal Server. And after getting it going, we found that for some reason, we couldn&#8217;t set a calendar server for our users. We&#8217;d set the calendar in Workgroup Manager (WGM hereafter), hit save, and right after that, WGM would uncheck the box, and set it back to none. Something was weird with our accounts. My boss deleted his account and recreated it, and that fixed it. So, the problem was obviously something with the &#8220;old&#8221; accounts on the system (e.g. the accounts that had been migrated from 10.1 -> 10.2 -> 10.3 -> 10.4 -> 10.5. Some attribute didn&#8217;t get added.</p><p>At first glance, the obvious missing one was there was only one authAuthority entry in our user accounts. Just the ApplePasswordServer entry, no Kerberosv5 entry. And deleting and recreating his account remedied that. So, I put it on the back burner because we figured out that iCal Server was kinda buggy, and later found out that the iPhone couldn&#8217;t write to it, just read (no good). When 10.6 was announced, and we heard that iCal Server 2 supported read/write from the iPhone (with version 3.x+ of the iPhone software), I started thinking about it again. So, I looked at the attribute, and figured out that a single &#8220;sed&#8221; would create the attribute I needed. So, I coded up <a href="https://www.staze.org/svn/staze/scripts/addKerberosv5.sh" rel="nofollow" >this</a>. And figured, problem solved.</p><p>Alas, it was not. While testing a migration of 10.4 email (cyrus) to a 10.6 server (dovecot) using the migrate_mail_data.pl script, I noticed at the end, the script renames the imap spool folders after the user&#8217;s UUID. It failed to rename them for several users (like me) because we didn&#8217;t have a UUID. Then it hit me, iCal Server&#8217;s URLs contain the UUID for the user. No UUID, no iCal Server calendar. DOH! So, I took the Kerberos script, changed it a bit (using uuidgen), and batch added UUIDs for all the users that didn&#8217;t have them (Script <a href="https://www.staze.org/svn/staze/scripts/addGeneratedUID.sh" rel="nofollow" >here</a>. Re-ran the migrate_mail_data.pl script, and viola, all the spools got renamed. Now, I&#8217;m not sure if this really fixes the iCal Server 1 problem, since I don&#8217;t have an iCal Server set up, but iCal Server 2 works (though, it works differently, so this issue doesn&#8217;t occur). I also got word from a bug I filed about the initial issue, that Apple thinks 10.6 fixed it, so I&#8217;d imagine when you upgrade your OD server to 10.6, it adds missing attributes.</p><p>More later, work related. Thought I should keep topics distinct.</p> ]]></content:encoded> <wfw:commentRss>http://www.staze.org/missing-od-attributes/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced)
Database Caching 1/16 queries in 0.013 seconds using apc
Object Caching 528/545 objects using apc

Served from: www.staze.org @ 2010-07-31 02:50:48 -->