Using Emacs - 26 - Google Calendar, Org Agenda

A while ago I did a couple of videos on how I use org-capture (part 1, part 2). I didn't get into a big part of org-capture - how I use org-mode and capture to manage my calendar and todo lists.

I was waiting to see if I liked my current setup - using org-gcal to sync with my Google Calendar for appointments while using my main org file for my todo list.

Coincidentally, Rainer König recently put up a video on how he syncs with his Google calendar. He uses a different method than the one I present in this video so make sure to check out his approach. In fact, you should check out his entire series on org-mode.

Here's the code I use install org-gcal. The video steps through setting up things on the Google side. You'll have to replace the client ID and client secrets in the code below as well as use your calendar name and whatever org file you want to sync with.

(setq package-check-signature nil)


(use-package org-gcal
  :ensure t
  :config
  (setq org-gcal-client-id "oauth 2.0 client ID"
	org-gcal-client-secret "client secret"
	org-gcal-file-alist '(("zamansky@gmail.com" .  "~/Dropbox/orgfiles/gcal.org"))))

I use these two hooks to sync things semi-automatically. The first hook syncs whenever I load the agenda. Since this happens in the background, if I just added something to my calendar, I might have to reload the agenda by hitting r in the agenda view.

The second hook syncs with my Google calendar when I capture.

(add-hook 'org-agenda-mode-hook (lambda () (org-gcal-sync) ))
(add-hook 'org-capture-after-finalize-hook (lambda () (org-gcal-sync) ))

Here are the rest of my settings. The org files I want to include in my agenda views:

  • gcal.org – the one I'm syncing
  • i.org – my main org file for todo items (the todo capture places things in here)
  • schedule.org – my old schedule before I was syncing with Google. Not active anymore. I should probably remove it.

Also, my capture settings:

(setq org-agenda-files (list "~/Dropbox/orgfiles/gcal.org"
			     "~/Dropbox/orgfiles/i.org"
			     "~/Dropbox/orgfiles/schedule.org"))


(setq org-capture-templates
      '(("a" "Appointment" entry (file  "~/Dropbox/orgfiles/gcal.org" )
	 "* %?\n\n%^T\n\n:PROPERTIES:\n\n:END:\n\n")
	("l" "Link" entry (file+headline "~/Dropbox/orgfiles/links.org" "Links")
	 "* %? %^L %^g \n%T" :prepend t)
	("b" "Blog idea" entry (file+headline "~/Dropbox/orgfiles/i.org" "Blog Topics:")
	 "* %?\n%T" :prepend t)
	("t" "To Do Item" entry (file+headline "~/Dropbox/orgfiles/i.org" "To Do")
	 "* TODO %?\n%u" :prepend t)
	("n" "Note" entry (file+headline "~/Dropbox/orgfiles/i.org" "Note space")
	 "* %?\n%u" :prepend t)
	("j" "Journal" entry (file+datetree "~/Dropbox/journal.org")
	 "* %?\nEntered on %U\n  %i\n  %a")
	("s" "Screencast" entry (file "~/Dropbox/orgfiles/screencastnotes.org")
	 "* %?\n%i\n")))

The end result is that I can add an event in my Google calendar (or accept a calendar invite) and it appears in my org-mode agenda. Likewise, I can add a scheduled event using capture and it will sync up to Google. I can also just add an event by editing gcal.org but then would have to run org-gcal-post-at-point to send it up to Google.

Now, I can use bring up a regular agenda C-a a, my todo list C-a t or by adding a custom agenda command:

(setq org-agenda-custom-commands
      '(("c" "Simple agenda view"
	 ((agenda "")
	  (alltodo "")))))

a combined agenda and todo view using C-a n

Finally, there's calfw. It's a nice tool to view calendars in Google. I don't use it much anymore but it is nice:

