What I want from a wireless plan

Mon Jun 07 13:36:50 UTC 2010

Here's what I want from a wireless plan:

  1. Calling
  2. Texting
  3. Web Browsing / Maps

Ok, so to get any of this most of the services insist I commit to them for 1-2 years, and pay a bundle for all sorts of services I may or may not use. I don't want rollover, although that is better than just losing your minutes. What I want is the ability to move into different Tiers based on my usage. If I use 200 Megs one month, I get charged for the 200 Meg limit. If I decide to browse more the next month, I want to be bumped to the next plan. No outrageous fees for those extra minutes past my plan or extra data past my allotment.

IE 7 Input Change Bug

Fri May 14 16:39:18 UTC 2010

In IE7 under some conditions the onchange event won't fire for input fields. I recently wanted to run javascript using jQuery to extract the name of the file and print it on the screen. To fix this I ended up extracting the logic that changes the contents of a span on the page into a function, and then calling that function inside a setTimeout call to get around this problem. I've had to use setTimeout before on a similar issue with a race condition and I'm sure glad that call exists. It's solved two of my last two IE bugs. Of course, I only run this hack with IE by checking jQuery with

if (jQuery.browser.msie) { ... }
      

How I Rate Netflix Movies

Fri May 14 16:21:46 UTC 2010

Just a quick rundown on how I rate movies that I watch from Netflix.

  • 5 stars - I own the movie or have changed as a person by watching it (or want to change).
  • 4 stars - I will watch the movie again, but I don't think I need this in my library.
  • 3 stars - Watched - it might not have been horrible but it wasn't anything special.
  • 2 stars - horrible movie that was either offensive, stupid or a combination of those two.
  • 1 star - I'm no longer a friend with whomever recommended this movie to me. Sending hate-mail to the studio.

A small look into my rating system.

My Preferred Way to Stop SSH Dictionary Attacks

Tue May 11 23:03:27 UTC 2010

I did a google search and found aerospacesoftware.com that suggested using iptables to filter ssh traffic and to slow down repeat requests. The default is to let the first request through, and then wait 1 minute before accepting another request. It seems to work like a champ. I already do things like only allow public-key authentication and I have turned off root access as any sysadmin should. Below are the iptables commands I added to my /etc/rc.local file to be run at startup:

iptables -A INPUT -p tcp -m state --syn --state NEW --dport ssh \
      -m limit --limit 1/minute --limit-burst 1 -j ACCEPT
      
      iptables -A INPUT -p tcp -m state --syn --state NEW --dport ssh -j DROP
      

MarkLogic xdmp:to-json()

Thu Apr 29 17:17:26 UTC 2010

I do like that MarkLogic has a to-json function and that I don't need to download third-party code to make something like JSON work, especially in 2010, years after JSON has become a fairly well known standard.

One problem I ran into was that when a sequence is converted to JSON, a JSON array is returned.

('a', 'b', 'c', 'd')
      

becomes

['a', 'b', 'c', 'd']
      

The problem comes when only one value is returned in a sequence, such as ('a'). This now becomes the string 'a' as JSON instead of being a javascript array. I can understand why, but I wanted an array since the autocomplete jQuery UI plugin always uses a javascript array. So, in my code I now check for a sequence of one and concatenate '[' to the beginning and ']' to the end to give me a valid JSON array.

If I could have, I would have changed the autocomplete plugin to accept a string JSON parameter as well and then the MarkLogic code would have worked fine.

Uploading XML File to MarkLogic Server using IE

Thu Apr 29 10:30:47 UTC 2010

I ran into a problem uploading an XML file into Internet Explorer today. When uploading the file into MarkLogic Server using Firefox, the file content-type was "text/xml". I expected this from IE, but found that it was "application/octet-stream". I didn't know exactly what "octet-stream" meant at the time but I feel like I should have understood what that meant. It basically converted each character in the XML document into it's hexadecimal equivalent and then sent that converted string to the server.

So, how does one go about converting that back to the XML node that I need in MarkLogic?

First, cast the contents as xs:hexBinary. Then, create a binary node with those contents and finally, use xdmp:quote() to create a string and then finally xdmp:unquote() to convert this back to an xml node.

xdmp:unquote(xdmp:quote(binary { xs:hexBinary($content) } ) )
      

Done. Thanks to this post for helping me find the solution. I've tried to explain it as I understand it.

Adding Tidy to VIM

Thu Apr 08 08:16:18 UTC 2010

I currently am using MarkLogic and by association use XML heavily in my job. I often get an XML file that is all jumbled into one line - a really long line. I knew that html/xml tidy could format this better so I installed tidy and added this mapping to my .vimrc file:

map <leader>x :%!tidy -i -q -xml -raw<CR>
      

I have <leader> mapped as my comma character so in normal mode I just press ,x and my xml is now all tidied up.

XQuery Modification to NERD_commenter for VIM

Fri Mar 26 16:42:10 UTC 2010

I updated the NERD_commenter VIM plugin to have comments for XQuery files. There is a giant elseif statment that I added the following lines to:

 elseif a:filetype == "xquery"
          call s:MapDelimiters('(:', ':)')
      

Now I can use the NERD_commenter mappings to comment out lines more quickly.

Javascript - Crockford On JS Act III

Thu Mar 25 13:42:02 UTC 2010

Just some gleaned insights taken from Douglas Crockford's Act III presentation on Javascript. You'll likely want to watch the video to understand why these things are important.

  1. Declare all variables at the top of a function.
  2. Declare all functions before you call them.
  3. Treat arguments as read-only.
  4. this is available to an inner function through assigning the outer this to another variable.
  5. apply and call can specify what this refers to.
  6. function => this is global object or undefined, method => this is the object calling the method, constructor => this is the new object, apply/call => this is passed in as an argument.
  7. Promise making is queuing up calls to happen when something happens that is likely asynchronous.
  8. Don't make functions in a loop.
  9. Y Combinator - mind is now blown.

"[Closure] is one of the most important features in javascript."

"[Closure] is the thing that makes javascript one of the world's brilliant programming languages."

Y Combinator

function y(le) {
      return (function (f) {
      return f(f);
      }(function (f) {
          return le(function (x) {
              return f(f)(x);
          });
      }));
      }
      
      var factorial = y(function (fac) {
           return function (n) {
               return n <= 2 ? n : n * fac(n - 1);
           };
      });
      
      var number120 = factorial(5);
      

UTC

Tue Mar 16 12:27:26 UTC 2010

With my body fighting off an infection induced through losing an entire hour of my life (thanks to Daylight Saving Time), I've been contemplating giving that hour away forever. Yeah, I don't want the hour back - Universe, you can keep the hour. But here is what I want.

One Time Zone

I want to have one time for everyone on this planet we call Earth. Instead of getting up earlier all of a sudden, we could keep our rhythms going and have no sudden changes.

What this means for me

I guess it means when someone says they want a lunch meeting at "Noon" local time, I want a universal translator that will hear "Noon" UTC, and not local. For me that might be 1800 UTC. Regardless, it would be a translator to know when I needed to be somewhere and it would work for everyone. Everywhere. That's what I want. Now to create the iPhone app that does the translation for those who are slow at math or for me when I'm short an hour of sleep.