<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>google — jd:/dev/blog</title><description>Posts tagged &quot;google&quot; on jd:/dev/blog.</description><link>https://julien.danjou.info/</link><item><title>Google Calendar notifications using pynotify</title><link>https://julien.danjou.info/blog/google-calendar-pynotify/</link><guid isPermaLink="true">https://julien.danjou.info/blog/google-calendar-pynotify/</guid><description>I use Google Calendar to manage my calendars, and I really missed something to warn me whenever I have an appointment with an alert set.</description><pubDate>Tue, 03 Jan 2012 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;I use &lt;a href=&quot;http://google.com/calendar&quot;&gt;Google Calendar&lt;/a&gt; to manage my calendars, and I really missed something to warn me whenever I have an appointment with an alert set.&lt;/p&gt;
&lt;p&gt;So here is an example of a Python program to do such a thing. It is written using the &lt;a href=&quot;http://code.google.com/p/gdata-python-client/&quot;&gt;Google Data APIs Python client library&lt;/a&gt; and pynotify.&lt;/p&gt;
&lt;p&gt;I&apos;ll detail the code here, so you can build your own and adapt it to your needs.&lt;/p&gt;
&lt;p&gt;First, we need to import GTK+ and pynotify, and initialize it.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;import gtk
import pynotify
pynotify.init(sys.argv[0])
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then, we need to import gdata Calendar API and connect to the calendar. I&apos;ll use the simple email/password way to login, which is clearly not the best, but it&apos;s also the simplest. Feel free to use OAuth 2.0. :-)&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;calendar_service = gdata.calendar.service.CalendarService()
calendar_service.email = &apos;mygooglelogin&apos;
calendar_service.password = &apos;mygooglepassword&apos;
calendar_service.ProgrammaticLogin()
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now we&apos;re ready to request stuff and notify! First, request the events from the default calendar.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;feed = calendar_service.GetCalendarEventFeed()
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now we can iterate over &lt;em&gt;feed&lt;/em&gt; and do various checks.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;for event in feed.entry:
    # If the event status is not confirmed, go to the next event.
    if event.event_status.value != &quot;CONFIRMED&quot;:
        continue
    # Now iterate over all the event dates (usually it has one)
    for when in event.when:
        # Parse start and end time
        try:
            start_time = datetime.datetime.strptime(when.start_time.split(&quot;.&quot;)[0], &quot;%Y-%m-%dT%H:%M:%S&quot;)
            end_time = datetime.datetime.strptime(when.end_time.split(&quot;.&quot;)[0], &quot;%Y-%m-%dT%H:%M:%S&quot;)
        except ValueError:
            # ValueError happens on parsing error. Parsing errors
            # usually happen for &quot;all day&quot; events since they have
            # not time, but we do not care about this events.
            continue
        now = datetime.datetime.now()
        # Check that the event hasn&apos;t already ended
        if end_time &amp;gt; now:
            # Check each alert
            for reminder in when.reminder:
                # We handle only reminders with method &quot;alert&quot;
                # and whose start time minus the reminder delay has passed
                if reminder.method == &quot;alert&quot; \
                        and start_time - datetime.timedelta(0, 60 * int(reminder.minutes)) &amp;lt; now:
                    # Build the notification
                    notification = pynotify.Notification(summary=event.title.text,
                                                         message=event.content.text)
                    # Set an icon from the GTK+ stock icons
                    notification.set_icon_from_pixbuf(gtk.Label().render_icon(gtk.STOCK_DIALOG_INFO,
                                                                              gtk.ICON_SIZE_LARGE_TOOLBAR))
                    notification.set_timeout(0)
                    # Show the notification
                    notification.show()
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Running this program, you should see a notification if an appointment has an alert to be raised at that time.&lt;/p&gt;
&lt;p&gt;This should be enough to start to build something.&lt;/p&gt;
&lt;p&gt;If you don&apos;t want to program this into Python, you might want to take a look at &lt;a href=&quot;http://code.google.com/p/gcalcli/wiki/HowTo&quot;&gt;gcalcli&lt;/a&gt;.&lt;/p&gt;
</content:encoded><category>python</category><category>x11</category><category>google</category></item><item><title>Google Contacts for Emacs</title><link>https://julien.danjou.info/blog/google-contacts-for-emacs/</link><guid isPermaLink="true">https://julien.danjou.info/blog/google-contacts-for-emacs/</guid><description>I finally finished a thing I was really missing: accessing my Google Contacts from Emacs.</description><pubDate>Mon, 26 Sep 2011 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;I finally finished a thing I was really missing: accessing my Google Contacts from Emacs.&lt;/p&gt;
&lt;p&gt;That&apos;s now possible, thanks to my new &lt;a href=&quot;https://github.com/jd/google-contacts.el&quot;&gt;google-contacts.el&lt;/a&gt; package.&lt;/p&gt;
&lt;p&gt;It includes searching for any contact and displaying the result in a window.&lt;br /&gt;
You can also jump to a contact from &lt;a href=&quot;http://gnus.org&quot;&gt;Gnus&lt;/a&gt; by pressing a&lt;br /&gt;
key, and complete e-mail addresses while composing a mail.&lt;/p&gt;
</content:encoded><category>emacs</category><category>google</category></item><item><title>Google Maps for Emacs: moving, caching and home</title><link>https://julien.danjou.info/blog/google-maps-for-emacs-moving-caching-home/</link><guid isPermaLink="true">https://julien.danjou.info/blog/google-maps-for-emacs-moving-caching-home/</guid><description>Last week, I worked on my Google Maps for Emacs extension. I&apos;ve introduced a new format handling for locations which include the longitude and latitude.</description><pubDate>Mon, 08 Nov 2010 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Last week, I worked on my Google Maps for Emacs extension. I&apos;ve introduced a new format handling for locations which include the longitude and latitude. The initial format was just a string describing the location, which was obviously too limited.&lt;/p&gt;
&lt;p&gt;It now prints coordinates of the different elements when the mouse is over the map, with other information.&lt;/p&gt;
&lt;p&gt;It also center the map on &lt;em&gt;M-x google-maps&lt;/em&gt; and set a default zoom level. This is something which was not set because it&apos;s not a good idea to set center coordinates in order to see all points on the map automatically. But you can still remove the centering by pressing &lt;em&gt;&quot;C&quot;&lt;/em&gt;. On the other hand, setting it automatically allows to move the map easily, and I think that what most users want to do.&lt;/p&gt;
&lt;p&gt;I&apos;ve also added a &quot;place my home on the map&quot; feature, accessible by pressing &lt;code&gt;h&lt;/code&gt; on any map. That adds a marker according to the location set in Emacs using the &lt;code&gt;calendar-&lt;/code&gt; variables.&lt;/p&gt;
&lt;p&gt;This feature is also available under &lt;a href=&quot;http://orgmode.org&quot;&gt;Org&lt;/a&gt; by pressing &lt;em&gt;C-u C-c M-l&lt;/em&gt;, which shows the location of your appointment with your home on the map too.&lt;/p&gt;
&lt;p&gt;Finally, you also get caching so it does not request images you already seen, which makes the moving nicer and faster to use, and prompt history.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://julien.danjou.info/content/images/03/emacs-google-maps-move-1.png&quot; alt=&quot;emacs-google-maps-move-1&quot; /&gt;&lt;/p&gt;
</content:encoded><category>emacs</category><category>google</category></item><item><title>Emacs, Org, whatever the weather!</title><link>https://julien.danjou.info/blog/emacs-org-whatever/</link><guid isPermaLink="true">https://julien.danjou.info/blog/emacs-org-whatever/</guid><description>Another week, another Emacs extension!</description><pubDate>Wed, 08 Sep 2010 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Another week, another &lt;a href=&quot;http://www.gnu.org/software/emacs/&quot;&gt;Emacs&lt;/a&gt; extension!&lt;/p&gt;
&lt;p&gt;I had (once again) a wonderful idea: what if I could have the weather forecasts in my &lt;a href=&quot;http://orgmode.org&quot;&gt;Org&lt;/a&gt; agenda? Wouldn&apos;t that be wonderful?&lt;/p&gt;
&lt;p&gt;My quest started by looking for a service offering a good weather forecast API. I found nothing simple as the hidden Google Weather API, which is nice, but… not documented. Not at all. Not a single line. Nah.&lt;/p&gt;
&lt;p&gt;Then, I wrote a &lt;strong&gt;google-weather&lt;/strong&gt; extension, implementing a basic Emacs Lisp API to retrieve data from the Google service:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ELISP&amp;gt; (google-weather-data-&amp;gt;forecast (google-weather-get-data &quot;Paris&quot;))
(((9 8 2010)
  (low &quot;53&quot;)
  (high &quot;63&quot;)
  (icon &quot;http://www.google.com/ig/images/weather/rain.gif&quot;)
  (condition &quot;Rain&quot;))
 ((9 9 2010)
  (low &quot;53&quot;)
  (high &quot;69&quot;)
  (icon &quot;http://www.google.com/ig/images/weather/chance_of_rain.gif&quot;)
  (condition &quot;Scattered Showers&quot;))
 ((9 10 2010)
  (low &quot;54&quot;)
  (high &quot;72&quot;)
  (icon &quot;http://www.google.com/ig/images/weather/partly_cloudy.gif&quot;)
  (condition &quot;Partly Cloudy&quot;))
 ((9 11 2010)
  (low &quot;55&quot;)
  (high &quot;75&quot;)
  (icon &quot;http://www.google.com/ig/images/weather/partly_cloudy.gif&quot;)
  (condition &quot;Partly Cloudy&quot;)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;My API even implements data caching, which is nice to speed up the agenda display.&lt;/p&gt;
&lt;p&gt;By the way, I think my next job will be to hack on the &lt;em&gt;url-cache&lt;/em&gt; feature of Emacs, which is utterly buggy and has probably never be used. But that&apos;s another topic.&lt;/p&gt;
&lt;p&gt;Finally, I just had to write another module on top of that to export the forecasts to Org. A screen shot is probably better than a long and boring explanation, so here&apos;s the result.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://julien.danjou.info/content/images/03/org-google-weather-1.png&quot; alt=&quot;org-google-weather-1&quot; /&gt;&lt;/p&gt;
&lt;p&gt;My only regret is that the icons provided by Google are ugly squares, so I did not want to use them. On the other hand, I did not found any icon set that would have all the icons Google provides (around 20). So I felt back on the &lt;a href=&quot;http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html&quot;&gt;icon naming specification&lt;/a&gt; to map the Google images to standard images. Any better idea would be welcome, of course.&lt;/p&gt;
&lt;p&gt;All the information can be found on the &lt;a href=&quot;https://github.com/jd/google-weather.el&quot;&gt;Google Weather for Emacs extension homepage&lt;/a&gt;.&lt;/p&gt;
</content:encoded><category>emacs</category><category>google</category></item><item><title>Emacs, Google Maps and BBDB</title><link>https://julien.danjou.info/blog/emacs-google-maps-bbdb/</link><guid isPermaLink="true">https://julien.danjou.info/blog/emacs-google-maps-bbdb/</guid><description>Today&apos;s fun idea was to put all my contacts stored into BBDB on a Google Maps&apos; map, using my Google Maps extension for Emacs.</description><pubDate>Wed, 18 Aug 2010 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Today&apos;s fun idea was to put all my contacts stored into &lt;a href=&quot;http://bbdb.sourceforge.net/&quot;&gt;BBDB&lt;/a&gt; on a Google Maps&apos; map, using my Google Maps extension for Emacs.&lt;/p&gt;
&lt;p&gt;With the help of a few lines of Lisp glue:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(google-maps-static-show
 :markers
 (mapcar
  (lambda (address-entry)
    `((,(concat
         (mapconcat
          &apos;identity
          (elt address-entry 1) &quot;, &quot;) &quot;, &quot;
          (elt address-entry 2) &quot;, &quot;
          (elt address-entry 3) &quot;, &quot;
          (elt address-entry 4) &quot;, &quot;
          (elt address-entry 5)))))
  (mapcan
   (lambda (record)
     ;; We need to copy the returned list, because mapcan will modify it later
     (copy-list (bbdb-record-addresses record)))
   (bbdb-records))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;https://julien.danjou.info/content/images/03/emacs-google-maps-bbdb-1.png&quot; alt=&quot;Screenshot of Google Maps with BBDB contacts&quot; /&gt;&lt;/p&gt;
&lt;p&gt;It&apos;s really simplistic, but I did not need more to have fun. :-) This could be extended to set a specific marker and/or color for each contact, with a legend. I&apos;ll let that as an exercise for my readers.&lt;/p&gt;
</content:encoded><category>emacs</category><category>google</category></item><item><title>M-x google-maps</title><link>https://julien.danjou.info/blog/google-maps-el/</link><guid isPermaLink="true">https://julien.danjou.info/blog/google-maps-el/</guid><description>Since I have started to use Org-mode, I though it was missing something to have appointment locations on a map.</description><pubDate>Mon, 28 Jun 2010 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Since I have started to use &lt;a href=&quot;http://www.orgmode.org&quot;&gt;Org-mode&lt;/a&gt;, I though it was missing something to have appointment locations on a map. Of course, it&apos;s easy to get a &lt;code&gt;LOCATION&lt;/code&gt; property from an entry, and then &lt;code&gt;browse-url&lt;/code&gt; on &lt;a href=&quot;http://maps.google.com&quot;&gt;Google Maps&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://julien.danjou.info/content/images/03/emacs-google-maps-1.png&quot; alt=&quot;emacs-google-maps-1&quot; /&gt;&lt;/p&gt;
&lt;p&gt;But it is &lt;strong&gt;too&lt;/strong&gt; easy for me, so once again I said: challenge accepted! I will bring Google Maps into Emacs!&lt;/p&gt;
&lt;p&gt;After several hours of work, the &lt;a href=&quot;https://github.com/jd/google-maps.el&quot;&gt;google-maps.el project&lt;/a&gt; shows a map!&lt;/p&gt;
&lt;p&gt;It fully implements the &lt;a href=&quot;http://code.google.com/apis/maps/documentation/staticmaps/&quot;&gt;Google Static Maps API&lt;/a&gt; and the &lt;a href=&quot;http://code.google.com/apis/maps/documentation/geocoding/&quot;&gt;Google Maps Geocoding API&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;You can type &lt;code&gt;M-x google-maps&lt;/code&gt; and type some place to see it marked on map. Of course you can do much more, as seen in the screen shot above.&lt;/p&gt;
&lt;p&gt;I&apos;ve also completed all of this with a small &lt;code&gt;org-location-google-maps.el&lt;/code&gt; which simply show a Google Maps&apos; map for the location of an event in &lt;em&gt;Org mode&lt;/em&gt; by pressing &lt;code&gt;C-c M-l&lt;/code&gt; in an Org buffer or in the Org agenda.&lt;/p&gt;
</content:encoded><category>emacs</category><category>google</category></item></channel></rss>