Saturday, December 20, 2008

GMail + Thunderbird + GPG solution

After quite a hiatus (nothing exciting, techie, and cool has happened lately) I finally have something useful ( to contribute to the blag-o-hyper-sphere: my solution to establishing a reasonable personal GPG infrastructure even while using Gmail as my primary email. I've searched quite a bit on integrating Thunderbird with Gmail and never found anyone providing a walk-through to view specific Gmail labels in Thunderbird so here's mine:

Tools used: an exiting Gmail account, Thunderbird with working Enigmail (which requires gpg to be installed and working, and preferably an existing key, for help with any of that see the Enigmail site as a starting point).


The idea is to use a Gmail filter to siphon away all encrypted messages to a special label ("encrypted" works well) which is monitored by Thunderbird (setup to use Gmail as an IMAP server, not POP which is the Thunderbird default for Gmail accounts) where Enigmail does all the heavy lifting.


Setup Gmail


Create a new label in Gmail for encrypted messages... again, "encrypted" seems reasonable to me but any label will do.

Create a new filter to go with this label. The filter I chose only specifies the "Has the words" field and the magic words are "BEGIN PGP MESSAGE". The actions I specified are "Skip the Inbox (Archive it)", Star It, Apply the Label: encrypted, and Never send it to spam.


Setup Thunderbird


Create a new email Account in Thunderbird: Provide your "Real Name" and Gmail address. Specify IMAP as your protocol and imap.gmail.com as the IMAP server and finally provide your "Incoming User Name" (i.e. foo if your email address is foo@gmail.com), and give the new account a name in Thunderbird.


Now do some Thunderbird house-keeping: Right click on the newly created account and choose "Properties..."

  • Under Server Settings specify SSL in the Security Settings box.
  • Under "Copies & Folders" and the settings for Sent Mail make sure you select the "Other:" radio box and navigate to Gmail's existing Sent Mail folder or Thunderbird will create a new label in your Gmail account called "IMAP/sent". I do the same for drafts but cannot for Trash. If somone has a hack for making Thunderbird use Gmail's trash folder I'd be interested.
  • Lastly, under "OpenPGP Security" check the "Enable OpenPGP support (Enigmail) for this identity" box and choose your OpenPGP key id appropriately.
Now, right click on the account and select "Subscribe..." In my case I only use Thunderbird locally for encrypted mail so unselect all folders (Gmail's labels) except encrypted.

You're done!
Test by sending yourself an encrypted message (maybe from Thunderbird so you can verify the correctness of your Enigmail configuration) and you should be able to view the message within Thunderbird as well and see it encrypted in Gmail's web interface. Now encrypted mail can be read in Thunderbird and essentially ignored in Gmail. Clearly this doesn't help you read encrypted messages in the browser but that's risky to start with and compromises the entire intent of using GPG.

Happy encrypting!

Wednesday, September 17, 2008

Hacker Spaces and a process

An interesting read about CCC.de and how to build a hacker-space. The whole principal is that having a space and creative people can lead to really cool work. The slides address tons of issues succinctly which helped me to be positive. It could also be that Dino and NYCResistor make me super jealous...

Wednesday, July 23, 2008

"Algorithms for Programmers" (A work in progress) - by Jörg Arndt

This is something of a "book review" for Jörg Arndt's "Algorithms for Programmers" which I have not read straight through but continually dig through and find interesting gems.

There are clearly two types of algorithms already showing up in this collection: those with a systems / optimization bent and those with a mathematical bent. Since I appreciate both optimization and mathematics for the sake of mathematics, I find no problem with this but very often books on Algorithms emphasize the absolutely most boring end of the mathematics of algorithms: complexity analysis. One almost never finds interesting or cool problems solved with equally interesting data-structures or algorithms. Instead Quicksort is presented and we get a chance to show that something is of O(n-logn) complexity. Lame / Boring / *Snore*. To Quicksort's credit it is one of the more mathematically beautiful sorting algorithms but once you've seen it, you've seen it, and can move one.


Jörg's collection of algorithms "for programmers" has a very "systems" or "bit twiddling" feel to it and provides algorithms for many day-to-day real programming problems that come up. Little (if any) time is spent on complexity analysis, in particular proving that an algorithm lives in a given class. Instead good pseudo-code is provided, often several solutions to the same problem, with a bit of explanation as to why one would use a certain variant over the others presented. Even cooler is there are three full chapters on mathematical algorithms including Orthogonal Transforms, Fast Arithmetic, and Algorithms for Finite Fields!

Check it out and be sure to thank
Jörg.

Thursday, July 17, 2008

Cool Ruby One-Liner - Sierpinski Gasket

First found here referencing a twitter-updated Ruby golf entry, a nice snippet which generates the Sierpinski Gasket (or triangle) I was completely intrigued in the console. Like Giles from the first link I figured I should understand the mathematics used in generating the image but just didn't.

I "improved" the code to my liking since I like parameters for investigative purposes...

ruby -le 's=32; s.times{|y|print" "*(s-y-1),(0..y).map{|x|~y&x>0?" .":" A"}}'
I figured that the reason this code worked was based on a nice mathematical description of the underlying points. The example which hinted at this is to me is the Cantor Set. It has the beautiful definition as the set of points in the closed interval [0,1] such that the trinary expansion at any point contains no 1's (only 0's and 2's). The punchline is the Sierpinski Gasket has a similar description (documented here) and that's why the code works.

Math Nerd Editor's Note: The proof that the cantor-set is uncountable is based on the trivial mapping of the trinary expansions containing only 0's and 2's to the binary expansions containing 0's and 1's which describe all of the reals in [0,1] which itself is uncountable. How cool is that?

Wednesday, July 16, 2008

Cool Data-Structure: Interval Tree

Geometric Algorithms are pretty darned cool. I've found them interesting for a long time; in fact my new-found love affair with cool algorithms came from my interest in them. The book Data Structures for Computer Graphics, while lacking in certain descriptions, contains a load of fun structures. The first one I just had to implement in Ruby was the Interval Tree, which as a mathematician allowed me to play with the structure theorem for open intervals in the reals in a cool way. I may even post my implementation here later, but for now read the Wiki and see if this is cool for you too!

For a snippet of the book check out this file: Geometric Data Structures for Computer Graphics [PDF]. This is by the authors of the above book and contains much of the same content and even some pretty pictures.

Coming Soon: my implementation from early in my Ruby explorations.

Cool Data-Structure: Radix Tree

My interest in Radix trees came from reading Cisco's Inside Cisco IOS Software Architecture (a surprisingly interesting book) after getting a job as a network engineer. My interest was once again piqued by Thomas Ptacek's post on the Matasano Chargen Blog (which is always a good read). Thomas thinks that the Wikipedia entry on them "sucks" (and I kind of agree but certainly haven't stepped up to improve it) but it is also worth reading I think. So check out the Wiki and Thomas' post and note how cool Radix Trees (Tries) are.

Cool Algorithm: Boyer-Moore string searching algorithm

This algorithm is super cool in that instead of searching the text for a key it searches the key for the text and very very quickly. How sweet is that? More at the almighty Wiki.

Cool Data-Structure: Bloom Filter

Bloom Filters share a relationship with hash tables but are optimized for space over time. They don't store values but will tell you if things have not been hashed (and usually if they have... but not always). More at the almighty-Wiki as well as my original inspiration in looking into them in the first place.

Coming soon... my implementation (again for those paying attention) once I get my stylesheets working. I am programmer not a web-designer.

Cool Algorithms and Data-Structures in general

Like many CS students (before I dropped out and studied real mathematics) I was continually frustrated by the standard algorithm courses we are forced to sit through. First you do weeks of recurrence relations and basic algorithmic analysis followed by quicksort and some trees. Along the way there are tons of implementations of various data-structures and algorithms with stupid patronizing applications.

After having left CS, and even mathematics for the most part, I find myself discovering tons of cool algorithms and data-structures that are never mentioned in classes that I've seen. So I am starting a list of cool algorithms everyone should see once and appreciate, even if they never ever use them.

I will tag them all as "cool algorithms" even if they are data-structures that imply certain algorithms.

Friday, May 30, 2008

Displaying Gruff Graphs in RubyCocoa v2

After getting the last post to be as minimal as possible and popping a window using RubyCocoa I wanted something more complete...

There were lots of little goals here:
a) Add a real icon (I assumed this was drag-n-drop in IB or XCode, not so much, but it is simple) b) dynamically generate an interesting icon at run-time (this is actually really easy) c) generate "interesting random" graphs for gruff.

