<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   >
<channel>
    <title>JasonFried.info - Code</title>
    <link>http://jasonfried.info/</link>
    <description>My Technical Life</description>
    <dc:language>en</dc:language>
    <generator>Serendipity 1.5-beta1 - http://www.s9y.org/</generator>
    <pubDate>Wed, 20 Jul 2011 15:44:22 GMT</pubDate>

    <image>
        <url>http://jasonfried.info/templates/square/img/s9y_banner_small.png</url>
        <title>RSS: JasonFried.info - Code - My Technical Life</title>
        <link>http://jasonfried.info/</link>
        <width>100</width>
        <height>21</height>
    </image>

<item>
    <title>Perl Tail -f Replacement</title>
    <link>http://jasonfried.info/archives/3-Perl-Tail-f-Replacement.html</link>
            <category>Perl</category>
    
    <comments>http://jasonfried.info/archives/3-Perl-Tail-f-Replacement.html#comments</comments>
    <wfw:comment>http://jasonfried.info/wfwcomment.php?cid=3</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://jasonfried.info/rss.php?version=2.0&amp;type=comments&amp;cid=3</wfw:commentRss>
    

    <author>nospam@example.com (Jason Fried)</author>
    <content:encoded>
    &lt;p&gt;If you have ever tried to get a job as a Perl programmer you have probably been asked to create a tail replacement. Well I have. I was bored last night so I made one. Its pretty straight forward, the one issue I can see is that of detecting where the 10th line from the end is, for large files my method may be slow. A character by character search from the tail of the file looking for newline characters could be a faster solution.&lt;/p&gt;
&lt;pre&gt;#!/usr/bin/perl
use strict;

#Get filename and optional lines to tail from
my $filepath = shift @ARGV;
my $lines = shift @ARGV || 10;

#Get the inital inode and size
our ($inode,$size) = filestats($filepath);

open (FILE,$filepath) or die &quot;Could not open $filepath for reading\n&quot;;

my @lineEnds = ();

#Get a list of all the line ending locations
while() {
   push @lineEnds,tell();
}

my $startloc = $lineEnds[($lines*-1)-1];
@lineEnds = (); #No more need;

#Seek to the line requested
seek FILE,$startloc,0;

#Loop Forever, like tail -f
for(;;) {

#Clear Out any EOF flags
seek FILE,0,1; #Seek 0 bytes from current pos

 #Print out any new file contents, or inital requested lines
 while() {
   print;
 }
 sleep(1); #Sleep to allow other procs to run.
 my ($ninode, $nsize) = filestats($filepath); #Get the current inode and file size;

 if ($ninode != $inode) {
    print STDERR &quot;File Rotated Re-opening file @ $filepath\n&quot;;
    close(FILE);
    open(FILE,$filepath) or die &quot;File Could Not be Re-Opened!\n&quot;;
    $inode = $ninode;
    $nsize = $nsize;
 }

 if($nsize &amp;lt; $size) {
    print STDERR &quot;File Cleared Out Seeking to Top\n&quot;;
    seek FILE,0,0; #Seek to Top
    $size = $nsize;
 }

 #Update File size
 $size = $nsize;

}

#Small untility sub for grabing inode and file size;
sub filestats {
    my $file = shift;
    my @stats = stat $file;
    #Inode and file size
    return ($stats[1],$stats[7]);
}

&lt;/pre&gt; 
    </content:encoded>

    <pubDate>Wed, 20 Jul 2011 10:44:22 -0500</pubDate>
    <guid isPermaLink="false">http://jasonfried.info/archives/3-guid.html</guid>
    
</item>
<item>
    <title>Active Directory and Subversion - Fixing the case-sensitive username problem </title>
    <link>http://jasonfried.info/archives/2-Active-Directory-and-Subversion-Fixing-the-case-sensitive-username-problem.html</link>
            <category>Perl</category>
            <category>Subversion</category>
    
    <comments>http://jasonfried.info/archives/2-Active-Directory-and-Subversion-Fixing-the-case-sensitive-username-problem.html#comments</comments>
    <wfw:comment>http://jasonfried.info/wfwcomment.php?cid=2</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://jasonfried.info/rss.php?version=2.0&amp;type=comments&amp;cid=2</wfw:commentRss>
    

    <author>nospam@example.com (Jason Fried)</author>
    <content:encoded>
    &lt;p&gt;&lt;img src=&quot;http://jasonfried.info/uploads/journal/svn-square.jpg&quot; border=&quot;0&quot; alt=&quot;svn-square&quot; title=&quot;svn-square&quot; width=&quot;80&quot; height=&quot;80&quot; /&gt;&lt;img src=&quot;http://jasonfried.info/uploads/journal/svn-name-banner.jpg&quot; border=&quot;0&quot; alt=&quot;svn-name-banner&quot; title=&quot;svn-name-banner&quot; width=&quot;320&quot; height=&quot;80&quot; /&gt;&lt;/p&gt;
