Vim on Squeeze for Python

With some help from http://henry.precheur.org/vim/python, I came to the following .vimrc.  It may be better to use a filetype condition, but I’m only really doing python at the moment, so this is pretty good.

$ cat ~/.vimrc
syntax on
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
set autoindent
filetype plugin indent on

The first line turns on syntax highlighting.  I just don’t know what to do without it.  Tabstop tells vim that if it sees a tab, to make it appear as 4 spaces.  softtabstop means that if vim sees spaces in multiples of 4 (in this case) at Coinstar agent the start of the line, it will treat them as tabs, so that a single backspace will dedent 4 spaces.  Shiftwidth tells vim that when it is told to indent (by a script of visual mode), it will indent by 4 spaces.

Expandtab instructs vim to put spaces into files instead of using actual tab characters.  Autoindent makes vim preserve your indentation levels upon newlines.  This feature is one that you just can’t live without, especially when you are coding 3 or 4 indentation levels in.

Filetype plugin indent on tells vim to turn on the indentation plugins for different filetypes.  In my case, for my testing, it means that it will enable smartindent scripts that come with vim on Debian Squeeze.  If you are using some other distro, you may have to get the script manually.

 This was very nice because now it will automatically indent another level when it sees blocks like what end in :, and when it sees that parenthesis, brackets, or curly braces are not matched, triggering implied line continuation.  It’s awesome.

Posted in Uncategorized | Leave a comment

X-Mouse Button Control

I’m left-handed, and prefer my mice to be inverted in most cases, and that’s how I have it at work.  On my Mac with my Magic Mouse, I simply change which side is the secondary click.  Then all my programs work as I expect.

However, on my Windows machine, strangeness happens.  I go into the control panel and invert the primary and secondary mouse buttons for my Logitech mouse, and under most programs it works just fine.  However, when I use Hyper-V viewer or Remote Desktop Connection, it somehow decides that even though I wanted it on my local machine this way, its not really how I wanted it for the remote machine.

Today, this finally annoyed me enough to get me to search Google for a solution.  I found a blog post here that pointed me to a solution: X-Mouse Button Control.  While this beast is made to do way more sophisticated things, it has solved my problems, because Windows now doesn’t even see that my right-click is a right-click; it thinks it is a left-click.  That means that all of my programs already work how I expect them too, and Hyper-V and Remote Desktop do too!

Edit: Actually, there is a gotcha on this:  UAC comes before Moneygram point X-Mouse Button Control, so my mouse is backward whenever a UAC comes up.  After a while this got really annoying, and I ended up looking some more.  The final solution I found was obvious, and I didn’t find it till I was looking to do something else.

I have a Logitech keyboard and mouse, and my keyboard has some cool media access keys that I wanted to use, so I broke down and installed their software.  One lucky option was to invert the mouse keys.  This ends up being done early enough that UAC sees it, and everything else sees it too.

 So I’ve now removed X-Mouse Button Control, since it is of no use to me when the Logitech is able to do it through its own software.

Posted in Uncategorized | Leave a comment

mod_security Issues

mod_secur ity is a patch to make

it OK to run code that has holes in it.

 And it seems to me that it ends up causing more problems than it is worth.  But perhaps that is only to me.

When you add a post that has anything that it is worried may cause security problems.  The one that hit me first was the use of a particular full path.  The path I wished to use was [slash] etc [slash] hosts, as I was creating an Moneygram locations instructional that dealt with modifying that file.  However, it would not work.  After chasing down error after error I finally got it back to that, changed what I wrote, and it worked easily.

I write a typically technically-oriented blog, and I need to be able to post things like this.  And honestly, I expect that my readers may post technically-oriented answers that would suffer from this.  I may have to live with this for now, but it also may mean that I choose to move my blog to another hosting company because of this limitation.

Posted in Uncategorized | Leave a comment

Adding a Single-host OpenDNS Network Using SSH Port Forwarding

OpenDNS is capable of adding entire networks into their database, however, a lot of times it is better and simpler to build your own recursive DNS to simplify not only your own setup, but also to simplify registration of your IP addresses, as OpenDNS requires extra validation for any network that contains more than one IP address.  By adding a host (like your recursive DNS server), you save the hassle of having OpenDNS approve it, and additionally are able to include local-only DNS apart from OpenDNS.  However, if you are running a minimal UNIX/Linux operating system without a GUI (you should be for this type of server), you run into the problem of how to register this IP.

OpenDNS requires that you use the actual host you are registering when you register a single IP network.  This can be accomplished by using a CLI web browser like Lynx, but the OpenDNS site is definitely not created to facilitate doing it this way.  Instead, you can use another host to have the web browser, and just forward the ports through the recursive server using SSH.

Requirements:

  • SSH server on the recursive name server
  • SSH client on your GUI client
  • A web browser on the client

I assume that you are using some using a UNIX/Linux operating system as the client, although it is feasible that you could use Windows and PuTTY.  I am using OSX.

The process is remarkable simple.

1. Forward your local port 80 and 443 through an SSH tunnel to your remote server

  • This won’t require root access on the remote server, but it will require root (or sudo) access on the local (client) machine, since you will be binding to ports lower than 1024.
  • You cannot have any local web server running while you do this, because this will require the normal web server ports.
  • Assuming that your remote username is john, that your remote host is dns.john.example.com, and that you are using the default SSH port (22) for the server, use this command to connect up the port forwarding.  Note that it will still open up a shell for you, and that when you exit the shell, the port forwarding will stop.
    sudo ssh john@dns.john.example.com -L 80:www.opendns.com:80 -L 443:www.opendns.com:443

2. Point all opendns.com and www.opendns.com traffic to 127.0.0.1

Edit -etc-hosts, and add the following:

127.0.0.1 www.opendns.com
127.0.0.1 opendns.com

3. Open your web browser to opendns.com, and add the network.

  1. Browse to opendns.com in your browser.  When you get there, look at the top, and make sure that it is seeing the forwarded server’s IP address.
  2. Log In.
  3. Go to the Dashboard.
  4. Go to Settings.
  5. The IP address is probably already entered.  Ensure that it is correct, and add it.
  6. Log off.

4. Clean up.

  1. Close your SSH session.  This should stop the port forwarding as well.
  2. Revert your -etc-hosts file.

     Just remove the lines that we added in step 2.

That’s it.  You’ve successfully added that remote server to OpenDNS, and you were able to do it from a complete web browser rather than having to use Lynx.

P.S. For the record, I love Lynx.

 It’s just rather difficult to use with sites that use as much Javascript as the OpenDNS site.

Posted in Uncategorized | Leave a comment