<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: gmail code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sat, 17 May 2008 13:20:51 GMT</pubDate>
    <description>DZone Snippets: gmail code</description>
    <item>
      <title>Retrieve your Gmail messages as an XML feed</title>
      <link>http://snippets.dzone.com/posts/show/5097</link>
      <description>This Ruby example shows how to retrieve your most recent email as an atom XML feed from the Google Apps website.  &lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;require 'rubygems'&lt;br /&gt;require 'httpclient'&lt;br /&gt;&lt;br /&gt;url = "https://mail.google.com/a/yourwebsite.com/feed/atom"&lt;br /&gt;client = HTTPClient.new&lt;br /&gt;client.debug_dev = STDOUT if $DEBUG&lt;br /&gt;client.set_auth(url, 'yourname@yourwebsite.com', 'yourpassword')&lt;br /&gt;resp = client.get(url)&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Note: You might require to gem install httpclient.</description>
      <pubDate>Sun, 03 Feb 2008 16:29:06 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5097</guid>
      <author>jrobertson (James Robertson)</author>
    </item>
    <item>
      <title>Ruby retrieve gmail emails through POP3</title>
      <link>http://snippets.dzone.com/posts/show/4617</link>
      <description>Found at &lt;br /&gt;http://blog.seagul.co.uk/articles/2006/10/24/connecting-to-gmail-with-ruby-or-connecting-to-pop3-servers-over-ssl-with-ruby&lt;br /&gt;&lt;br /&gt;pop.rb is the new Ruby 1.9 version&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;require 'pop_ssl' # I renamed the file from pop.rb to pop_ssl.rb to ensure I was requiring the correct version&lt;br /&gt;&lt;br /&gt;username = 'YOUR_GMAIL_USERNAME@gmail.com'&lt;br /&gt;password = 'YOUR_GMAIL_PASSWORD'&lt;br /&gt;&lt;br /&gt;Net::POP3.enable_ssl(OpenSSL::SSL::VERIFY_NONE)&lt;br /&gt;Net::POP3.start('pop.gmail.com', 995, username, password) do |pop|&lt;br /&gt;  if pop.mails.empty?&lt;br /&gt;    puts 'No mail.'&lt;br /&gt;  else&lt;br /&gt;    pop.each_mail do |mail|&lt;br /&gt;      p mail.header&lt;br /&gt;    end&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 04 Oct 2007 17:30:33 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4617</guid>
      <author>tkofol (Tim Kofol)</author>
    </item>
    <item>
      <title>Gmail - Select All Spam</title>
      <link>http://snippets.dzone.com/posts/show/4374</link>
      <description>// Standard HTML GMail does not have a select all option on the Spam page(s). Paste this into firebug console to select all...&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;for (i = 0; i &lt; document.f.t.length; i++) {document.f.t[i].checked = true;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;or&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;for each(s in document.f.t){s.checked=true;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 31 Jul 2007 14:58:01 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4374</guid>
      <author>emartin24 (Eric Martin)</author>
    </item>
    <item>
      <title>Empty a Gmail label with FireWatir</title>
      <link>http://snippets.dzone.com/posts/show/3961</link>
      <description>When you have a huge label with thousands of messages, Gmail can't handle deleting all of them at a time (it says it can, but for me it's never worked). This solves the problem.&lt;br /&gt;&lt;br /&gt;I wrote it more as a practice to get familiar with FireWatir, so it's not very pretty or anything and it's a bit slow. If you have doubts on how to use or suggestions on how to improve it please feel free to contact me.&lt;br /&gt;&lt;br /&gt;By the way, it assumes Gmail is in German. Replace that string with the one that comes up for your language.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;def empty_label(label)&lt;br /&gt;  # you need a Firefox instance already running with JSSh installed and listening&lt;br /&gt;  ff = Firefox.new&lt;br /&gt;  # Goes to Gmail in HTML&lt;br /&gt;  ff.goto('http://mail.google.com/mail/h/x4odcwnm5f5v/?s=l&amp;l=#{label}')&lt;br /&gt;  a = []&lt;br /&gt;  # doing 'c.set' didn't work for me here so I had to do this hack of getting the value&lt;br /&gt;  # and then acquiring the element thorugh ff.checkbox(:value,value)&lt;br /&gt;  ff.checkboxes.each {|c| a &lt;&lt; c.value}&lt;br /&gt;&lt;br /&gt;  while a.length &gt; 0 do&lt;br /&gt;    c = []&lt;br /&gt;    a.each {|v| c &lt;&lt; ff.checkbox(:value,v)}&lt;br /&gt;    # checks all checkboxes&lt;br /&gt;    c.each {|e| e.set}&lt;br /&gt;    # clicks the drop-down entry for deleting&lt;br /&gt;    ff.select_list(:name,'tact').select('In den Papierkorb verschieben')&lt;br /&gt;    ff.button(:name,'nvp_tbu_go').click&lt;br /&gt;    a = []&lt;br /&gt;    ff.checkboxes.each {|c| a &lt;&lt; c.value}&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 07 May 2007 21:54:04 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3961</guid>
      <author>helder (Helder Ribeiro)</author>
    </item>
    <item>
      <title>Gmail-Like Incremental Search //JavaScript Class</title>
      <link>http://snippets.dzone.com/posts/show/684</link>
      <description>&lt;a href="http://www.jsfromhell.com/dhtml/incremental-search"&gt;&lt;br /&gt;Implements a GMail-like auto-complete.&lt;br /&gt;&lt;br /&gt;[UPDATED CODE AND HELP CAN BE FOUND HERE]&lt;br /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;@REQUIRES &lt;a href="http://www.jsfromhell.com/geral/event-listener"&gt;Event-Listener&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;//Requires http://www.jsfromhell.com/geral/event-listener&lt;br /&gt;&lt;br /&gt;//+ Jonas Raoni Soares Silva&lt;br /&gt;//@ http://jsfromhell.com/dhtml/incremental-search [v1.0]&lt;br /&gt;&lt;br /&gt;IncrementalSearch = function( input, callback, className ){&lt;br /&gt;	var i, o = ( o = this, o.l = [], o.i = input, o.c = null, o.s = { e: null, i: -1 }, o.f = callback || function(){}, o.n = className || "", o );&lt;br /&gt;	for( i in { keydown: 0, focus: 0, blur: 0, keyup: 0, keypress: 0 } )&lt;br /&gt;		addEventListener( o.i, i, function( e ){ o.handler.call( o, e ); } );&lt;br /&gt;};&lt;br /&gt;with( { p: IncrementalSearch.prototype } ){&lt;br /&gt;	(p.constructor.fadeAway = function( o ){&lt;br /&gt;		o instanceof Object ? ( this.trash = this.trash || [] ).push( o ) &amp;&amp; setTimeout( this.fadeAway, 200 ) : arguments.callee.c.trash.pop().hide();&lt;br /&gt;	}).c = p.constructor;&lt;br /&gt;	p.callEvent = function( e ){ this[e] &amp;&amp; this[e].apply( this, [].slice.call( arguments, 1 ) ); };&lt;br /&gt;	p.highlite = function( e ){ ( this.s.e &amp;&amp; ( this.s.e.className = "normal" ), ( this.s = { e: e, i: e.listindex } ).e.className += " highlited", this.callEvent( "onhighlite", this.l[ this.s.i ], this.s.e.d ) ); };&lt;br /&gt;	p.select = function(){ this.s.i + 1 &amp;&amp; ( this.i.value = this.l[ this.s.i ], this.callEvent( "onselect", this.i.value, this.s.e.d ), this.hide() ); };&lt;br /&gt;	p.hide = function(){ ( this.c &amp;&amp; this.c.parentNode.removeChild( this.c ), this.c = null, this.l = [], this.s = { e: null, i: -1 }, this.callEvent( "onhide" ) ); };&lt;br /&gt;	p.next = function(){ var e = ( e = this.s.e ) ? e.nextSibling || e.parentNode.firstChild : null; e &amp;&amp; this.highlite( e ); };&lt;br /&gt;	p.previous = function(){ var e = ( e = this.s.e ) ? e.previousSibling || e.parentNode.lastChild : null; e &amp;&amp; this.highlite( e ); };&lt;br /&gt;	p.handler = function( evt ){&lt;br /&gt;		var o = this, t = evt.type, k = evt.key, e = /span/i.test( ( e = evt.target ).tagName ) ? e.parentNode : e;&lt;br /&gt;		t == "keyup" ? k != 40 &amp;&amp; k != 38 &amp;&amp; k != 13 &amp;&amp; o.show()&lt;br /&gt;		: t == "keydown" ? ( k == 40 &amp;&amp; o.next() ) || ( k == 38 &amp;&amp; o.previous() )&lt;br /&gt;		: t == "keypress" ? k == 13 &amp;&amp; !evt.preventDefault() &amp;&amp; o.select()&lt;br /&gt;		: t == "blur" ? o.constructor.fadeAway( o )&lt;br /&gt;		: t == "click" ? o.select()&lt;br /&gt;		: t == "focus" ? o.show()&lt;br /&gt;		: o.highlite( e );&lt;br /&gt;	};&lt;br /&gt;	p.show = function(){&lt;br /&gt;		var cS, found = 0, o = this, i = o.i, iV = i.value, d = document, c = ( o.hide(), o.c = d.body.appendChild( d.createElement( "div" ) ) );&lt;br /&gt;		( c.className = o.n, cS = c.style, cS.display = "none", cS.position = "absolute", o.callEvent( "onshow" ) );&lt;br /&gt;		o.f.call( function( s, x, data ){&lt;br /&gt;			if( !( x.length == undefined ? ( x = [x] ) : x ).length )&lt;br /&gt;				return;&lt;br /&gt;			var j, l = 0, i = o.l.length, e = c.appendChild( d.createElement( "div" ) );&lt;br /&gt;			for( j in ( o.l[i] = s, e.className = "normal", e.d = data, e.listindex = i, !found &amp;&amp; i == o.s.i &amp;&amp; ++found &amp;&amp; o.highlite( e ), x ) )&lt;br /&gt;				e.appendChild( d.createTextNode( s.substring( l, x[j] ) ) ).parentNode.appendChild( d.createElement( "span" ) ).appendChild( d.createTextNode( s.substring( x[j], l = x[j] + iV.length ) ) ).parentNode.className = "selectedText";&lt;br /&gt;			for( x in ( e.appendChild( d.createTextNode( s.substr( l ) ) ), { click: 0, mouseover: 0 } ) )&lt;br /&gt;				addEventListener( e, x, function( e ){ o.handler.call( o, e ); } );&lt;br /&gt;		}, iV );&lt;br /&gt;		if( !c.childNodes.length )&lt;br /&gt;			return o.hide();&lt;br /&gt;		for( var x = i.offsetLeft, y = i.offsetTop + i.offsetHeight; i = i.offsetParent; x += i.offsetLeft, y += i.offsetTop );&lt;br /&gt;		( cS.display = "block", cS.left = x + "px", cS.top = y + "px", !found &amp;&amp; o.highlite( c.firstChild ) );&lt;br /&gt;	};&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Example&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;style type="text/css"&gt;&lt;br /&gt;/*container da lista*/&lt;br /&gt;.autocomplete{&lt;br /&gt;	cursor: pointer;&lt;br /&gt;	border: 1px solid #999;&lt;br /&gt;	border-top: none;&lt;br /&gt;	background: #eee;&lt;br /&gt;}&lt;br /&gt;/*caracteres que combinaram*/&lt;br /&gt;.autocomplete .selectedText{ font-weight: bold; color: #008; }&lt;br /&gt;/*items n&#227;o selecionados*/&lt;br /&gt;.autocomplete .normal{ border-top: 1px solid #999; overflow: hidden; white-space: pre; }&lt;br /&gt;/*item selecionado*/&lt;br /&gt;.autocomplete .highlited{ background: #ddf; }&lt;br /&gt;&lt;/style&gt;&lt;br /&gt;&lt;br /&gt;&lt;form action=""&gt;&lt;br /&gt;	&lt;fieldset&gt;&lt;br /&gt;		&lt;legend&gt;Preenchimento din&#226;mico&lt;/legend&gt;&lt;br /&gt;		&lt;label for="list" &gt;Emails&lt;/label&gt;&lt;br /&gt;		&lt;input autocomplete="0" type="text" name="list" id="list" /&gt;&lt;br /&gt;		&lt;br /&gt;&lt;br /&gt;		&lt;label for="ip" &gt;Lista de IPs&lt;/label&gt;&lt;br /&gt;		&lt;textarea name="ip" rows="3" cols="20" id="ip"&gt;&lt;/textarea&gt;&lt;br /&gt;		&lt;br /&gt;&lt;br /&gt;	&lt;/fieldset&gt;&lt;br /&gt;&lt;/form&gt;&lt;br /&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;//&lt;![CDATA[&lt;br /&gt;&lt;br /&gt;var list = [ "192.168.0.1", "192.168.0.2", "192.168.0.3", "192.168.1.1", "192.168.1.2", "192.168.1.3", "200.168.0.1", "200.168.0.2", "200.168.0.3", "200.168.1.1", "200.168.1.2", "200.168.1.3" ];&lt;br /&gt;new IncrementalSearch( document.forms[0].ip, function( search ){&lt;br /&gt;	for( var i in list )&lt;br /&gt;		if( !list[i].indexOf( search ) )&lt;br /&gt;			this( list[i], 0 );&lt;br /&gt;}, "autocomplete" );&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;var names = [ "Jo&#227;o Alves &lt;joao@123.com&gt;", "Jonas Raoni Soares Silva &lt;jonas@abc.com&gt;", "Roberto &lt;rob@net.net&gt;", "Maria Fernanda &lt;mariaf@i.tu&gt;" ];&lt;br /&gt;&lt;br /&gt;function retrieveNames( search ){&lt;br /&gt;	search = search.toLowerCase();&lt;br /&gt;	for( var i in names ){&lt;br /&gt;		if( search ){&lt;br /&gt;			for( var j = 0, indices = []; j = names[i].toLowerCase().indexOf( search, j ) + 1; indices[indices.length] = j - 1 );&lt;br /&gt;			this( names[i], indices, i );&lt;br /&gt;		}&lt;br /&gt;		else&lt;br /&gt;			this( names[i], 0, i );&lt;br /&gt;&lt;br /&gt;	}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;x = new IncrementalSearch( document.forms[0].list, retrieveNames, "autocomplete" );&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;//]]&gt;&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;</description>
      <pubDate>Fri, 09 Sep 2005 07:41:46 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/684</guid>
      <author>jonasraoni (Jonas Raoni Soares Silva)</author>
    </item>
    <item>
      <title>Atom / RSS feed of your GMail account</title>
      <link>http://snippets.dzone.com/posts/show/262</link>
      <description>&lt;code&gt;https://USERNAME:PASSWORD@gmail.google.com/gmail/feed/atom&lt;/code&gt;</description>
      <pubDate>Sat, 07 May 2005 22:45:40 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/262</guid>
      <author>peter (Peter Cooperx)</author>
    </item>
    <item>
      <title>Change Gmail encoding to display thai.</title>
      <link>http://snippets.dzone.com/posts/show/124</link>
      <description>Some emails send from yahoo and hotmail will display thai incorrectly. This bookmarklet re-encode it by shifting the unicode numbers. Can be applied to some language whose encoding is in the same "shifting" order.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;javascript:(function(){  map=[];for(i=161;i&lt;251;i++)map[i]=String.fromCharCode(i+3424);  function thai(s){s2='';for(var i=0;i&lt;s.length;i++){n=s.charCodeAt(i);if(n&gt;160&amp;&amp;n&lt;251) s2+=map[n];else s2+=s.charAt(i)}return s2}   function rc_thai(el){if(el.nodeType== 3){el.data=thai(el.data);return} if(el.tagName == 'SCRIPT') return; for (var i=0; i&lt;el.childNodes.length; i++) rc_thai(el.childNodes[i])}   for(i=0;i&lt;4;i++){if(fi=window.frames[0].frames[i].document.getElementById('fi')) break}  rc_thai(fi); })();&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;The one-liner version above maybe difficult to read.&lt;br /&gt;Here's a reorganized one&lt;br /&gt;&lt;code&gt;&lt;br /&gt;javascript:(function(){&lt;br /&gt;map=[];&lt;br /&gt;/* create conversion table */&lt;br /&gt;for(i=161;i&lt;251;i++) {&lt;br /&gt;  map[i]=String.fromCharCode(i+3424);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function thai(s){&lt;br /&gt;  s2='';&lt;br /&gt;  for(var i=0;i&lt;s.length;i++){&lt;br /&gt;    n=s.charCodeAt(i);&lt;br /&gt;    if(n&gt;160&amp;&amp;n&lt;251) &lt;br /&gt;      s2+=map[n];&lt;br /&gt;    else &lt;br /&gt;      s2+=s.charAt(i)&lt;br /&gt;  }&lt;br /&gt;  return s2&lt;br /&gt;}   &lt;br /&gt;&lt;br /&gt;/* recursively convert encoding of sub-element */&lt;br /&gt;function rc_thai(el){&lt;br /&gt;  if(el.nodeType== 3){&lt;br /&gt;    el.data=thai(el.data);&lt;br /&gt;    return&lt;br /&gt;  } &lt;br /&gt;  if(el.tagName == 'SCRIPT') &lt;br /&gt;    return; &lt;br /&gt;  for (var i=0; i&lt;el.childNodes.length; i++)&lt;br /&gt;    rc_thai(el.childNodes[i])&lt;br /&gt;}   &lt;br /&gt;&lt;br /&gt;/* finding the content element in sub-sub-frame */&lt;br /&gt;for(i=0;i&lt;4;i++){&lt;br /&gt;  if(fi=window.frames[0].frames[i].document.getElementById('fi'))&lt;br /&gt;    break&lt;br /&gt;}  &lt;br /&gt;&lt;br /&gt;/* change that element (and all its descendants */&lt;br /&gt;rc_thai(fi); &lt;br /&gt;})();&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 11 Apr 2005 03:57:06 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/124</guid>
      <author>korakot (Korakot Chaovavanich)</author>
    </item>
  </channel>
</rss>
