Monthly Archives: October 2008

Bummer!

In addition to my Halloween plans falling through, I just found out that independent hiking on the Inca Trail is prohibited!

Since June 2002 trekking independently on the Inca Trail has been prohibited. Regulations state that each trekker must be accompanied on the Inca Trail by a professionally qualified guide. (source)

Posted in Backpacking, Travel | Tagged | Leave a comment

Getting Squid (Internet Proxy) Working

Problem

After configuring Safari and Firefox to use my local network’s squid proxy, I got the following error whenever I tried to browse to a page:

ERROR

The requested URL could not be retrieved
While trying to retrieve the URL:  http://www.google.com/

The following error was encountered:
 * Access Denied. 
   Access control configuration prevents your request from
   being allowed at this time. Please contact your service
   provider if you feel this is incorrect.

Solution

The squid.conf file on my server wasn’t configured correctly. Actually, I had simply neglected to ever bother configuring it! By default, Squid rejects all requests.

I edited the Squid configuration file:

sudo vi /etc/squid/squid.conf

Changing from this:

# Example rule allowing access from your local networks. Adapt
# to list your (internal) IP networks from where browsing should
# be allowed
#acl our_networks src 192.168.1.0/24 192.168.2.0/24
#http_access allow our_networks

To this:

# Example rule allowing access from your local networks. Adapt
# to list your (internal) IP networks from where browsing should
# be allowed
acl our_networks src 192.168.1.0/24
http_access allow our_networks

Then restarted Squid:

sudo /etc/init.d/squid restart
Posted in Technology | Tagged , , , | Leave a comment

The Demise of CAPICOM

CAPICOM, a COM-based wrapper for the CryptoAPI library, is deprecated and on its way out. However, Microsoft has no time line for phasing it out, nor have they provided sufficient documentation of alternatives.

Many CAPICOM pages contain a confusing, bright-red header along the lines of:

[The SignedCode object is available for use in the operating systems listed in the Requirements section. Instead, use Platform Invocation Services (PInvoke) to call the Win32 API SignerSignEx, SignerTimeStampEx, and WinVerifyTrust functions to sign content with an Authenticode digital signature. For information about PInvoke, see Platform Invoke Tutorial. The .NET and CryptoAPI via P/Invoke: Part 1 and .NET and CryptoAPI via P/Invoke: Part 2 subsections of Extending .NET Cryptography with CAPICOM and P/Invoke may also be helpful.]

Note that this alarming paragraph seems to begin by simply telling you that this API is supported on the operating systems listed later. It does not state that the API will not be available on later OSes, but why place this here otherwise? The next sentence, beginning with, “Instead, …” seems to be contrasting with something, yet makes absolutely no sense in this context.

Finally, this paragraph instructs us to investigate SignerSignEx, and SignerTimeStampEx, which are supplied by the mssign32.dll, have no header file, and absolutely no example code. This is what I find most irksome, they document each and every function and structure, yet each page says, “there is no header file, so copy and paste the declaration given here.” Well, why not simply provide an mssign.h file on blogs.msdn, or similar? And why, oh why, is there not a single line of sample code?

Follow-up

I have provided a basic header file for mssign32.dll, here.

Posted in Authenticode, COM, Cryptography, Technology, Win32 | Tagged , , | Leave a comment

Unable to Connect to Localhost SQL Server Express Instance

Problem

Connecting programmatically or by using osql failed with the following, generic error:

error: 40 - Could not open a connection to SQL Server

My programmatic attempt looked like this:

string cs = "Data Source=localhost;" +
            "Trusted_Connection=true;" +
            "Initial Catalog=dbname;";
SqlConnection connection = new SqlConnection(cs);
connection.Open();

Other variants I tried for Data Source were (local), 127.0.0.1, and the fully-qualified name of my local server.

My osql attempt looked like this:

c:\>osql -E -S localhost

Solution

The solution, at least for the basic connection problem, turned out to be a missing instance name. The instance name can be found by looking in Programs | Microsoft SQL Server 2005 | Configuration Tools | SQL Server Configuration Manager, under SQL Server 2005 Services. In my case, the instance is named “SQLEXPRESS“, so I tacked this onto my connection strings for a (more) successful login.

Programmatic:

string cs = "Data Source=localhost\\sqlexpress;" +
            "Trusted_Connection=true;" +
            "Initial Catalog=dbname;";
SqlConnection connection = new SqlConnection(cs);
connection.Open();

osql:

c:\>osql -E -S localhost\sqlexpress
1> 

Authorization

Actually, the above code didn’t quite work. I still get an authorization error:

Cannot open database "dbname" requested by the login. The login failed.
Login failed for user 'DOMAIN\username'.

This was actually because I hadn’t yet created the database, nor a user! I followed this handy guide in order to create a database, a user, and grant the user access to the new database.

In the end, my connection code looks like this:

string cs = "Data Source=localhost\\sqlexpress;" +
            "Trusted_Connection=true" +
            "Initial Catalog=dbname;" +
            "user id=username;password=userpass;";
SqlConnection connection = new SqlConnection(cs);
connection.Open();
Posted in ASP.Net, Technology | Tagged , , , , | Leave a comment

GnuPG Plugin for vim Under Cygwin

GnuPG, GNU Privacy Guard, is a free system for encrypting files, emails, etc. The GnuPG plugin for vim provides automatic encryption and decryption of files within vim. If you attempt to edit a GnuPG-encrypted file with vim, it will prompt you for the password, and re-encrypt the file when you’re done editing.

Download the gnupg plugin for vim from here and copy it into your user directory directory under .vim/plugin. From the Cygwin bash prompt:

mkdir ~/.vim/plugin
copy gnupg.vim ~/.vim/plugin

Run vim, then use the :scriptnames command and verify that gnupg.vim appears in the list of sourced scripts:

  1: /cygdrive/c/Users/username/.vim/plugin/gnupg.vim
Posted in Cryptography, Technology, Win32 | Leave a comment

My Fantastic Contraptions

A collection of solutions for Fantastic Contraption:

My Solutions:

  • Tube – a minimal tube crawler.
  • U-Turn – a floppy, crawling chariot.
  • U-Turn (again)) – a simple cart which uses leverage to apply force on the ceiling.
  • Back and Forth – an awful contraption.
  • Back and Forth – a better version which uses many wheels for low friction, and no bridge.
  • Higher – a ridiculously simple stick-flicker.
  • Around the Bend – a tiny triangle that flops to change direction.

Solutions by Others Which I Like:

My Experiments:

Posted in Fun, Internet | Leave a comment

Neat Flash Games for Nerds

These three games present interesting logic puzzles:

  • Fantastic Contraption – build a machine to get an item into the target zone.
  • Light-bot – provide simple commands to make your robot traverse obstacles (publisher site with annoying, talking banner ads is here).
  • Chronotron – solve puzzles using a time machine.

    Fantastic Contraption

    Light-bot

    Chronotron

Posted in Fun, Internet | Tagged | Leave a comment