Category Archives: geek

August 2015 Emacs Hangout

Thanks to Philip Stark for hosting this one!

Text chat:

Paul Harper 2:08 PM Evan’s Links: http://www.misshula.org/category/tutorials.html Dart Throwing Chimp: https://dartthrowingchimp.wordpress.com/
Philip Stark 2:15 PM https://www.vagrantup.com/ http://stevelosh.com/blog/2012/10/the-homely-mutt/
Paul Harper 2:19 PM mu4e: http://www.macs.hw.ac.uk/~rs46/posts/2014-01-13-mu4e-email-client.html Zawinski’s Law “Every program attempts to expand until it can read mail. Those programs which cannot so expand are replaced by ones which can.” Law of Software Envelopment, Jamie Zawinski. Mutt with Org-Mode: https://upsilon.cc/~zack/blog/posts/2010/02/integrating_Mutt_with_Org-mode/
me 2:23 PM Maybe http://emacswiki.org/emacs/MultipleSMTPAccounts ?
Magnus Henoch 2:24 PM I mashed some of those together into this monster: link (github.com)
Mond Beton 2:25 PM org mode is new
Rogelio Zarate 2:26 PM Just started with emacs
Paul Harper 2:27 PM Emacs and Vim started in 1976 link (slate.com)
me 2:28 PM Was it this Err, link (sachachua.com)
http://endlessparentheses.com/ ?
Paul Harper 2:41 PM Not sure if this might help. Setting up Emacs key mappings on Windows Outlook link (blogs.adobe.com)
me 2:42 PM http://emacsblog.org/2007/05/10/emacs-key-bindings-in-windows/ suggests XKeymacs, but I don’t know if it will work with recent versions of Windows. http://www.cam.hi-ho.ne.jp/oishi/indexen.html
Mond Beton 2:44 PM thank you
Rogelio Zarate 2:48 PM Too many opinions on how to do things, example keybing on emacs/os x
me 2:50 PM link (emacs.stackexchange.com) may be helpful if you want it to reuse an existing Emacs if possible
Daniel Gopar 2:58 PM https://github.com/gopar/.emacs.d/blob/master/init.el#L442
Paul Harper 2:59 PM Something for beginners like me. A course in research tools which includes some clear videos on using Emacs. Kurt Schwehr put the course on YouTube (linked in note) and the course is in org mode. The Course itself is GIS focused. You can download the whole thing with Mercurial. Instructions on the page. I found it very helpful when I started. http://vislab-ccom.unh.edu/~schwehr/rt/
Philip Stark 3:02 PM What’s GIS?
me 3:03 PM Phil: Hmm, something like http://emacs.stackexchange.com/questions/608/evil-map-keybindings-the-vim-way using tags?
Philip Stark 3:05 PM https://www.gnu.org/software/global/
Philip Stark 3:07 PM http://elpa.gnu.org/packages/ggtags.html
Daniel Gopar 3:09 PM so im learning elisp. Does elisp have any ways of creating private/public variables? or is everything exposed once you run the require command on the file?
Philip Stark 3:09 PM https://github.com/skeeto/skewer-mode
Rogelio Zarate 3:14 PM How do you handle projects, like in Sublime, do you use Projectile or Perspective?
Philip Stark 3:14 PM http://exercism.io/
me 3:16 PM https://github.com/losingkeys/4clojure.el and http://endlessparentheses.com/be-a-4clojure-hero-with-emacs.html
Philip Stark 3:18 PM https://www.bestpractical.com/rt/
Rogelio Zarate 3:19 PM Keeping just one list sounds like the correct approach. Great tip.
me 3:19 PM link (saintaardvarkthecarpeted.com)
Paul Harper 3:21 PM Notmuch https://www.youtube.com/watch?v=PK5rOT6k8rw
me 3:29 PM Want to get notified about upcoming hangouts? You can sign up for notifications at http://eepurl.com/bbi-Ir

Org Mode date arithmetic

Whenever I need to get Emacs to prompt me for a date or time (even for non-Org things), I use org-read-date. I love its flexibility. It’s great to be able to say things like +3 for three days from now, fri for next Friday, +2tue for two Tuesdays from now, +1w for next week, and +1m for next month. It’s easy to use org-read-date in Emacs Lisp. Calling it with (org-read-date) (usually as an interactive argument, like so: (interactive (list (org-read-date)))) gives me a date like 2015-08-06 depending on what I type in.