Solution a) Edit the
Info.plist and set the CFBundleIconFile entry to an appropriately created .icns file

Solution b) in some method (I chose awakeFromMib) simply fetch the currently running application thusly: @thisApp = OSX::NSApplication.sharedApplication and call the setApplicationIconImage method with and NSImage (BOOM!)

Solution c) trivial

I've done all of those things in the
attached code

Friday, May 16, 2008

Displaying Gruff Graphs in RubyCocoa

In the quest to do interesting things in RubyCocoa I decided I had display gruff graphs in native windows. Luckily it turns out this is very very easy, simply create a new Ruby-Cocoa project in XCode, add the following class to the project, instantiate it in InterfaceBuilder, connect it to an NSImageView called imageOutlet and Boom!

Done.

(Thanks to Jim Morris for his Ruby-HTMLization-fu)


#  GruffGraphController.rb
# GrufferGrapher
#
# Created by Dave on 5/16/08.
# Copyright (c) 2008. All rights reserved.
#

require 'osx/cocoa'
require 'rubygems'
require 'gruff'

class GruffGraphController < OSX::NSObject

 ib_outlet :imageOutlet

 def awakeFromNib
  g = Gruff::Pie.new
  g.data("ASN 1", 5)
  g.data("ASN 2", 3)

  b = g.to_blob

  d = OSX::NSData.alloc.initWithBytes_length(b, b.length)

  i = OSX::NSImage.alloc.initWithData(d)

  @imageOutlet.setImage(i)
 end
end
Powered By Blogger