(use-package calfw
  :ensure ;TODO: 
  :config
  (require 'calfw) 
  (require 'calfw-org)
  (setq cfw:org-overwrite-default-keybinding t)
  (require 'calfw-ical)

  (defun mycalendar ()
    (interactive)
    (cfw:open-calendar-buffer
     :contents-sources
     (list
      ;; (cfw:org-create-source "Green")  ; orgmode source
      (cfw:ical-create-source "gcal" "https://somecalnedaraddress" "IndianRed") ; devorah calender
      (cfw:ical-create-source "gcal" "https://anothercalendaraddress" "IndianRed") ; google calendar ICS
      ))) 
  (setq cfw:org-overwrite-default-keybinding t))

(use-package calfw-gcal
	:ensure t
	:config
	(require 'calfw-gcal))

Enjoy.

Better version:

Old, bad version:

BS? - BA - addendum

Over on Facebook, a friend commented on my last post. He commented on the rigor of BA vs BS degrees. The comment mentioned Physics and Math degrees but I thought Id follow up a bit on CS degrees.

I took a quick look at three computer science programs - Cornell, UMich, and Queens College. Cornell because my daughter is there, UMich, my son, and Queens College because it's a CUNY college that offers both a BS and a BA in computer science.

Cornell

Here's a link to Cornell's CS Major page. Same requirements for a BA through their School of Arts and Sciences as for their BS in the School of Engineering. The differences are limited to the fundamental school differences.

University of Michigan

Info on their program can be found here. They note:

  • Identical Core Computer Science requirements
  • Similar Senior Design experiences
  • Identical Upper Level Elective requirement
  • Slight difference in Flexible Technical Elective hours and list

Again, the difference is fundamentally in the base school requirements.

Queens College

This page has links to degree requirements. THe page states that "The B.S. augments the B.A. with more computer science, mathematics, and experimental laboratory courses" but when you look at the actual BS and BA requirements, they're the same.

In all cases, the differences are the fundamental difference between the extra liberal arts and distribution requirements in an Arts and Sciences school and the extra science and math courses required of an engineering school.

Which is better? It all depends. For me, personally, the liberal arts education is very important. For others, it will be the deep dive into science. Maybe more phyics will better enable a CS major to solve some technical problem but then again, maybe a culteral anthropology course will help a CS major see the world and people differently and also color her work.

To my original point - the important thing is that we do a better job informing guidance counselors, teachers, and high school students as to the possibilities so that they can make informed decisions.

BS? - BA

I didn't know Hunter College had computer science.

I heard that refrain more than once during my fall visits to high schools. Part of the reason for this is due to Hunter CS's low profile and small size in spite of its high quality.

Part, though, was also because of some misconceptions about Computer Science programs. I'd hear things like "but they only offer a BA not a BS," or "but Hunter isn't an engineering school."

I've come to realize that we have to do a better job educating kids as to what can come next after high school.

I'm not entirely sure why many assume that CS has to be under engineering. When I was applying to college, most of my choices were Arts and Science schools offering BAs in CS. Maybe it's because people don't disagregate STEM subjects. Even though it's not a computer science program many schools seem to associate FIRST robotics with computer science. Likewise any class with even a modicum of coding becomes computer science and as makerspaces and robotics are a percieved as easy entry STEM classes that appear to be CS (something I'll rant about in a future post), CS becomes associated with engineering.

It's easy enough to explain the difference between a BA in CS and a BS in CS and it's equally easy to show that you can have tremendous success either way. All you have to do to show the validity of a BA in CS is look at succesful people from places like NYU, Courant, Columbia College (as opposed to Columbia Engineering), Cornell school of Arts and Sciences, etc to balance successful people from the engineering schools.

As I'm sure you know, I'm pretty high on Hunter CS and it's certainly one of the best value CS educations out there. Personally, I'm a big believer in a liberal arts education but in any case, as a community we have to do a better job educating the high schools so that graduating seniors are best informed when deciding on their futures.

Using Emacs - 25 - Tramp

Today's video talks about using emacs Tramp mode.

Tramp mode allows you to edit remote files using your local emacs. I usually do this over ssh.

To edit a file on a machine www.cstuy.org I would first find-file using C-c C-f and then for the file name to open:

/ssh:www.cstuy.org:/home/zamansky/sc/testfile

this would open the file testfile in the absolute directory /home/zamansky/sc. If my username on the remote machine is different:

/ssh:username@www.cstuy.org:/home/zamansky/sc/testfile

And I can also work relative to my home directory:

/ssh:username@www.cstuy.org:sc/testfile

If I just hit enter after the machine name and : -

/ssh:username@www.cstuy.org:

I end up in a dired buffer on the remote machine.

Likewise if I run a shell or eshell in the tramp buffer, it will run the shell on the remote machine. In the video I showed how shell didn't work because locally, I'm configured to use zsh and I don't have zsh installed remotely. Eshell, however, worked fine.

Using tramp in this way gives us all of the power of our local emacs configuration to edit a file on a remote machine.

You can also use tramp to edit local files as root using sudo:

sudo::/tmp/sc/rootfile

Note the double colon.

Finally, you can do the double-whammy - remote root editing:

ssh::www.cstu.org|sudo:www.cstuy.org:/home/zamansky/sc/rootfile

If you use zsh and any of this freezes, just do a search on "zsh tramp" and the top couple of hits will tell you what to add to your configuration files to fix things.

Finally, I mentioned in the video that I don't use tramp all that much anymore. That's mostly because I don't do much remote editing anymore. I used it more when I was administering a number of machines at Stuyvesant.

I still use it periodically, but I also use sshfs, a Linux tool (which may be available for other operating systems) that allows me to mount a directory tree from a remote machine and use it on my local machine.




Enter your email address:

Delivered by FeedBurner

Google Analytics Alternative