I use org-read-date for non-interactive date calculations, too. For example, if I want to quickly get the Org-style date for tomorrow, I can use org-read-date‘s third parameter (from-string) like this:

(org-read-date nil nil "+1")

Here’s how to calculate relative dates based on a specified date. You can hard-code the base date or use another org-read-date to get it. In this example, I’m getting the Monday after 2015-08-31. Note the use of two + signs instead of just one.

(org-read-date nil nil "++mon" nil (org-time-string-to-time "2015-08-31"))

org-time-string-to-time converts a date or time string into the internal representation for time. You can then extract individual components (ex: month) with decode-time, or convert it to the number of seconds since the epoch with time-to-seconds. Alternatively, you can convert Org time strings directly to seconds with org-time-to-seconds.

If you’re working with days, you can convert time strings with org-time-string-to-absolute. For example, you can use this to calculate the number of days between two dates (including the first day but excluding the last day), like this:

(let ((start-date (org-read-date))
      (end-date (org-read-date)))
  (- (org-time-string-to-absolute end-date)
     (org-time-string-to-absolute start-date)))

To get the month, day, and year, you can use org-time-string-to-time and decode-time, or you can use org-time-string-to-seconds and calendar-gregorian-from-absolute.

To convert internal time representations into Org-style dates, I tend to use (format-time-string "%Y-%m-%d" ...). encode-time is useful for converting something to the internal time representation. If you’re working with absolute days, you can convert them to Gregorian, and then format the string.

So, to loop over all the days between the start and end date, you could use a pattern like this:

(let* ((start-date (org-read-date))
       (end-date (org-read-date))
       (current (org-time-string-to-absolute start-date))
       (end (org-time-string-to-absolute end-date))
       gregorian-date
       formatted-date)
  (while (< current end)
    (setq gregorian-date (calendar-gregorian-from-absolute current))
    (setq formatted-date
          (format "%04d-%02d-%02d"
                  (elt gregorian-date 2) ; month
                  (elt gregorian-date 0) ; day
                  (elt gregorian-date 1))) ; year
    ;; Do something here; ex:
    (message "%s" formatted-date)
    ;; Move to the next date
    (setq current (1+ current))))

Alternatively, you could use org-read-date with a default date, like this:

(let* ((start-date (org-read-date))
       (end-date (org-read-date))
       (current start-date))
  (while (string< current end-date)
    ;; Do something here; ex:
    (message "%s" current)
    ;; Move to the next date
    (setq current (org-read-date nil nil "++1" nil (org-time-string-to-time current)))))

There are probably more elegant ways to write this code, so if you can think of improvements, please feel free to share.

Anyway, hope that helps!

July 2015 Emacs Hangout

We talked about Python, Org Mode, system administration, keybindings, Hydra, and other neat things. =)

I’ll probably set up another hangout mid-August, or we’ll just do the one on the 29th. We’ll see! You can follow the Emacs Conferences and Hangouts page for more information, or sign up to get e-mails for upcoming hangouts. Past Emacs Hangouts

Text chat (links edited to avoid weird wrapping things):

me 9:18 PM literate devops link
Daniel Gopar 9:34 PM config link
me 9:37 PM jwiegley/dot-emacs jwiegley – haskell
Howard Melman 9:48 PM cocoa-text-system
Mr Swathepocalypse 9:55 PM I have to go attend to some work stuff, I look forward to watching the rest of the hangout later on.
me 9:55 PM Orgstruct
Mr Swathepocalypse 9:55 PM Thanks guys!
me 9:55 PM Bye Dylan! my config erc erc-pass
Howard Abrams 9:59 PM Did I mention how I’ve been using emacs mail to mime encode an org-mode buffer into HTML for the most awesome mail messages.
Daniel Gopar 10:05 PM Have you guys used “helm-M-x”? It’s part of the helm package I believe
Kaushal Modi 10:07 PM ready to share which-key package
Daniel Gopar 10:10 PM Got to go. Nice talking to everyone.
Kaushal Modi 10:14 PM config link
Kaushal Modi 10:37 PM (setq debug-on-message “Making tags”)
me 10:39 PM org-map-entries
Correl Roush 10:47 PM git graphs
me 10:54 PM imagex-global-sticky-mode imagex-auto-adjust-mode
Kaushal Modi 10:54 PM Emacs-imagex config link example of setting ditaa and plantuml
Correl Roush 10:58 PM writing specs link that has some setup steps listed out as well

