gmail snippets

A simple Jabber/XMPP bot that uses the Jabber:Simple library

Tagged jabber, xmpp, gmail, gtalk, bot  Languages ruby

First install Jabber::Simple:

$sudo gem install xmpp4r-simple -y

On OSX you might get this error when installing xmpp4r-simple and the rdoc dependency:

gcc -I. -I/usr/local/lib/ruby/1.8/i686-darwin8.10.3 -I/usr/local/lib/ruby/1.8/i686-darwin8.10.3 -I.  -fno-common -g -O2  -fno-common -pipe -fno-common  -c callsite.c
gcc -I. -I/usr/local/lib/ruby/1.8/i686-darwin8.10.3 -I/usr/local/lib/ruby/1.8/i686-darwin8.10.3 -I.  -fno-common -g -O2  -fno-common -pipe -fno-common  -c rcovrt.c
cc -dynamic -bundle -undefined suppress -flat_namespace  -L"/usr/local/lib" -o rcovrt.bundle callsite.o rcovrt.o  -lruby  -lpthread -ldl -lobjc  
/usr/bin/ld: /usr/lib/gcc/i686-apple-darwin8/4.0.1/../../../libpthread.dylib unknown flags (type) of section 6 (__TEXT,__dof_plockstat) in load command 0
/usr/bin/ld: /usr/lib/gcc/i686-apple-darwin8/4.0.1/../../../libdl.dylib unknown flags (type) of section 6 (__TEXT,__dof_plockstat) in load command 0
/usr/bin/ld: /usr/lib/gcc/i686-apple-darwin8/4.0.1/../../../libobjc.dylib load command 9 unknown cmd field
/usr/bin/ld: /usr/lib/gcc/i686-apple-darwin8/4.0.1/../../../libSystem.dylib unknown flags (type) of section 6 (__TEXT,__dof_plockstat) in load command 0
/usr/bin/ld: /usr/lib/libSystem.B.dylib unknown flags (type) of section 6 (__TEXT,__dof_plockstat) in load command 0
collect2: ld returned 1 exit status
make: *** [rcovrt.bundle] Error 1

Simply install XCode 3 to make the error go away, then run this code to start the bot--warning the bot will execute the message body, for example "ls -la", on the system:

require 'rubygems'
require 'xmpp4r-simple'

include Jabber
#Jabber::debug = true

jid = '[email protected]'
pass = 'password'

jabber =, pass)

loop do
  messages = jabber.received_messages
  messages.each do |message| 
    body = message.body if message.type == :chat
    process = IO.popen(body)
    result = process.readlines
    jabber.deliver('[email protected]', result)
  sleep 1

To use GTalk from another domain than gmail, you need to edit the Jabber::Simple source code...

Trusted and sensitive email protection with GPG using Gmail with Firefox

Tagged firefox, gmail, gpg, trusted emails, sensitive emails, firegpg  Languages bash

It's really simple to use GPG to encrypt and/or sign email you send through Gmail.

Generate your private key.

gpg --gen-key

Extract your public key, which you will send to people you need to communicate securely with.

gpg --armor --export [email protected] > my_public_pgp_key

Install FireGPG and restart the browser. Use GPG in Gmail.

Gmail checker plugin for wmii.

Tagged wmii, gmail, google mail, email checker  Languages ruby

I take no credit for this. The original URL is The reason it is here is that I don't want to lose it just in case the original site is taken down.

# gmail check plug in
# by Derek Young
# periodically read gmail's atom feed for new messages.
# if one is found, display the username and subject of
# the message.
# The applet wakes up after a configurable period to check (by default
# 3 minutes).  You can also cause it to check immediately by pressing
# the key binding for the gmail-check binding (MODKEY-g by default).
# place this file in ~/.wmii-3/plugins and
# add the following to your wmiirc-config.rb file to enable:
#  plugin_config["[email protected]:gmail"]["username"] = 'my user name'
#  plugin_config["[email protected]:gmail"]["password"] = 'my password'
#  plugin_config["[email protected]:gmail"]["interval"] = 3
#  use_bar_applet "[email protected]:gmail", 50
#  use_binding "[email protected]:gmail-check"
# atom parsing based on code from Evan Martin
# Copyright Derek Young, 2007
# Use as you wish but please give credit.

Plugin.define "[email protected]" do
  author '"Derek Young" <[email protected]>'

  def_settings "gmail/interval" do |wmii|
    wmii.plugin_config["[email protected]:gmail"]["interval"] = 3 * 60

  CERTPATH = '/etc/ssl/certs'

  # return title, email, author name of first new message
  def gmail_check(username, password)
    req = '/mail/feed/atom'
    req.basic_auth(username, password)

    http ='', 443)
    http.use_ssl = true
    http.verify_mode = OpenSSL::SSL::VERIFY_PEER
    http.ca_path = CERTPATH

    res = http.request req

    doc = res.body
    entries = doc.root.get_elements('/feed/entry')
    return nil if entries.length == 0
    title = entries[0].elements['title'].text
    email = entries[0].elements['author/email'].text
    name = entries[0].elements['author/name'].text
    [ title, email, name ]

  bar_applet("gmail", 100) do |wmii, bar|
    require 'net/https'
    require 'rexml/document'

    interval = wmii.plugin_config["[email protected]:gmail"]["interval"]
    username = wmii.plugin_config["[email protected]:gmail"]["username"]
    password = wmii.plugin_config["[email protected]:gmail"]["password"]

    @gmail_check_thread = do
      loop do = "checking..."
        first = gmail_check(username, password)
        if first
          title, email, name = first
          user, domain = email.split('@')
 = "#{user}:#{title}"
 = 'no mail'
        sleep (interval * 60)

  binding("gmail-check", "MODKEY-g") do |wmii,| "gmail check requested" if @gmail_check_thread