Forget Gmail filters, let Google sort your inbox using Machine Learning algorithms
Among the multitude of programming APIs provided by Google lies a jewel called Prediction API. It has a high-quality classifier that allows for continuous learning with model updates.
Let's quickly use it to automatically sort incoming mail into your existing labels. The most tedious part is configuration:
Configuration
- Create a new Blank Project in Google Apps Script and enable Prediction API in the
Resources/Advanced Google services…
menu. - Sign up for the Google Developers Console and take the 300$ free credit. Then, create your first Developers Console project and enable Prediction API in its API & auth section.
- Switch back to your newly created Google Apps Script and link it with your new Developers Console project through the
Resources/Developers Console Project
menu.
We are done configuring. Now, there are only two functions to implement: one to train the model and the other to classify incoming mail.
Train
The function GmailApp.getUserLabels()
❶ gets all labels that you defined in Gmail and disregards standard labels such as Inbox
, All Mail
or Spam
. Mails in Gmail are organized by threads, so once you get a handle on a label, you have to get all of its threads ❷, then grab individual mails under that thread. We'll use the first email of a thread for this simple exercise ❸.
Googless Calendar
. # get the pypi installer apt-get install python-stdeb patch <<EOF --- /usr/bin/pypi-install.ori 2014-05-11 21:32:24.884512975 +0200 +++ /usr/bin/pypi-install 2014-05-10 20:23:34.427058833 +0200 @@ -16,7 +16,7 @@ USER_AGENT = 'pypi-install/0.6.0+git ( http://github.com/astraw/stdeb )' -def find_tar_gz(package_name, pypi_url = 'http://python.org/pypi',verbose=0): +def find_tar_gz(package_name, pypi_url = 'http://pypi.python.org/pypi',verbose=0): transport = xmlrpclib.Transport() transport.user_agent = USER_AGENT pypi = xmlrpclib.ServerProxy(pypi_url, transport=transport) EOF # install the latest pam library from pypi pypi-install pam patch <<EOF--- /usr/lib/python2.7/dist-packages/radicale/acl/PAM.py.ori 2014-05-11 21:35:36.441065840 +0200 +++ /usr/lib/python2.7/dist-packages/radicale/acl/PAM.py 2014-05-10 20:27:12.771722350 +0200 @@ -50,7 +50,7 @@ # Check whether the group exists try: - members = grp.getgrnam(GROUP_MEMBERSHIP) + members = grp.getgrnam(GROUP_MEMBERSHIP)[3] except KeyError: log.LOGGER.debug( "The PAM membership required group (%s) doesn't exist" % EOF apt-mark hold python-pam apt-get install radicale
Notes on setting up Debian with ChromeOS kernel on a SD card plugged into Samsung ARM Chromebook
echo "console=tty1 debug verbose root=/dev/mmcblk1p3 rootwait rw lsm.module_locking=0" > /tmp/config dd if=/dev/mmcblk0p2 of=/tmp/oldblob vbutil_kernel --repack /tmp/newkern --keyblock /usr/share/vboot/devkeys/kernel.keyblock --version 1 \ --signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk --config=/tmp/config --oldblob /tmp/oldblob dd if=/tmp/newkern of=/dev/mmcblk1p1 dd if=/tmp/newkern of=/dev/mmcblk1p2 cgpt add -i 1 -S 1 -T 5 -P 10 -l KERN-A /dev/mmcblk1 cgpt add -i 2 -S 1 -T 5 -P 5 -l KERN-B /dev/mmcblk1Note the use of --oldblob option -- newer ChromeOS does now mount /boot anymore, but HOWTOs out there still suggest to point to the kernel using --vmlinuz . Also, lsm.module_locking=0 is important. Without it, you won't be able to load kernel modules in Debian.