• Home

  • Custom Ecommerce
  • Application Development
  • Database Consulting
  • Cloud Hosting
  • Systems Integration
  • Legacy Business Systems
  • Security & Compliance
  • GIS

  • Expertise

  • About Us
  • Our Team
  • Clients
  • Blog
  • Careers

  • VisionPort

  • Contact
  • Rejecting SSLv2 politely or brusquely

    Jon Jensen

    By Jon Jensen
    September 2, 2009

    Once upon a time there were still people using browsers that only supported SSLv2. It’s been a long time since those browsers were current, but when running an ecommerce site you typically want to support as many users as you possibly can, so you support old stuff much longer than most people still need it.

    At least 4 years ago, people began to discuss disabling SSLv2 entirely due to fundamental security flaws. See the Debian and GnuTLS discussions, and this blog post about PCI’s stance on SSLv2, for example.

    To politely alert people using those older browsers, yet still refusing to transport confidential information over the insecure SSLv2 and with ciphers weaker than 128 bits, we used an Apache configuration such as this:

    # Require SSLv3 or TLSv1 with at least 128-bit cipher
    <Directory "/">
        SSLRequireSSL
        # Make an exception for the error document itself
        SSLRequire (%{SSL_PROTOCOL} != "SSLv2" and %{SSL_CIPHER_USEKEYSIZE} >= 128) or %{REQUEST_URI} =~ m:^/errors/:
        ErrorDocument 403 /errors/403-weak-ssl.html
    </Directory>

    That accepts their SSLv2 connection, but displays an error page explaining the problem and suggesting some links to …


    browsers ecommerce hosting security tls

    JavaScript fun with IE 8

    Max Cohan

    By Max Cohan
    September 1, 2009

    I ran into, and found solutions for, two major gotchas targeting IE 8 with a jQuery-based (and rather JavaScript-heavy) web application.

    First is to specify the ‘IE 8 Standard’ rendering mode by adding the following meta tag:

    The default rendering mode is rather glitchy and tends to produce all sorts of garbage from ‘clean’ HTML and JavaScript. The result renders slightly different sizes, reports incorrect values from common jQuery calls, etc.

    The default rendering also caused various layout issues (CSS handling looked more like IE 6 than IE 7). Also, minor errors (an extra ’’ tag on one panel) caused the entire panel to not render.

    Another issue is the browser is overly lazy about invalidating the cache for AJAX pulled content, especially (X)HTML. This means that though you think you’re pulling current data, in reality it keeps feeding you the same old data. This also means that if you use the same exact URL for HTML & JSON data, you must add a parameter to avoid running into cache collisions. IE 8 only seemed to honor ‘Cache-control: no-cache’ in the header to cause it to behave properly.

    On the other side, I’ve got a big thumbs up for jQuery. I was able to …


    browsers javascript

    File test comparison table for shell, Perl, Ruby, and Python

    Jon Jensen

    By Jon Jensen
    August 31, 2009

    A few days ago, my co-worker Richard asked how in Python you would do the -x Bourne shell and Perl file test that checks whether a file is executable. This is (for me, at least) a really commonly used function but one I hadn’t needed to do yet in Python, so I looked it up.

    That wasn’t so hard to find, but then I wondered about the other shell and Perl file tests that I use all the time. Finding equivalents for those was harder than I expected. A web search didn’t turn much up aside from language holy wars and limited answers, but I didn’t find any exhaustive list.

    So I made my own. Below is a table comparing file test operators in the original Bourne shell-compatibles bash, ksh, and zsh; Perl’s expanded set; Ruby’s which was derived first from Perl; and equivalent Python code.

    There are still some blanks where I didn’t find a good equivalent. Of course I’m sure it’s possible with enough custom logic to achieve the same end, but I have tried to stick with relatively simple formulations using built-in functions for now. I’ll be happy to fill in the blanks if any readers make suggestions.

    Performance notes on avoiding multiple stats of the same file:

    • Starting with Perl 5.9.1, file …


    shell perl python ruby

    Interchange news

    Jon Jensen

    By Jon Jensen
    August 24, 2009

    Tomorrow we’ll be having an Interchange community meeting on IRC. All Interchange users and any other interested parties are invited to participate.

    Also, just recently, End Point’s own David Christensen joined the Interchange Development Group and became a core committer. Congratulations, David, and keep up the good work!


    community interchange

    Perl’s Scalar::Util::dualvar

    Jon Jensen

    By Jon Jensen
    August 24, 2009

    I just came across this fun Perl function that I can’t think of a (good) use for, but have to share.

    In the Scalar::Util module is the function dualvar:

    dualvar NUM, STRING

    Returns a scalar that has the value NUM in a numeric context and the value STRING in a string context.

        $foo = dualvar 10, "Hello";
        $num = $foo + 2;                    # 12
        $str = $foo . " world";             # Hello world

    Using that in the right place could lead a future programmer down some fun debugging paths!


    perl

    Defining variables for rpmbuild

    Jon Jensen

    By Jon Jensen
    August 20, 2009

    RPM spec files offer a way to define and test build variables with a directive like this:

    %define <variable> <value>

    Sometimes it’s useful to override such variables temporarily for a single build, without modifying the spec file, which would make the changed variable appear in the output source RPM. For some reason, how to do this has been hard for me to find in the docs and hard for me to remember, despite its simplicity.

    Here’s how. For example, to override the standard _prefix variable with value /usr/local:

    rpmbuild -ba SPECS/$package.spec --define '_prefix /usr/local'

    hosting redhat

    Text sequences

    Greg Sabino Mullane

    By Greg Sabino Mullane
    August 20, 2009

    Somebody recently asked on the Postgres mailing list about “Generating random unique alphanumeric IDs”. While there were some interesting solutions given, from a simple Pl/pgsql function to using mathematical transformations, I’d like to lay out a simple and powerful solution using Pl/PerlU

    First, to paraphrase the original request, the poster needed a table to have a text column be its primary key, and to have a five-character alphanumeric string used as that key. Let’s knock out a quick function using Pl/PerlU that solves the generation part of the question:

    DROP FUNCTION IF EXISTS nextvalalpha(TEXT);
    CREATE FUNCTION nextvalalpha(TEXT)
    RETURNS TEXT
    LANGUAGE plperlu
    AS $_$
      use strict;
      my $numchars = 5;
      my @chars = split // => qw/abcdefghijkmnpqrstwxyzABCDEFGHJKLMNPQRSTWXYZ23456789/;
      my $value = join '' => @chars[map{rand @chars}(1..$numchars)];
      return $value;
    $_$;

    Pretty simple: it simply pulls a number of random characters from a string (with some commonly confused letters and number removed) and returns a string:

    greg=# SELECT nextvalalpha('foo');
     nextvalalpha
    --------------
     MChNf
    (1 row)
    
    greg=# SELECT nextvalalpha('foo'); …

    database perl postgres

    Two quick tips: egrep & SQL dumps, Vim and deleting things that don’t match

    Selena Deckelmann

    By Selena Deckelmann
    August 20, 2009

    Sometimes, I just don’t want to restore a full SQL dump. The restore might take too long, and maybe I just want a small subset of the records anyway.

    I was in exactly this situation the other day—​faced with a 10+ hour restore process, it was way faster to grep out the records and then push them into the production databases, than to restore five different versions.

    So! egrep and vim to the rescue!

    In my case, the SQL dump was full of COPY commands, and I had a username that was used as a partial-key on all the tables I was interested in. So:

    egrep “((^COPY)|username)” PostgresDump.sql > username.out

    I get a pretty nice result from this. But, there are some records I’m not so interested in that got mixed in, so I opened the output file in vim and turned line numbers on (:set numbers).

    The first thing that I do is insert the ‘.’ needed to tell Postgres that we’re at the end of a COPY statement.

    :2,$s/^COPY/\.^V^MCOPY/

    The ‘^V^M’ is a control sequence that results in a ‘^M’ (a newline character, essentially). And the ‘2’ starts the substitution command on the second line rather than the first COPY statement (which, in my case, was on the first line).

    Next, I want to …


    postgres tips
    Previous page • Page 199 of 223 • Next page