Gradually evolving my data entry interfaces

I’m interested in Quantified Self as a way to make better decisions through data. When I come up with a question I want to explore, I usually start off tracking things on paper or in a spreadsheet. This means I can get started quickly, and I can check whether the question is useful enough to invest in further.

Clothes

I track my clothes to make it easier to simplify my wardrobe, and to guide my purchases.

I started by writing down dates and clothing combinations on an index card in the morning. Since my index card was unlined and my brain is pretty fuzzy early in the day, I occasionally had problems with incorrect dates or items not matching up. Eventually, I built a small Rails application (Quantified Awesome) to keep track of the clothes for me. Adding pictures made it easier to select the right item. Over time, I added little conveniences like the ability to display or sort by the last time I wore something.

I often find myself backdating entries, so maybe tracking my clothes isn’t as easy or as fun as it could be. I wonder if making it more prescriptive (“Pick one of these three outfits, or select what you’re going to wear”) would help, or maybe integrating it more into my morning routine.

Time

I track my time to guide my activity decisions and remind me of how I used the time.

I used apps on my phone to track time for a few months. I started with Time Recording and a few categories, adding more as I went along. When the number of categories got to be a bit unwieldy, I moved on to Tap Log so that I could organize the buttons into a menu. Since it didn’t have the built-in time analysis I liked about Time Recording, I added time analysis tools to Quantified Awesome. After I added other features to Quantified Awesome, I shifted to using it as my time tracking and analysis tool.

For a while, I tracked time by bringing up the Quantified Awesome web interface on my phone and typing in a substring of a category name. Then I decided to look into building Emacs integration so that I could automatically clock in from my to-do list. To speed up time tracking on my phone, I used Tasker to create a menu of my most common time categories. Since fiddling with Tasker on my phone was time-consuming and a little annoying, I eventually shifted to using Tasker and Javascript. That way, I could edit my HTML file in Emacs, copy it onto my phone through Dropbox, and get my handy menu of buttons. Using Tasker also allowed me to code extra behaviour such as turning off WiFi when I go for a walk.

My next step is probably to build more time visualizations so I can see the shifts from day to day, week to week.

Groceries

I track groceries so that I can make better decisions at the supermarket and so that I can get a sense of the balance and patterns of our consumption.

I started by typing in my receipts manually, but it was a little boring. I paid a virtual assistant to enter the data from my scanned receipts. This worked out to be better than the receipt scanning companies that were out there, since I could get line-item detail in a spreadsheet shared in Dropbox. I periodically reviewed the data, fixing errors and analyzing totals.

After some time doing this and quite a few errors in the data, I decided to build my own interface for entering data more reliably. Now that I’ve built my neat interactive interface, I find it faster (and more fun!) to enter the data in myself than to scan it and send it over. I’ve been digging into visualizing the data with D3 too.

Here’s a quick demo:

My next step is probably to build a grocery list interface for it. We’re currently using OurGroceries because it syncs well between my husband’s phone and mine, but I should be able to use either straight AJAX or WebSockets to get the synchronization part working.

So those are a few examples of how I slowly improve my tracking systems, rounding off rough edges and making things a little bit simpler for myself. Web programming is super helpful for me. Backend tools like Ruby on Rails allow me to build my own tracking tools and front-end tools like Javascript allow me to create personalized interfaces and visualizations.

I tend to code the next step of improvements only when something annoys me enough for me to do something about it or when a question makes me curious enough to want to investigate it. I’ve been deliberately working on my personal projects more often, though, and that might lead to more of these little improvements. We’ll see!

Exploring our grocery numbers

Analyzing my grocery data is more challenging than analyzing my time data. There’s a lot more data cleanup needed. I have to figure out obscure line items on old receipts and catch typos in both names and numbers. Then there’s figuring out how much I want to combine different items and how much I want to keep them separate.

