Mac OS: Spotlight and source code #
Mac OS X has a real time file indexing system called Spotlight. By itself, it's not terribly useful for me. What makes it useful is that it's accessible from the command line. I can search filenames:
locate mapgen2.as mdfind -name mapgen2.as
The locate command relies on a database that's rebuilt nightly; mdfind is updated in real time. Spotlight also indexes the contents, which gives me something similar to recursive fgrep:
fgrep -R word * mdfind -onlyin . word
It won't search for arbitrary regexps but for quickly narrowing down files to find certain words, it's useful.
Extracting Safari's Reading List #
I use Safari's Reading List to transfer pages from my phone to my computer. But I don't really want to read these in Safari on my desktop. I'd rather read them in Firefox, maybe through Pinboard, which has an API to write items and mark them as "to read". This blog post documents what I learned.
Update: [2014-06-07] Deleting items out of the reading list does not work properly. It's ok to read everything out of there but I haven't figured out how to properly modify it. So I guess I need to delete things manually after I read them out.
Update: [2014-09-18] With iOS 8, I'm switching from Reading List to something else, maybe Pinner, to make this process easier.
I searched the web for some resources, and learned that the reading list, as well as other Safari bookmarks, are stored in ~/Library/Safari/Bookmarks.plist. I can use plutil and PlistBuddy to read and edit that file.
Emacs: rainbow-identifiers #
After reading Evan Brook's post about using text editor colors for identifiers instead of keywords, I decided to try the Emacs rainbow-identifiers and color-identifiers-mode. I find rainbow-identifiers easier to configure (it's language agnostic), and the color choices are stable while editing. I find color-identifiers to generate better output when reading code. It highlights only the local identifiers instead of all words, so the colors are more meaningful. Try both and see which works best for you.
Before, using colors for keywords:
var edges = this.graph.edges_from(this.curr); for (var i = 0; i < edges.length; i++) { var next = edges[i]; var edge_weight = this.graph.edge_weight(this.curr, next); if (edge_weight != Infinity) { this.neighbors.push(next); mark_changed(next); if (!this.visited[next]) { this.g[next] = this.g[this.curr] + edge_weight; this.open.push(next); this.parent[next] = this.curr; this.visited[next] = true; } } }
After, using rainbow-colors mode:
var edges = this.graph.edges_from(this.curr); for (var i = 0; i < edges.length; i++) { var next = edges[i]; var edge_weight = this.graph.edge_weight(this.curr, next); if (edge_weight != Infinity) { this.neighbors.push(next); mark_changed(next); if (!this.visited[next]) { this.g[next] = this.g[this.curr] + edge_weight; this.open.push(next); this.parent[next] = this.curr; this.visited[next] = true; } } }
After, using color-identifiers mode (notice how it uses colors for fewer identifiers, so they stand out better):
var edges = this.graph.edges_from(this.curr); for (var i = 0; i < edges.length; i++) { var next = edges[i]; var edge_weight = this.graph.edge_weight(this.curr, next); if (edge_weight != Infinity) { this.neighbors.push(next); mark_changed(next); if (!this.visited[next]) { this.g[next] = this.g[this.curr] + edge_weight; this.open.push(next); this.parent[next] = this.curr; this.visited[next] = true; } } }
Here's how — I first turned off font-lock colors:
(set-face-attribute 'font-lock-comment-face nil :foreground nil :slant 'italic) (set-face-attribute 'font-lock-comment-delimiter-face nil :slant 'italic) (set-face-attribute 'font-lock-constant-face nil :foreground nil :underline t) (set-face-attribute 'font-lock-type-face nil :foreground nil) (set-face-attribute 'font-lock-function-name-face nil :foreground nil :weight 'bold) (set-face-attribute 'font-lock-variable-name-face nil :foreground nil) (set-face-attribute 'font-lock-keyword-face nil :foreground nil :slant 'italic) (set-face-attribute 'font-lock-string-face nil :background "#e0e0e0") (set-face-attribute 'font-lock-builtin-face nil :foreground nil :slant 'italic)
Second, I want colors chosen from L*a*b* color space because it makes the perceived brightness consistent across colors. It turns out color-identifiers mode already uses L*a*b* colors. In rainbow-identifiers mode, I configured it like this:
(loop for i from 1 to 15 do
(let* ((lightness 45)
(saturation 40)
(angle (* 2 pi (/ i 15.0)))
(a (* saturation (cos angle)))
(b (* saturation (sin angle))))
(set-face-attribute
(intern (format "rainbow-identifiers-identifier-%s" i))
nil
:foreground (apply 'color-rgb-to-hex
(color-lab-to-srgb lightness a b)))))
This generates these colors:
rainbow-identifiers-identifier-1
rainbow-identifiers-identifier-2
rainbow-identifiers-identifier-3
rainbow-identifiers-identifier-4
rainbow-identifiers-identifier-5
rainbow-identifiers-identifier-6
rainbow-identifiers-identifier-7
rainbow-identifiers-identifier-8
rainbow-identifiers-identifier-9
rainbow-identifiers-identifier-10
rainbow-identifiers-identifier-11
rainbow-identifiers-identifier-12
rainbow-identifiers-identifier-13
rainbow-identifiers-identifier-14
rainbow-identifiers-identifier-15
Pretty! You can change the color selection by changing the lightness and saturation constants. I'll try this for a while. Update: [2014-05-15] rainbow-identifiers 0.1.3 now has an option for using L*a*b* colors without needing the above code. Use (setq rainbow-identifiers-choose-face-function 'rainbow-identifiers-cie-l*a*b*-choose-face)
Edit: [2014-05-18] The original post was about rainbow-identifiers mode; I updated it to also show color-identifiers mode.
Labels: emacs
Building Mac OS X Emacs 24 #
Update: [2014-10-23] After a long wait, Emacs 24.4 is finally out. The binaries for the Yamamoto Mitsuharu version are available from railwaycat. The blog post is updated for Emacs 25.1 release candidate. I have another blog post for Emacs 26 pretest.
I'm a long time Emacs user. When using a Mac, I've been using the builds from emacsformacosx.com. After reading about the new features in 24.4, I tried the Emacs nightly builds, and was mostly happy with them, but I somehow messed up my Emacs package configuration in a way that I can't go back to Emacs 23.3. No big deal, right? So I waited for the 24.3.90 pretest to go back to a somewhat "stable" version, and that just came out last week.
The problem is that the emacs 24.3.90 pretest from emacsformacosx.com is triggering a runaway distnoted process on my system, and is also running rather slowly. There are some patches floating around there, but I'd have to build from source. I've also been curious about the Yamamoto Mitsuharu version of Emacs; see this list of features. If I'm going to build from source, I might as well try his version, right?
Bluetooth tooth #
People sometimes get tooth implants to replace missing or decayed teeth. Currently they're milled or 3d printed. But I think we could do much more. Why not put bluetooth into your tooth? We'd get:
- Speaker so that you could listen to tunes streamed from your phone.
- Microphone attached to the bone so that you could make phone calls without nearby people overhearing what you say.
- Sensors to measure and report the status of your mouth. Real time graphs of saliva, food, and dental bacteria can be sent to your phone, like a Fitbit for your mouth.
It'll finally turn the "tooth fillings pick up radio signals" myth into reality. Would you get one? I would!
[Update 2025-02-03] Found this announcement from 2008
Labels: future