&lt;p&gt;If you are running Subversion under Apache HTTPD and you are using the basic ldap provider to connect to Active Directory, then you know that Active Directory will let you authenticate using any case as long as the password matches. Normally this would not be a problem, as most of the time people do not add capitalization to their login names. Where this becomes a problem is when your using an &quot;sn authz&quot; file, which is case-sensitive.&lt;/p&gt;
&lt;p style=&quot;padding-left: 30px;&quot;&gt;joe.user = rw&lt;/p&gt;
&lt;p&gt;this will not match if he logs in with &quot;Joe.User&quot;. I became tired of telling people to use only lower-case that I decided to fix the problem for good. I had two possible solutions, patch Subversion or Make a custom authentication provider for Apache. The Apache route sounded easier and not prone to breaking next Subversion update. I already had mod_perl installed so it was quite easy to setup using &lt;a onclick=&quot;javascript: pageTracker._trackPageview(&#039;/extlink/search.cpan.org/~geoff/Apache-AuthenHook-2.00_04/AuthenHook.pm&#039;);&quot;  href=&quot;http://search.cpan.org/~geoff/Apache-AuthenHook-2.00_04/AuthenHook.pm&quot; target=&quot;_blank&quot; title=&quot;Apache::AuthenHook&quot;&gt;Apache::AuthenHook&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;So first thing you need to do is create a lib folder somewhere to hold your basic provider pm file. I have a pretty organized subversion setup so i just created lib folder in my subversion root.&lt;/p&gt;
&lt;pre&gt;[jfried@svn01]:/&amp;gt; cat /infrastructure/source/lib/Fried/LDAPProvider.pm
package Fried::LDAPProvider;
use Net::LDAP;
use Apache2::RequestRec;
use Apache2::Const -compile =&amp;gt; qw(OK DECLINED HTTP_UNAUTHORIZED);
use strict;

sub handler {
    my ($r, $user, $password) = @_;
    my $ldap = Net::LDAP-&amp;gt;new (&#039;ldaps://DOMAIN&#039;) 
                                       or return Apache2::Const::DECLINED;
    my $mesg = $ldap-&amp;gt;bind(&quot;$user@DOMAIN&quot;, password =&amp;gt; $password );
    $mesg-&amp;gt;code &amp;amp;&amp;amp; return Apache2::Const::DECLINED;
    if ($mesg-&amp;gt;{resultCode} == 0) {
        $r-&amp;gt;user(lc $user);
        return Apache2::Const::OK;
    }
    $ldap-&amp;gt;unbind;

    return Apache2::Const::DECLINED;
}
1;
&lt;/pre&gt;
&lt;p&gt;Just Update DOMAIN with your Active Directory Domain name. The important part that fixes the problem is the $r-&amp;gt;user(lc $user) which tells Apache what the user name should be.&lt;/p&gt;
&lt;p&gt;Now to make Apache make use of this we put the following inside our Apache configuration. Inside your subversion virtual host.&lt;/p&gt;
&lt;pre&gt;PerlSwitches -I/infrastructure/source/lib
PerlLoadModule Apache::AuthenHook

&amp;lt;Location /repos/&amp;gt;
    DAV svn
    SVNParentPath /infrastructure/source/repos
    ...
    AuthType Basic
    AuthBasicProvider Fried::LDAPProvider
    AuthName &quot;Subversion Repositories&quot;
    Require valid-user
    ...
&amp;lt;/Location&amp;gt;
&lt;/pre&gt;
&lt;p&gt;Reload and authz works no mater what case they login with.&lt;/p&gt; 
    </content:encoded>

    <pubDate>Thu, 10 Jun 2010 16:11:44 -0500</pubDate>
    <guid isPermaLink="false">http://jasonfried.info/archives/2-guid.html</guid>
    
</item>

</channel>
</rss>