For example, milk has different receipt item names depending on the item (size, brand, type) and the store. If I want to know how much we’ve spent on milk, I’ll use the total for all of them. But if I want to get a sense of the price history, it makes sense to track each receipt item type separately. I do this by keeping the receipt name (fixing typos as I review my data) and mapping these receipt names to a friendly name I set for myself. This way, the line “HOMO 4LI” on my receipt gets turned into “Milk” in my report. Come to think of it, maybe I should change it to “Milk, 4 L, Homogenized”…

Categories are handy for reporting too. Because of the ad-hoc way I created receipt item mappings and assigned them to categories, I ended up with inconsistent categorization. Some types of toilet paper were in the Supplies category, and some types were in the Other category. I manually reviewed the category assignments and I think I’ve gotten them sorted out.

Anyway, analyzing my data from 2013-07-01 to 2015-07-01, I see that we spend an average of $80 per week on groceries, which sounds about right. Some of the receipts are missing and there are almost certainly other little errors in the data, but this should give me the overall picture.

I’m still trying to figure out a good way to visualize the data in order to answer the questions I’m curious about, so here are my notes along the way. X axis is date, Y axis is total cost on that day, color is how it compares to the average price it is (lower price than average = blue, higher = orange).

Milk

2015-07-03 20_47_42-sachachua.com_8080_grocery_analysis

Milk consumption is pretty straightforward. Every week, we use around 0.6 bags of milk (~2.4L) – more when J- and her friends are over (teenagers!). The price of milk has stayed at $4.97 per 4L, except for the time we bought a slightly more expensive type of milk (~Oct 2013) and the time in June 2014 when a smaller size was on sale, so we picked up one of those instead.

Eggs

 

We used to buy extra-large eggs, but the supermarket close to us stopped carrying 18-packs of those, so we switched to 18-packs of large eggs instead.

Extra-large eggs

2015-07-03 20_45_34-sachachua.com_8080_grocery_analysis

Large eggs

2015-07-03 20_46_07-sachachua.com_8080_grocery_analysis

The price of large eggs is stable at $4.27 for 18. We use ~11 eggs a week.

Things we buy when they’re on sale

Canned tomatoes

We stock up on canned tomatoes when they go on sale, since they’re easy to store.

2015-07-03 20_50_19-sachachua.com_8080_grocery_analysis

 

We probably use ~3 cans a month. The sale price has drifted up from $0.88 to $0.97, while the regular price is a little bit over $1.50.

Butter

2015-07-03 20_52_53-sachachua.com_8080_grocery_analysis

We haven’t bought butter at full-price in two years. The sale price for unsalted butter tends to be between $2.77 and $3.33, while the regular price is $6+.

Produce

Strawberries

I like strawberries, but I stopped buying them for a long time because they seemed like such an indulgence and the sweetness tended to be hit-or-miss. This year, I gave myself permission to splurge on strawberries in season.

2015-07-03 20_55_25-sachachua.com_8080_grocery_analysis

Bananas

We seem to go through banana phases. When we hit banana overload, we stop for a while.

2015-07-03 20_57_54-sachachua.com_8080_grocery_analysis

 

The colours here are just due to floating point imprecision. Bananas have actually stayed the same price for the past two years ($1.26/kg).

Apples

We often get gala apples:

2015-07-03 21_01_18-sachachua.com_8080_grocery_analysis

We like picking up ambrosia apples during the rare occasions they’re available. Last winter was a good one for ambrosia apple availability.

2015-07-03 21_03_09-sachachua.com_8080_grocery_analysis

Chicken

Whole chickens

2015-07-03 21_05_03-sachachua.com_8080_grocery_analysis

Lots of whole chickens lately, because of the rotisserie.

Chicken quarters

2015-07-03 21_07_49-sachachua.com_8080_grocery_analysis

Our main protein, although we also buy a fair bit of beef and pork, and chicken drumsticks/thighs when they’re on sale.

There’s more I haven’t explored yet, but I figured I’d put together these little observations along the way. =)

 

 

Emacs Hangout June 2015

Times may be off by a little bit, sorry!

Boo, I accidentally browsed in the Hangouts window before copying the text chat, so no copy of the text chat this time… =|