<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Programming on The Shadow File</title>
    <link>https://shadowfile.inode.link/tags/programming/</link>
    <description>Recent content in Programming on The Shadow File</description>
    <generator>Hugo</generator>
    <language>en</language>
    <lastBuildDate>Sun, 15 Mar 2009 09:18:00 -0700</lastBuildDate>
    <atom:link href="https://shadowfile.inode.link/tags/programming/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Handling HTTP Redirection in Ruby</title>
      <link>https://shadowfile.inode.link/blog/2009/03/handling-http-redirection-in-ruby/</link>
      <pubDate>Sun, 15 Mar 2009 09:18:00 -0700</pubDate>
      <guid>https://shadowfile.inode.link/blog/2009/03/handling-http-redirection-in-ruby/</guid>
      <description>&lt;p&gt;I have a Ruby project where I&amp;rsquo;m dumping a bunch of bookmarks from&#xA;delicious.com, then fetching each bookmarked page for analysis.&lt;/p&gt;&#xA;&lt;p&gt;One of the problems I encountered early on is that the some of the web&#xA;pages bookmarked would redirect to some other location. Simply checking&#xA;for HTTP response code 200 was insufficient. I needed to check for&#xA;redirection as well.&lt;/p&gt;&#xA;&lt;p&gt;A quick Google search for &amp;ldquo;ruby follow http redirect&amp;rdquo; yields lots of&#xA;&lt;a href=&#34;http://www.google.com/search?q=ruby&amp;#43;follow&amp;#43;http&amp;#43;redirect&amp;amp;ie=utf-8&amp;amp;oe=utf-8&amp;amp;aq=t&amp;amp;rls=org.mozilla:en-US:official&amp;amp;client=firefox-a&#34; target=&#34;_blank&#34;&gt;results&lt;/a&gt;.&#xA;Unfortunately, they&amp;rsquo;re all very similar, and not quite right. In&#xA;general, the examples you come across (even the one in the official Ruby&#xA;documentation) don&amp;rsquo;t handle the case when the redirected location is&#xA;path relative to the original location. So you end up doing a get on a&#xA;URL that looks like &amp;ldquo;../../redirected/location/index.html,&amp;rdquo; which&#xA;clearly won&amp;rsquo;t work.&lt;/p&gt;</description>
    </item>
    <item>
      <title>How to sudoedit non-interactively</title>
      <link>https://shadowfile.inode.link/blog/2009/01/how-to-sudoedit-non-interactively/</link>
      <pubDate>Thu, 08 Jan 2009 06:31:00 -0800</pubDate>
      <guid>https://shadowfile.inode.link/blog/2009/01/how-to-sudoedit-non-interactively/</guid>
      <description>&lt;p&gt;Okay, this one&amp;rsquo;s a bit esoteric, but I think it&amp;rsquo;s pretty cool. How do&#xA;you use &amp;lsquo;sudoedit&amp;rsquo; non-interactively such as from a script? Just a brief&#xA;background about sudo: sudo is an authentication mechanism in Unix &amp;amp;&#xA;Linux that allows unprivileged users to run specific commands (as&#xA;defined by the system administrator) with root privileges without having&#xA;the root password. This has several advantages over logging in as&#xA;root:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Users can have specific, limited set of root privileges without&#xA;having the entire set of root privileges.&lt;/li&gt;&#xA;&lt;li&gt;Users use their &lt;!-- raw HTML omitted --&gt;own&lt;!-- raw HTML omitted --&gt;&#xA;password, so the root password doesn&amp;rsquo;t have to be shared. If a&#xA;user&amp;rsquo;s sudo privileges are revoked, the root password doesn&amp;rsquo;t have&#xA;to be reset.&lt;/li&gt;&#xA;&lt;li&gt;Each use of sudo is audited per user, so that each time sudo&#xA;privileges are invoked, there is an event in the system logs that&#xA;identifies the specific user and the command they ran.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Sudoedit is a command that is related to sudo. It lets users edit files&#xA;that normally only root can edit, such as system configuration files.&#xA;However instead of using &amp;ldquo;sudo&amp;rdquo; followed by the editing command, the&#xA;user runs &amp;ldquo;sudoedit filename&amp;rdquo; and sudo invokes the user&amp;rsquo;s default&#xA;editor, letting them edit the file.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
