Emacs: find files anywhere, updated for 2017 #
Back in 2016 I posted my emacs setup for finding files globally. It unifies find-file and switch-to-buffer, and also lets me find files without switching folders. I've been improving it since then and wanted to post an update.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjM5dg0tnaxvSWZZdNoInYnDcWTwemJepgsAeQ45cLDfa7gpjiTwV7dqU3gplk9LMDqIZ-KqyIJebxn9SDyUrGwvv-iikxNciaOpelLfv0jBwxxRsvTvU3SW2YDwFx8VFrF99Jv/s1600/multifolder.png)
The biggest change is speed. I profiled the code and found two bottlenecks in the construction of the global file list. The list is roughly 15000 elements, so I precomputed as much of that as I could, and the startup time went down from 0.8 seconds to 0.1 second. It feels instant now.
PM2.5 to Air Quality Index (AQI) #
I wanted to understand the relationship between particulate matter measurements (PM2.5) and the U.S. air quality index (AQI).
The formula is on wikipedia, defined as a piecewise linear function. But it's weird that the slope isn't monotonic! It starts at 4.2, then drops to 2.1, but goes up to 2.5, then drops to 0.5, then goes up to 1.0, then back down to 0.66. Weird!
(chart made with d3.js)
Also see this article from smartairfilters.com that goes into more detail and also suggests using µg/m³ instead of AQI. The definition of AQI varies across countries! For example, 250 µg/m³ is considered AQI 400 in India but AQI 300 in the U.S.
Labels: health
Building Mac OS X Emacs 26 #
On 11 Oct 2017 Emacs 26.0.90 pretest was released. For Mac, there's a build on emacsformacosx.com. I have been using the "Mac port" from Mitsuharu Yamamoto because it feels smoother and faster on my system, and I decided to try his development branch. Here's what I ran:
brew install gnutls texinfo libxml2 cd ~/Projects/src git clone --branch work --depth 1 https://bitbucket.org/mituharu/emacs-mac.git cd emacs-mac ./autogen.sh export PATH=/usr/local/opt/texinfo/bin/:$PATH export PKG_CONFIG_PATH=/usr/local/opt/libxml2/lib/pkgconfig ./configure --with-mac \ --prefix=/PersonalApplications/Emacs.app/Contents/MacOS \ --enable-mac-app=/PersonalApplications make make install
It runs nicely!
A minor note: the byte-compiled .elc
files compiled under Emacs 26 are not compatible with Emacs 25, so if you go back to an older version, you'll need to recompile the .elc
files.
Panorama to square images for Instagram #
Instagram recently added a feature to post up to 10 photos side by side. I saw someone cleverly used it to post a single panoramic photo. You split the panorama into square photos and then post them all at once to Instagram, which then arranges them side by side. Here's a quick & dirty script I wrote to split up my own panoramas into square photos. It uses a few Mac commands to get the size of the image, and ImageMagick to break up the images into smaller ones:
#!/bin/bash if [ -z "$1" ]; then echo "Usage: $0 filename.jpg" exit fi filename="$1" # Original image size width=$(mdls -raw -name kMDItemPixelWidth "$filename") height=$(mdls -raw -name kMDItemPixelHeight "$filename") # Each of the square pieces will be 1/Nth the width N=$[$width / $height] if [ $N -gt 10 ]; then N=10; fi # maximum 10 allowed by instagram size=$[$width / N] if [ $height -lt $size ]; then size=$height; fi # Use the center of the x,y range x_offset=$[$[$width - $size * N] / 2] y_offset=$[$[$height - $size] / 2] echo "$filename : ${width}x${height}, $N parts" if [ $x_offset -gt 0 ]; then echo "Wide image; truncating $[2 * $x_offset] pixels" else x_offset=0 fi if [ $y_offset -gt 0 ]; then echo "Tall image; truncating $[2 * $y_offset] pixels" else y_offset=0 fi for part in $(seq $[$N - 1] -1 0); do crop="${size}x${size}+$[${x_offset} + ${size}*${part}]+${y_offset}" echo " part $part : $crop" convert "$filename" -crop "$crop" $part.jpg done
I'm sure there are lots of things I could do better but I just wanted to get something working quickly.
Labels: howto
Emacs spaceline mode line #
Back in 2011 I posted my Emacs mode line configuration. At the time I was thinking it'd be nice to have a more modular way to define the mode line. A few weeks ago I rewrote my mode line configuration to use Spaceline, the mode line library used in Spacemacs. I made it match my tabbar:
...