<?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>Steven Harms &#187; Programming</title>
	<atom:link href="http://www.sharms.org/blog/category/programming-related-posts/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sharms.org/blog</link>
	<description>Life, Linux and Technology</description>
	<lastBuildDate>Sun, 28 Aug 2011 18:02:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Gitorious and Fully Qualified Domain Names (FQDN)</title>
		<link>http://www.sharms.org/blog/2011/02/gitorious-and-fully-qualified-domain-names-fqdn/</link>
		<comments>http://www.sharms.org/blog/2011/02/gitorious-and-fully-qualified-domain-names-fqdn/#comments</comments>
		<pubDate>Thu, 17 Feb 2011 15:08:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[gitorious]]></category>
		<category><![CDATA[installation]]></category>

		<guid isPermaLink="false">http://www.sharms.org/blog/?p=806</guid>
		<description><![CDATA[When you want to install your own version of gitorious, a lot of people seem to run into issues where they don&#8217;t have a real DNS name for their servers. This breaks the session code of gitorious. I just ran a &#8216;git diff&#8217; on my gitorious tree, and here are the changes I made to [...]


Related posts:<ol><li><a href='http://www.sharms.org/blog/2010/07/sles-sp1-and-novell-suse-autoyast-with-intel-dell-raid-controllers/' rel='bookmark' title='Permanent Link: SLES 11 SP1 and Novell / SUSE Autoyast with Intel / Dell Raid Controllers'>SLES 11 SP1 and Novell / SUSE Autoyast with Intel / Dell Raid Controllers</a></li>
<li><a href='http://www.sharms.org/blog/2009/02/finding-the-difference-between-two-files/' rel='bookmark' title='Permanent Link: Finding the difference between two files'>Finding the difference between two files</a></li>
<li><a href='http://www.sharms.org/blog/2009/06/installing-groupwise-8-client-in-ubuntu-jaunty-amd64/' rel='bookmark' title='Permanent Link: Installing Groupwise 8 Client in Ubuntu Jaunty AMD64'>Installing Groupwise 8 Client in Ubuntu Jaunty AMD64</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>When you want to install your own version of gitorious, a lot of people seem to run into issues where they don&#8217;t have a real DNS name for their servers.  This breaks the session code of gitorious.</p>
<p>I just ran a &#8216;git diff&#8217; on my gitorious tree, and here are the changes I made to make it work:</p>
<pre class="brush: diff">

diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb
index 7384f93..2409810 100644
--- a/config/initializers/session_store.rb
+++ b/config/initializers/session_store.rb
@@ -8,7 +8,8 @@ gitorious_yaml = YAML::load_file(File.join(Rails.root, &quot;config/gitorious.yml&quot;))[
 ActionController::Base.session = {
   :key    =&gt; &#039;_gitorious_sess&#039;,
   :secret =&gt; gitorious_yaml[&#039;cookie_secret&#039;],
-  :domain =&gt; &quot;.#{gitorious_yaml[&quot;gitorious_host&quot;]}&quot;,
+#  :domain =&gt; &quot;.#{gitorious_yaml[&quot;gitorious_host&quot;]}&quot;,
+  :domain =&gt; &quot;10.80.21.73&quot;,
   :expire_after =&gt; 3.weeks,
 }
</pre>
<p>And also:</p>
<pre class="brush: diff">
diff --git a/app/models/repository.rb b/app/models/repository.rb
index c4fd612..1df689c 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -226,7 +226,7 @@ class Repository &lt; ActiveRecord::Base
   end

   def http_clone_url
-    &quot;http://git.#{GitoriousConfig[&#039;gitorious_host&#039;]}/#{gitdir}&quot;
+    &quot;http://#{GitoriousConfig[&#039;gitorious_host&#039;]}/#{gitdir}&quot;
   end

   def http_cloning?
</pre>
<p>If you change 10.80.21.73 to whatever your ip is, all of your troubles should go away.</p>


<p>Related posts:<ol><li><a href='http://www.sharms.org/blog/2010/07/sles-sp1-and-novell-suse-autoyast-with-intel-dell-raid-controllers/' rel='bookmark' title='Permanent Link: SLES 11 SP1 and Novell / SUSE Autoyast with Intel / Dell Raid Controllers'>SLES 11 SP1 and Novell / SUSE Autoyast with Intel / Dell Raid Controllers</a></li>
<li><a href='http://www.sharms.org/blog/2009/02/finding-the-difference-between-two-files/' rel='bookmark' title='Permanent Link: Finding the difference between two files'>Finding the difference between two files</a></li>
<li><a href='http://www.sharms.org/blog/2009/06/installing-groupwise-8-client-in-ubuntu-jaunty-amd64/' rel='bookmark' title='Permanent Link: Installing Groupwise 8 Client in Ubuntu Jaunty AMD64'>Installing Groupwise 8 Client in Ubuntu Jaunty AMD64</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.sharms.org/blog/2011/02/gitorious-and-fully-qualified-domain-names-fqdn/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Automatically Backup Blogs / Websites to Amazon S3</title>
		<link>http://www.sharms.org/blog/2011/01/automatically-backup-blogs-websites-to-amazon-s3/</link>
		<comments>http://www.sharms.org/blog/2011/01/automatically-backup-blogs-websites-to-amazon-s3/#comments</comments>
		<pubDate>Wed, 12 Jan 2011 21:00:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.sharms.org/blog/?p=797</guid>
		<description><![CDATA[I maintain several personal websites, and felt they should be backed up in case my Xen host has issues. Step 1 Create an Amazon S3 account at http://aws.amazon.com/s3/.  Once your account is created, you will need to create &#8216;credentials&#8217;, which will allow us to authenticate with S3.  You can access this by going to the [...]


Related posts:<ol><li><a href='http://www.sharms.org/blog/2008/05/fun-with-amazon-s3-in-ubuntu-hardy/' rel='bookmark' title='Permanent Link: Fun with Amazon S3 in Ubuntu Hardy'>Fun with Amazon S3 in Ubuntu Hardy</a></li>
<li><a href='http://www.sharms.org/blog/2009/06/interesting-blogs/' rel='bookmark' title='Permanent Link: Interesting Blogs'>Interesting Blogs</a></li>
<li><a href='http://www.sharms.org/blog/2009/04/dropbox-on-ubuntu/' rel='bookmark' title='Permanent Link: Dropbox on Ubuntu'>Dropbox on Ubuntu</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I maintain several personal websites, and felt they should be backed up in case my Xen host has issues.</p>
<p><strong>Step 1</strong></p>
<p>Create an Amazon S3 account at <a href="http://aws.amazon.com/s3/">http://aws.amazon.com/s3/</a>.  Once your account is created, you will need to create <strong>&#8216;credentials&#8217;</strong>, which will allow us to authenticate with S3.  You can access this by going to the <strong>&#8220;Amazon -&gt; Account -&gt; AWS Identity and Access Management&#8221;</strong> then clicking <strong>&#8216;Security Credentials&#8217;</strong> on the left, and then creating a <strong>&#8216;Access Key&#8217;</strong>.  These keys are composed of 2 parts: a public portion, called the <strong>&#8216;Access Key ID&#8217;</strong>, and a private portion (never to be shared) called the <strong>&#8216;Secret Access Key&#8217;</strong>.</p>
<p><a href="http://www.sharms.org/blog/wp-content/uploads/2011/01/amazon-credentials.png"><img class="aligncenter size-full wp-image-798" title="Amazon Security Credentials" src="http://www.sharms.org/blog/wp-content/uploads/2011/01/amazon-credentials.png" alt="Amazon Security Credentials" width="726" height="518" /></a></p>
<p><strong>Step 2</strong></p>
<p>We need to install a program called <strong>&#8216;s3cmd&#8217;</strong>.  This will allow us to interface with Amazon S3 via the command line.  On Ubuntu:</p>
<pre class="brush: sh">
sudo apt-get install s3cmd
</pre>
<p><strong>Step 3</strong></p>
<p>Now we need to setup <strong>s3cmd</strong> to save settings about our setup.  Make sure you have the <strong>Access Key ID</strong> and the <strong>Secret Key</strong>.  Run the following command to get started:</p>
<pre class="brush: sh">
s3cmd --configure
</pre>
<p>From here you will get an interactive prompt:  </p>
<pre>
Enter new values or accept defaults in brackets with Enter.
Refer to user manual for detailed description of all options.

Access key and Secret key are your identifiers for Amazon S3
Access Key: 231231232
Secret Key: 213123123

Encryption password is used to protect your files from reading
by unauthorized persons while in transfer to S3
Encryption password: ubuntu
Path to GPG program [/usr/bin/gpg]: 

When using secure HTTPS protocol all communication with Amazon S3
servers is protected from 3rd party eavesdropping. This method is
slower than plain HTTP and can't be used if you're behind a proxy
Use HTTPS protocol [No]: yes

New settings:
  Access Key: 231231232
  Secret Key: 213123123
  Encryption password: ubuntu
  Path to GPG program: /usr/bin/gpg
  Use HTTPS protocol: True
  HTTP Proxy server name:
  HTTP Proxy server port: 0

Test access with supplied credentials? [Y/n]
</pre>
<p>I chose to pick &#8220;Use HTTPS protocol&#8221;, which will upload it via a secure method.  This is a good idea, although will slightly impact performance and may use slightly more traffic.  In addition, s3cmd also will encrypt the files using gpg, which means that if someone broke into your s3 account, they would still need that pass phrase to decrypt your data.</p>
<p><strong>Step 4</strong><br />
We can now test <strong>s3cmd</strong> and try to upload a file.  You will need to create a <strong>&#8216;bucket&#8217;</strong>, which is where our files for this project are stored.  You can have many buckets, so if you want to separate your projects you could create additional ones for each one.  When we make a bucket name, they are globally visible in S3, so you will want to pick something not likely to be taken:</p>
<pre class="brush: sh">
s3cmd mb s3://sharms.org-wordpress-blog
</pre>
<p>If that command runs successfully, we now have a new bucket called &#8216;sharms.org-wordpress-blog&#8217;.  If not, pick a different name and try again.  Now we can test uploading a file:</p>
<pre class="brush: sh">
s3cmd put /home/sharms/testfile.txt s3://sharms.org-wordpress-blog

# Verify its where we think it is
s3cmd ls s3://sharms.org-wordpress-blog
</pre>
<p><strong>Step 5</strong><br />
Using bash, we can automate this, and backup all of our files, daily, weekly, monthly etc.  Here is an example, which I put at <strong>&#8216;/usr/local/bin/backup_blog_to_s3.sh&#8217;</strong>:</p>
<pre class="brush: sh">
bucket=&quot;s3://sharms.org-wordpress-blog&quot;

logger -t backup_blog_to_s3.sh &quot;Backing up sharms.org blog to S3&quot;
cd /var/www
tar -cf sharms.org.tar blog
bzip2 -9 sharms.org.tar
s3cmd put sharms.org.tar.bz2 ${bucket}
rm /var/www/sharms.org.tar.bz2

logger -t backup_blog_to_s3.sh &quot;Backing up MySQL database to S3&quot;
mysqldump sharms-wordpress -u databaseuser -p databasepassword -a -r sharms-wordpress.sql
bzip2 -9 sharms-wordpress.sql
s3cmd put sharms-wordpress.sql.bz2 ${bucket}
rm sharms-wordpress.sql.bz2
</pre>
<p>You can see from the example that we backup all of the files in the &#8216;blog&#8217; directory, and export all of our data out of a MySQL database.  You can even change the file names so they have the date when they were backed up:</p>
<pre class="brush: sh">
tar -cf sharms.org-wordpress-$(date +%d%m%y) blog
</pre>
<p><strong>Running Automatically</strong><br />
If we wanted to backup the system every day, this is very easy:</p>
<pre class="brush: sh">
sudo cp /usr/local/bin/backup_blog_to_s3.sh /etc/cron.daily
sudo chmod 755 /etc/cron.daily
</pre>
<p><strong>Security Notes</strong><br />
When considering this setup, you are most vulnerable to someone obtaining access to your server, and getting your Amazon keys.  You can always revoke them from the Amazon Webservices Control Panel, but you don&#8217;t want an attacker using your S3 account for nefarious means.  Beyond the scope of this document, you could setup a user called &#8216;backups&#8217;, and make the file &#8216;~backups/.s3cmd&#8217; with the permissions &#8217;600&#8242;, to stop other users from looking at it&#8217;s contents. </p>


<p>Related posts:<ol><li><a href='http://www.sharms.org/blog/2008/05/fun-with-amazon-s3-in-ubuntu-hardy/' rel='bookmark' title='Permanent Link: Fun with Amazon S3 in Ubuntu Hardy'>Fun with Amazon S3 in Ubuntu Hardy</a></li>
<li><a href='http://www.sharms.org/blog/2009/06/interesting-blogs/' rel='bookmark' title='Permanent Link: Interesting Blogs'>Interesting Blogs</a></li>
<li><a href='http://www.sharms.org/blog/2009/04/dropbox-on-ubuntu/' rel='bookmark' title='Permanent Link: Dropbox on Ubuntu'>Dropbox on Ubuntu</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.sharms.org/blog/2011/01/automatically-backup-blogs-websites-to-amazon-s3/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>On Why Open Source Developers Run Mac OS X</title>
		<link>http://www.sharms.org/blog/2010/12/on-why-open-source-developers-run-mac-os-x/</link>
		<comments>http://www.sharms.org/blog/2010/12/on-why-open-source-developers-run-mac-os-x/#comments</comments>
		<pubDate>Fri, 17 Dec 2010 15:55:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[apple.programming]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.sharms.org/blog/?p=775</guid>
		<description><![CDATA[A common trend among many of the best developers is to see them posting screenshots running OS X. Many of the best developers, some my personal &#8216;developer heroes&#8217;, have made the switch to OS X. It&#8217;s All About the Mentality I respect and admire programmers like @migueldeicaza, @mitsuhiko, mandrake, @dhh for all they have accomplished. [...]


Related posts:<ol><li><a href='http://www.sharms.org/blog/2008/10/open-source-radeonhd-driver-122-released/' rel='bookmark' title='Permanent Link: Open Source RadeonHD driver 1.2.2 released'>Open Source RadeonHD driver 1.2.2 released</a></li>
<li><a href='http://www.sharms.org/blog/2008/11/creative-open-sources-their-driver/' rel='bookmark' title='Permanent Link: Creative open sources their driver'>Creative open sources their driver</a></li>
<li><a href='http://www.sharms.org/blog/2007/11/howto-add-updated-e1000-driver-to-sled-10-sp1/' rel='bookmark' title='Permanent Link: Howto:  Add updated e1000 driver to SLED 10 SP1'>Howto:  Add updated e1000 driver to SLED 10 SP1</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>A common trend among many of the best developers is to see them posting screenshots running OS X.  Many of the best developers, some my personal &#8216;developer heroes&#8217;, have made the switch to OS X.</p>
<p><strong>It&#8217;s All About the Mentality</strong><br />
I respect and admire programmers like <a href="http://twitter.com/#!/migueldeicaza">@migueldeicaza</a>, <a href="http://twitter.com/#!/mitsuhiko">@mitsuhiko</a>, <a href="http://www.mandrake.net">mandrake</a>, <a href="http://twitter.com/#!/dhh">@dhh</a> for all they have accomplished.  One thing they all have in common, present day, is running OS X.  Mandrake cowrote Enlightenment (which is the original really cool window manager for Linux), Miguel started Gnome, and the majority of code both Mitsuhiko (wrote almost every useful Python library ever) and DHH (Ruby on Rails) write run on Linux backends to say the least.</p>
<p>What are they most known for?  Problem solving skills mixed with actually producing / releasing.  </p>
<p><strong>Linux is Open Source</strong><br />
And this, I believe, is why great developers tend to move towards OS X (yes, there are plenty of exceptions).  A critical piece of writing software is focus.  When a problem solver uses a Linux desktop, they are immediately confronted with the possibility of being able to modify every part of their system.  When a problem solver runs OS X, their options are severely limited, by design.</p>
<p>I think all of us are guilty for hunting down PPAs to get a backported browser, or running &#8216;./configure &#038;&#038; make &#038;&#038; make install&#8217; at some point.  And when you have programming skills, source code can turn into a detriment to productivity when you start modifying projects outside of what you intended to accomplish.  All of a sudden you start hacking a project for a few minutes, and wake up days later in a coding haze with all of that time lost.</p>
<p>Personally I have had experience with this while using old Linux distributions.  We have SLES 9 systems and SLES 10 systems here at work, and in the past year I have spent countless hours hacking Sprint 3G wireless drivers, USB over IP, Firefox 3 and countless others to work on these older systems.  Why?  Not because they are the primary goal, but because I could, which in turn took up time from things I actually &#8220;wanted&#8221; to do.</p>
<p><strong>Time is Valuable</strong><br />
Watching one of Miguel&#8217;s presentations, he mentions that he does not have enough years left to &#8220;worry about memory management&#8221; and that they leave that to the younger folks.  This is the crux of the argument.  For programmers, there is far too much opportunity for distraction at every avenue.  We don&#8217;t know how long we will be here for, but certainly we know that nothing we care about will get done as long as our focus is spread so thin across the spectrum of Linux.</p>
<p><strong>Summary</strong><br />
This is all just food for thought, not a judgement against any form of desktop or usage pattern.  For reference, I am still running Ubuntu on my desktop, and being wildly unproductive on the tasks I want to finish.</p>


<p>Related posts:<ol><li><a href='http://www.sharms.org/blog/2008/10/open-source-radeonhd-driver-122-released/' rel='bookmark' title='Permanent Link: Open Source RadeonHD driver 1.2.2 released'>Open Source RadeonHD driver 1.2.2 released</a></li>
<li><a href='http://www.sharms.org/blog/2008/11/creative-open-sources-their-driver/' rel='bookmark' title='Permanent Link: Creative open sources their driver'>Creative open sources their driver</a></li>
<li><a href='http://www.sharms.org/blog/2007/11/howto-add-updated-e1000-driver-to-sled-10-sp1/' rel='bookmark' title='Permanent Link: Howto:  Add updated e1000 driver to SLED 10 SP1'>Howto:  Add updated e1000 driver to SLED 10 SP1</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.sharms.org/blog/2010/12/on-why-open-source-developers-run-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>38</slash:comments>
		</item>
		<item>
		<title>Programming using IOCTL to interface with Linux kernel drivers</title>
		<link>http://www.sharms.org/blog/2010/06/programming-using-ioctl-to-interface-with-linux-kernel-drivers/</link>
		<comments>http://www.sharms.org/blog/2010/06/programming-using-ioctl-to-interface-with-linux-kernel-drivers/#comments</comments>
		<pubDate>Fri, 18 Jun 2010 19:14:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.sharms.org/blog/?p=721</guid>
		<description><![CDATA[IOCTL is a function call that allows you to interface with kernel drivers, allowing you to adjust settings or set parameters from code without compiling a new module. From a programming perspective, having the linux kernel source is a prerequisite. In this example, I cloned the main kernel: git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git linux Once I had [...]


Related posts:<ol><li><a href='http://www.sharms.org/blog/2009/07/programming-in-c-converting-an-integer-to-binary-int-to-bin/' rel='bookmark' title='Permanent Link: Programming in C: Converting an Integer to Binary (int to bin)'>Programming in C: Converting an Integer to Binary (int to bin)</a></li>
<li><a href='http://www.sharms.org/blog/2009/07/fun-stuff/' rel='bookmark' title='Permanent Link: MMap to null'>MMap to null</a></li>
<li><a href='http://www.sharms.org/blog/2008/12/why/' rel='bookmark' title='Permanent Link: Why?'>Why?</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>IOCTL is a function call that allows you to interface with kernel drivers, allowing you to adjust settings or set parameters from code without compiling a new module.  </p>
<p>From a programming perspective, having the linux kernel source is a prerequisite.  In this example, I cloned the main kernel:</p>
<pre class="brush: sh">
git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git linux
</pre>
<p>Once I had the source, I specifically wanted to see exactly how I could interface with the driver called <strong>usblp</strong>.  I was using a USB to parallel port converter, and wanted to see if there was any way to force it to operate differently as we needed a non-printer device to work with it.</p>
<p>After opening the kernel source, I found the driver file itself which was under <strong>/drivers/usb/class/usblp.c</strong>.  In this file I found a section of information about which IOCTLs it supported, and put them in a header file for my program called usblp-hack.h:</p>
<pre class="brush: c">
#ifndef USBLP_HACK_H
#define USBLP_HACK_H

#include &lt;linux/ioctl.h&gt;

/* ioctls: */
#define IOCNR_GET_DEVICE_ID     1
#define IOCNR_GET_PROTOCOLS     2
#define IOCNR_SET_PROTOCOL      3
#define IOCNR_HP_SET_CHANNEL        4
#define IOCNR_GET_BUS_ADDRESS       5
#define IOCNR_GET_VID_PID       6
#define IOCNR_SOFT_RESET        7
/* Get device_id string: */
#define LPIOC_GET_DEVICE_ID(len) _IOC(_IOC_READ, &#039;P&#039;, IOCNR_GET_DEVICE_ID, len)
/* The following ioctls were added for http://hpoj.sourceforge.net: */
/* Get two-int array:
 * [0]=current protocol (1=7/1/1, 2=7/1/2, 3=7/1/3),
 * [1]=supported protocol mask (mask&amp;(1&lt;&lt;n)!=0 means 7/1/n supported): */
#define LPIOC_GET_PROTOCOLS(len) _IOC(_IOC_READ, &#039;P&#039;, IOCNR_GET_PROTOCOLS, len)
/* Set protocol (arg: 1=7/1/1, 2=7/1/2, 3=7/1/3): */
#define LPIOC_SET_PROTOCOL _IOC(_IOC_WRITE, &#039;P&#039;, IOCNR_SET_PROTOCOL, 0)
/* Set channel number (HP Vendor-specific command): */
#define LPIOC_HP_SET_CHANNEL _IOC(_IOC_WRITE, &#039;P&#039;, IOCNR_HP_SET_CHANNEL, 0)
/* Get two-int array: [0]=bus number, [1]=device address: */
#define LPIOC_GET_BUS_ADDRESS(len) _IOC(_IOC_READ, &#039;P&#039;, IOCNR_GET_BUS_ADDRESS, len)
/* Get two-int array: [0]=vendor ID, [1]=product ID: */
#define LPIOC_GET_VID_PID(len) _IOC(_IOC_READ, &#039;P&#039;, IOCNR_GET_VID_PID, len)
/* Perform class specific soft reset */
#define LPIOC_SOFT_RESET _IOC(_IOC_NONE, &#039;P&#039;, IOCNR_SOFT_RESET, 0)
#endif
</pre>
<p>There are plenty of hints on usage here, and I was able to grab a little more info after searching for some of those defines in google code search.  Using these IOCTLs I wanted to know exactly which modes the USB to parallel converter supported, and try to set it in mode 3, which I hoped would give me more options for talking to the device.</p>
<p>Here is my usblp-hack.c which was able to probe and update these settings, although in my case mode 3 didn&#8217;t work, but shows an example of exactly how to do it:</p>
<pre class="brush: c">
#include &quot;usblp-hack.h&quot;
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;fcntl.h&gt;		/* open */
#include &lt;unistd.h&gt;		/* exit */
#include &lt;sys/ioctl.h&gt;		/* ioctl */

main()
{
	int fd;
	int twoints[2];

	fd = open(&quot;/dev/usblp0&quot;, O_RDONLY | O_NONBLOCK);
	if (fd &lt; 0) {
		printf(&quot;Cannot open device.\n&quot;);
		exit(-1);
	}

	if(ioctl(fd, LPIOC_GET_PROTOCOLS(sizeof(int[2])), &amp;twoints) &gt;= 0)
		printf(&quot;Great success: %d / %d\n&quot;, twoints[0], twoints[1]);
	else {
		printf(&quot;Fail!\n&quot;);
		exit(-1);
	}

	if(ioctl(fd, LPIOC_SET_PROTOCOL, 2) &gt;= 0)
		printf(&quot;set protocol to version 2\n&quot;);
	else {
		printf(&quot;Fail!\n&quot;);
		exit(-1);
	}

	if(ioctl(fd, LPIOC_GET_PROTOCOLS(sizeof(int[2])), &amp;twoints) &gt;= 0)
		printf(&quot;Great success: %d / %d\n&quot;, twoints[0], twoints[1]);
	else {
		printf(&quot;Fail!\n&quot;);
		exit(-1);
	}

	if(ioctl(fd, LPIOC_SOFT_RESET) &gt;= 0)
	{
		printf(&quot;Success reset device\n&quot;);
	} else {
		printf(&quot;Could not reset device\n&quot;);
		exit(-1);
	}

	close(fd);
	exit(0);
}
</pre>
<p>You can compile the above example just using gcc:</p>
<pre class="brush: sh">
gcc -o usblp-hack usblp-hack.c
</pre>
<p>You can see in the example above I was able to probe the device to see what mode it was currently in and supports (<strong>LPIOC_GET_PROTOCOLS</strong>), attempt to set the device mode (<strong>LPIOC_SET_PROTOCOL</strong>), and soft reset the device (<strong>LPIOC_SOFT_RESET</strong>).</p>
<p>So in the end, nothing here too complex or mind blowing, but if you are just getting your feet wet it might take you a minute to dig this sort of information up.</p>


<p>Related posts:<ol><li><a href='http://www.sharms.org/blog/2009/07/programming-in-c-converting-an-integer-to-binary-int-to-bin/' rel='bookmark' title='Permanent Link: Programming in C: Converting an Integer to Binary (int to bin)'>Programming in C: Converting an Integer to Binary (int to bin)</a></li>
<li><a href='http://www.sharms.org/blog/2009/07/fun-stuff/' rel='bookmark' title='Permanent Link: MMap to null'>MMap to null</a></li>
<li><a href='http://www.sharms.org/blog/2008/12/why/' rel='bookmark' title='Permanent Link: Why?'>Why?</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.sharms.org/blog/2010/06/programming-using-ioctl-to-interface-with-linux-kernel-drivers/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Java</title>
		<link>http://www.sharms.org/blog/2010/05/java/</link>
		<comments>http://www.sharms.org/blog/2010/05/java/#comments</comments>
		<pubDate>Thu, 27 May 2010 01:16:13 +0000</pubDate>
		<dc:creator>sharms</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.sharms.org/blog/?p=716</guid>
		<description><![CDATA[It has always been trendy to make fun of Java, and wax poetic about how superior someone&#8217;s language of choice is. The fact of the matter is, whether or not you wish to acknowledge it, more users run Java applications on Linux than any other language1. In the past few years, I have had the [...]


Related posts:<ol><li><a href='http://www.sharms.org/blog/2008/12/64-bit-java-browser-plugin/' rel='bookmark' title='Permanent Link: 64-bit Java browser plugin'>64-bit Java browser plugin</a></li>
<li><a href='http://www.sharms.org/blog/2009/12/installing-play-framework-on-openbsd-4-6/' rel='bookmark' title='Permanent Link: Installing Play Framework on OpenBSD 4.6'>Installing Play Framework on OpenBSD 4.6</a></li>
<li><a href='http://www.sharms.org/blog/2006/12/run-your-java-apps-under-aiglx/' rel='bookmark' title='Permanent Link: Run your java apps under Aiglx'>Run your java apps under Aiglx</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>It has always been trendy to make fun of Java, and wax poetic about how superior someone&#8217;s language of choice is. The fact of the matter is, whether or not you wish to acknowledge it, more users run Java applications on Linux than any other language<sup><a href="http://www.sharms.org/blog/2010/05/java/#footnote_0_716" id="identifier_0_716" class="footnote-link footnote-identifier-link" title="http://www.electronista.com/articles/10/05/26/admob.april.2010.study.has.android.near.even/">1</a></sup>.</p>
<p>In the past few years, I have had the opportunity to code multiple enterprise web applications in any language I chose.  I made a few in Symfony (php), Django (python), and recently I used Play (java).  All of them were fantastic frameworks and languages in their own respect (the only thing people make fun of more than Java is PHP, again generally baseless).</p>
<p>I have used vim for as long as I can remember, but for the Play project I switched over to Eclipse, and that was also a great IDE.  A lot of nice features where it would automated a lot of typing, and I found managing multiple files slightly easier.</p>
<p>Point being the language and the tools around it are there, well tested, and ready for prime time.  Given the right coder, they are just as effective as any of the trendy languages, and to dismiss that based on outright false statements on most comment threads is absurd.</p>
<p><strong>Performance:</strong> Java in no way, in any application I wrote, was limited by the language or jvm in performance.  This is generally affected entirely by the coder, not the language.</p>
<p><strong>Adoption:</strong>  Java is all over my business, and is the clear leader in the enterprise technology stack<sup><a href="http://www.sharms.org/blog/2010/05/java/#footnote_1_716" id="identifier_1_716" class="footnote-link footnote-identifier-link" title="http://www.forrester.com/rb/Research/of_strategic_languages%2C_javas_adoption_is_highest/q/id/37356/t/2">2</a></sup></p>
<p><strong>Tools:</strong> Tools for Java are abundant, feature rich, and more than adequate to develop complex projects</p>
<p><strong>Criticisms:</strong>  The only valid criticism is that Java apps are slow to load up initially, for user apps.  I think with the innovation we see with respect to JVM performance improvements (JIT compilation etc)<sup><a href="http://www.sharms.org/blog/2010/05/java/#footnote_2_716" id="identifier_2_716" class="footnote-link footnote-identifier-link" title="http://www.h-online.com/open/news/item/Android-s-Dalvik-to-be-JIT-boosted-861870.html">3</a></sup> continuously make that point not even legitimate, but clearly you can make applications load slowly.  With that in mind, I have the ability to write a C app that loads slow also.</p>
<p>This post more than anything is to encourage breaking the mold of the group think, <em>&#8220;None of us is as dumb as all of us&#8221;</em> mentality.  No matter how many points you get on reddit for a snarky comment, those points won&#8217;t pay your bills, nor give you respect among legitimate coders.</p>
<ol class="footnotes"><li id="footnote_0_716" class="footnote"><a href="http://www.electronista.com/articles/10/05/26/admob.april.2010.study.has.android.near.even/">http://www.electronista.com/articles/10/05/26/admob.april.2010.study.has.android.near.even/</a></li><li id="footnote_1_716" class="footnote"><a href="http://www.forrester.com/rb/Research/of_strategic_languages%2C_javas_adoption_is_highest/q/id/37356/t/2">http://www.forrester.com/rb/Research/of_strategic_languages%2C_javas_adoption_is_highest/q/id/37356/t/2</a></li><li id="footnote_2_716" class="footnote"><a href="http://www.h-online.com/open/news/item/Android-s-Dalvik-to-be-JIT-boosted-861870.html">http://www.h-online.com/open/news/item/Android-s-Dalvik-to-be-JIT-boosted-861870.html</a></li></ol>

<p>Related posts:<ol><li><a href='http://www.sharms.org/blog/2008/12/64-bit-java-browser-plugin/' rel='bookmark' title='Permanent Link: 64-bit Java browser plugin'>64-bit Java browser plugin</a></li>
<li><a href='http://www.sharms.org/blog/2009/12/installing-play-framework-on-openbsd-4-6/' rel='bookmark' title='Permanent Link: Installing Play Framework on OpenBSD 4.6'>Installing Play Framework on OpenBSD 4.6</a></li>
<li><a href='http://www.sharms.org/blog/2006/12/run-your-java-apps-under-aiglx/' rel='bookmark' title='Permanent Link: Run your java apps under Aiglx'>Run your java apps under Aiglx</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.sharms.org/blog/2010/05/java/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Pygoocanvas, pygtk etc</title>
		<link>http://www.sharms.org/blog/2010/03/pygoocanvas-pygtk-etc/</link>
		<comments>http://www.sharms.org/blog/2010/03/pygoocanvas-pygtk-etc/#comments</comments>
		<pubDate>Wed, 31 Mar 2010 17:50:56 +0000</pubDate>
		<dc:creator>Steven Harms</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.sharms.org/blog/?p=702</guid>
		<description><![CDATA[I was reading a post about PyGoocanvas, and decided to take a look at some code and see what fun could be had. I haven&#8217;t done much yet, but this screenshot of it is pretty entertaining in it&#8217;s own right: Related posts:Writing a blog post people will actually read


Related posts:<ol><li><a href='http://www.sharms.org/blog/2006/12/writing-a-blog-post-people-will-actually-read/' rel='bookmark' title='Permanent Link: Writing a blog post people will actually read'>Writing a blog post people will actually read</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I was reading a<a href="http://www.themacaque.com/?p=482"> post about PyGoocanvas</a>, and decided to take a look at some code and see what fun could be had.  I haven&#8217;t done much yet, but this screenshot of it is pretty entertaining in it&#8217;s own right:</p>
<p><a href="http://www.sharms.org/blog/wp-content/uploads/garth.jpg"><img src="http://www.sharms.org/blog/wp-content/uploads/garth-208x300.jpg" alt="" title="garth" width="208" height="300" class="aligncenter size-medium wp-image-703" /></a></p>


<p>Related posts:<ol><li><a href='http://www.sharms.org/blog/2006/12/writing-a-blog-post-people-will-actually-read/' rel='bookmark' title='Permanent Link: Writing a blog post people will actually read'>Writing a blog post people will actually read</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.sharms.org/blog/2010/03/pygoocanvas-pygtk-etc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A thousand passwords</title>
		<link>http://www.sharms.org/blog/2009/12/a-thousand-passwords/</link>
		<comments>http://www.sharms.org/blog/2009/12/a-thousand-passwords/#comments</comments>
		<pubDate>Thu, 31 Dec 2009 20:22:22 +0000</pubDate>
		<dc:creator>sharms</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[passwords]]></category>
		<category><![CDATA[revelation]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.sharms.org/blog/?p=668</guid>
		<description><![CDATA[In this day and age of the internet, we have more content and interaction than ever before. This access generally comes with a price: everything requires a username and password. How does a mere mortal remember their credentials to login to thousands of websites? More importantly, I am not always on the same computer, how [...]


Related posts:<ol><li><a href='http://www.sharms.org/blog/2011/08/using-keepassx-on-ubuntu-linux/' rel='bookmark' title='Permanent Link: Using KeepassX on Ubuntu Linux'>Using KeepassX on Ubuntu Linux</a></li>
<li><a href='http://www.sharms.org/blog/2009/04/dropbox-on-ubuntu/' rel='bookmark' title='Permanent Link: Dropbox on Ubuntu'>Dropbox on Ubuntu</a></li>
<li><a href='http://www.sharms.org/blog/2011/01/automatically-backup-blogs-websites-to-amazon-s3/' rel='bookmark' title='Permanent Link: Automatically Backup Blogs / Websites to Amazon S3'>Automatically Backup Blogs / Websites to Amazon S3</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>In this day and age of the internet, we have more content and interaction than ever before.  This access generally comes with a price:  everything requires a username and password.  How does a mere mortal remember their credentials to login to thousands of websites?  More importantly, I am not always on the same computer, how do I access my passwords from all of them?</p>
<p>The long term solution would be to see 100% adoption of OpenID.  Inevitably many sites will always be behind the curve, so until that day comes, I recommend <strong>Revelation</strong>.</p>
<p>Revelation is an easy to use, secure and lightweight password manager for Linux.  It is written in GTK so those running the GNOME desktop (the default for Ubuntu) will be right at home.  You can have several different folders to help organize your passwords, and define actions based on the type of password being stored.</p>
<p>A picture is worth a thousand words, so here is a screenshot of Revelation in action:<br />
<a href="http://www.sharms.org/blog/wp-content/uploads/revelation.jpg"><img src="http://www.sharms.org/blog/wp-content/uploads/revelation.jpg" alt="revelation" title="revelation" width="585" height="401" class="size-full wp-image-670" /></a></p>
<p>What makes this great is that all of your passwords are stored encrypted.  This means if someone takes your computer, without your master password your passwords would be useless.  This also means we can store our password using Ubuntu One or Dropbox.</p>
<p>If you are curious about Dropbox I wrote a post with screenshots <a href="http://www.sharms.org/blog/2009/04/16/dropbox-on-ubuntu/">showing exactly how it works</a>.  Simply save your Revelation password file there, and all of your systems that have Dropbox will now have access to those passwords (once you unlock it for that session of course).</p>
<p>Under the preferences window in Revelation you can also adjust your default password size (when you use Revelation you simply randomly generate a new password for each website) for as long as you need, with the longer the better.</p>
<p>If you are running Ubuntu, you can install Revelation by clicking <em>Applications -> Ubuntu Software Center</em> and searching for Revelation.  If you would prefer the command line version:</p>
<pre class="brush: bash">
# sudo apt-get install revelation
</pre>
<p>There are many alternatives out there, but if you are running Linux and just need a simple, no-hassle password manager Revelation is worth five minutes to try it out.</p>


<p>Related posts:<ol><li><a href='http://www.sharms.org/blog/2011/08/using-keepassx-on-ubuntu-linux/' rel='bookmark' title='Permanent Link: Using KeepassX on Ubuntu Linux'>Using KeepassX on Ubuntu Linux</a></li>
<li><a href='http://www.sharms.org/blog/2009/04/dropbox-on-ubuntu/' rel='bookmark' title='Permanent Link: Dropbox on Ubuntu'>Dropbox on Ubuntu</a></li>
<li><a href='http://www.sharms.org/blog/2011/01/automatically-backup-blogs-websites-to-amazon-s3/' rel='bookmark' title='Permanent Link: Automatically Backup Blogs / Websites to Amazon S3'>Automatically Backup Blogs / Websites to Amazon S3</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.sharms.org/blog/2009/12/a-thousand-passwords/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Installing Play Framework on OpenBSD 4.6</title>
		<link>http://www.sharms.org/blog/2009/12/installing-play-framework-on-openbsd-4-6/</link>
		<comments>http://www.sharms.org/blog/2009/12/installing-play-framework-on-openbsd-4-6/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 18:16:49 +0000</pubDate>
		<dc:creator>sharms</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[openbsd]]></category>
		<category><![CDATA[play-framework]]></category>

		<guid isPermaLink="false">http://www.sharms.org/blog/?p=658</guid>
		<description><![CDATA[OpenBSD OpenBSD is a free, reliable and secure operating system. From a configuration standpoint it is both minimal and simple, which is great for those who want to get started quickly. For the purposes of this tutorial, it is assumed the user has already installed OpenBSD. If not, check out openbsd101.com for guides on installation [...]


Related posts:<ol><li><a href='http://www.sharms.org/blog/2008/12/64-bit-java-browser-plugin/' rel='bookmark' title='Permanent Link: 64-bit Java browser plugin'>64-bit Java browser plugin</a></li>
<li><a href='http://www.sharms.org/blog/2009/06/installing-groupwise-8-client-in-ubuntu-jaunty-amd64/' rel='bookmark' title='Permanent Link: Installing Groupwise 8 Client in Ubuntu Jaunty AMD64'>Installing Groupwise 8 Client in Ubuntu Jaunty AMD64</a></li>
<li><a href='http://www.sharms.org/blog/2007/03/making-openbsd-more-friendly/' rel='bookmark' title='Permanent Link: Making OpenBSD more friendly'>Making OpenBSD more friendly</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><strong>OpenBSD</strong><br />
<a href="http://www.openbsd.org">OpenBSD</a> is a free, reliable and secure operating system.  From a configuration standpoint it is both minimal and simple, which is great for those who want to get started quickly.  For the purposes of this tutorial, it is assumed the user has already installed OpenBSD.  If not, check out <a href="http://www.openbsd101.com/">openbsd101.com</a> for guides on installation etc.</p>
<p><strong>Play Framework</strong><br />
<a href="http://www.playframework.org">The Play Framework</a> is a java based web programming system, that includes the enterprise features of java with the methodology of Ruby on Rails or Django.  You can view an <a href="http://www.playframework.org/">introductory screencast</a> at their website which shows just how easy and powerful it is.</p>
<p><strong>Allow your user to sudo</strong><br />
Since this blog is aggregated on many Ubuntu sites, we will use the sudo facility to run commands instead of root.  To enable sudo the same way Ubuntu does:</p>
<ol>
<li>su &#8211; # Get root</li>
<li>visudo</li>
<li>Uncomment the line &#8220;%wheel  ALL=(ALL) SETENV: ALL&#8221;</li>
</ol>
<p><strong>Install packages</strong><br />
For the play framework the launch scripts are in python.  Zsh is installed for a better shell, and vim is installed for a full featured editor.</p>
<pre class="brush: bash">
export PKG_PATH=ftp://ftp.openbsd.org/pub/OpenBSD/4.6/packages/i386/
sudo pkg_add zsh jre-1.7.0.00b59p0 wget python-2.6.2p0 vim-7.2.190p1-no_x11 unzip
sudo ln -sf /usr/local/bin/python2.6 /usr/bin/python
sudo ln -sf /usr/local/bin/python2.6-config /usr/bin/python-config
sudo ln -sf /usr/local/bin/pydoc2.6  /usr/bin/pydoc
</pre>
<p><strong>Install Play Framework</strong></p>
<pre class="brush: bash">
cd /usr/local
sudo wget http://download.playframework.org/releases/play-1.0.zip
sudo unzip play-1.0.zip
</pre>
<p><strong>Start your project</strong></p>
<pre class="brush: bash">
cd /var
sudo /usr/local/play-1.0/play new ourappname
sudo chown -R ourusername ourappname
cd ourappname
# Set java home -- you can set this permanently in /etc/login.conf or in a startup script
export JAVA_HOME=&quot;/usr/local/jre-1.7.0/&quot;
/usr/local/play-1.0/play run
</pre>
<p><strong>Done</strong><br />
Your test app is now listening on port 9000 of the systems IP.  That is all there is to it.  Make sure to check out the excellent documentation available for the Play Framework.</p>
<p><a href="http://www.sharms.org/blog/wp-content/uploads/play.jpg"><img src="http://www.sharms.org/blog/wp-content/uploads/play.jpg" alt="play" title="play" width="650" height="519" class="alignleft size-full wp-image-663" /></a></p>


<p>Related posts:<ol><li><a href='http://www.sharms.org/blog/2008/12/64-bit-java-browser-plugin/' rel='bookmark' title='Permanent Link: 64-bit Java browser plugin'>64-bit Java browser plugin</a></li>
<li><a href='http://www.sharms.org/blog/2009/06/installing-groupwise-8-client-in-ubuntu-jaunty-amd64/' rel='bookmark' title='Permanent Link: Installing Groupwise 8 Client in Ubuntu Jaunty AMD64'>Installing Groupwise 8 Client in Ubuntu Jaunty AMD64</a></li>
<li><a href='http://www.sharms.org/blog/2007/03/making-openbsd-more-friendly/' rel='bookmark' title='Permanent Link: Making OpenBSD more friendly'>Making OpenBSD more friendly</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.sharms.org/blog/2009/12/installing-play-framework-on-openbsd-4-6/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

