Thursday, February 7, 2013

Logging out of AppEngine App only

I wanted to create a logout URL in an Google AppEngine app, but unfortunately the documented method (users.create_logout_url()) logs you out of all Google services, not just the app.

Fortunately, I found this post which describes how to set cookies to log you out of the app.  Here is what I did in my app:


https://gist.github.com/anonymous/4733505 

Now, I can add a link to /logout, and the user will be logged out of the app.

Many thanks to the pts.blog!

Friday, January 25, 2013

Embed an Outlook email into Excel

I needed to embed an email from Outlook into an Excel worksheet.  The only way I could find to do this was to save the Outlook email as a ".msg" file, and in Excel, do an Insert->Object and choose the ".msg" file.  The icon looked odd though, and the embedded object didn't behave like I thought it should.

And then I discovered that Microsoft Word automatically puts Outlook emails into the proper format for an object.

My method for embedding emails from Outlook into Excel added another step, but the finished product is perfect.  The steps are:

  1. Find the message you want in Outlook, and open the Excel worksheet that you will be using.
  2. Open a blank document in Microsoft Word
  3. Drag the message from Outlook to Microsoft Word.  An email object will be created in the Word document.
  4. Then, drag (or copy) the message from Word to where you want it in the Excel sheet.

Tuesday, November 16, 2010

NAT Port forwarding in VirtualBox (Windows Host)

I normally like to use a Bridged connection when I use a virtual machine with VirtualBox, but sometimes I need to use NAT networking. Using NAT makes it a bit harder to interact with the virtual machine if the virtual machine is running any servers (like an OpenSSH server, and HTTP server, etc).

I recently created an Ubuntu server with NAT networking (under a Windows host) and wanted to connect to the server with Putty. The setup is a little tricky, but the VirtualBox manual was a huge help.

In this example, I am going to map port 2222 on the host system to port 22 (the standard port for SSH) on the guest system.
  1. On the host system (Windows) open a command prompt
    • (Start Menu, "Run", enter cmd in the box and hit "OK")
  2. Browse to the location of the VirtualBox executable
    • For example: cd "C:\Program Files\Oracle\VirtualBox"
  3. Enter the following command:
    • VBoxManage.exe modifyvm "My VM name" --natpf1 "guestssh,tcp,,2222,,22"
    • (Make sure to change "My VM name" to the actual name of your VM that you are modifying
  4. If the virtual machine is running, shut it down.
  5. Shut down the VirtualBox gui if it is running
  6. Start your virtual machine
  7. Open putty, and connect to localhost at port 2222 (this will get forwarded to port 22 on the guest)
  8. You should be in business!

EDIT: I forgot to mention how to verify that your settings were successful:

In the same command window, enter the following command:
VBoxManage.exe showvminfo "My VM name" | grep NIC

The output should look something like this:
NIC 1: MAC: 0800274DB294, Attachment: NAT, Cable connected: on, Trace: off (file: none), Type: 82540EM, Reported speed: 0 Mbps, Boot priority: 0
NIC 1 Settings: MTU: 0, Socket( send: 64, receive: 64), TCP Window( send:64, receive: 64)
NIC 1 Rule(0): name = guestssh, protocol = tcp, host ip = , host port = 2222, guest ip = , guest port = 22
NIC 2: disabled
NIC 3: disabled
NIC 4: disabled
NIC 5: disabled
NIC 6: disabled
NIC 7: disabled
NIC 8: disabled

(Note the rule that was added is highlighted)

Tuesday, November 9, 2010

Quickly find shipping information in Gmail

My wife uses a Hotmail account for her email, and the other day I noticed a "Quick Views" section in her Hotmail.  One of the Quick Views is titled "Shipping Updates". 

Clicking this link filtered out all of her emails that had to do with shipping information.  Pretty handy!

Since I am a Gmail user, I figured the same thing would be possible in my favorite email service as well, so I tried to figure out how to make this happen in Gmail.  It's really not too difficult, and a lot of people probably already know how to do this.

Basically, I used a custom search to find shipping related emails in my Gmail account.  In order to save that search, I used the Gmail Labs feature, "Quick Links".  Here is what I did:

In Gmail, click on your "Settings" link in the upper right corner:


Next, click on the "Labs" tab in your settings.  (Note:  If you don't see the "Labs" tab in your settings, your browser may not be compatible with Gmail labs - see this Google help page for more information).


Now, scroll down to the "Quick Links" labs feature, and click the "Enable" option:


Scroll up or down to the "Save Changes" button, and click it:


Now, go back to your Gmail inbox, and enter a search phrase to find emails with shipping information, and click the "Search Mail" button.  Here is the search string I used:

"tracking number" OR "ship to" OR "has shipped" OR "shipment confirmation"

And here is what it looked like after I clicked the "Search Mail" button:


Now, to save this search to your quick links, click the "Add Quick Link" link on the left pane of your Gmail:


Enter a custom name for you saved search and click "OK" (I picked "ShippingInfo"):


Now, anytime you want to get a list of emails that have to do with shipping information, just click the "ShippingInfo" link under your "Quick Links"!














Tuesday, July 6, 2010

Sorting an Array of Hashes in Perl

I needed to sort an array of hashes in Perl (actually, it was an arrayref of hashrefs).  A quick Google search led me to this page:
http://www.storm-consultancy.com/blog/development/code-snippets/perl-sorting-an-array-of-hashes/

With a little modification of the example, I had something that worked perfectly:

my @{ $sorted } = sort { $b->{key_field} <=> $a->{key_field} } @{ $data };

Thursday, March 18, 2010

Commit counts on db2 imports

I couldn't remember how to import into a db2 table with a specific commit count.  A quick google search found this page:

The Music of Time: DB2 Import Commands Failing With "transaction log for db is full" Errors
db2 "import from [your_csv_file_name] of del commitcount 1000 insert into [table_name]([column A], [column B], [column C], ...)"


Saturday, October 31, 2009

jQuery - Custom Events

As mentioned in a recent post, I mentioned that I have really been enjoying the book, "jQuery Enlightenment".  Another thing I learned while reading this book was how you can create a custom event on an element (standard events being events like click, mouseover, etc.).  Something seemed really cool about custom events - I'm not exactly sure how I would use them, but I know that I want to remember them, which is why I'm posting this.

If I had a span element, I could use a custom event to make it alert a message.  (True, I could just use a click event, but like I said, I'm sure down the road I will have a good use for this).

Here's how to assign the event with jQuery:

$('span').bind('myOwnEvent', function(){
    alert("My Own Event works!");
});


Then, to execute (or trigger) the custom event, use jQuery again:

$('span').click(function(){
    $(this).trigger('myOwnEvent');
});


What I am not clear on right now is that if this is possible with native JavaScript or not - I like to know the "JavaScript theory" behind the jQuery methods - I'll have to do some research on that.

I'll end this post like my last one:

I am learning so much from this book, "jQuery Enlightenment".  I thought I knew a bit about jQuery, but this book has helped me learn so much more.  I highly recommend you go to the site and buy it.  Thanks Cody!