Literate .emacs with org mode!

Entered on [2016-01-03 Sun 12:56]

For a while now, I’d been meaning to convert my .emacs to the exciting, new style using org mode’s literate programming capabilities.

I’d been impressed by the clarity of Sacha Chua’s and, while I haven’t quite hit that level of cleanliness, yet, I feel much better about how mine looks, now. I also started using John Wiegley’s use-package, which I don’t completely understand, yet, but it seems to be a real boon for cleaning up loading and configuring packages.

Even setting up slime, which I use through the quicklisp setup, is easy to load:

(use-package slime
      :load-path "~/quicklisp/slime-helper.el")
Literate .emacs with org mode!

First wikipedia edit!

Entered on [2016-01-03 Sun 12:45]

I was working on my typing practice, today, learning the Colemak layout, and came across a small typo in the Wikipedia article on Morris Engines!

It was a simple typo (form -> from), but I decided that was a level I was comfortable contributing at. I didn’t notice there was a checkbox for minor edits like typos on the submission page, so I fully expect someone to crawl out of the internet and point it out to me.

First wikipedia edit!

Blog Walk Roundup 2015-12-10

I spent a bunch of time collecting things around the web today. I think some of these are worth a read, so I’ll link a bunch here.

Additionally, I participated in my first Massdrop and got my Code WASD Clears keyboard, yesterday. It’s really nice to type on! If you’re interested in playing that game, consider using my referral thing (https://www.massdrop.com/r/D2EFXE), because I like what they’ve done and I’d like a goodie box!

Neat blog comment policies

From Tim Chevalier’s Blog:

If you comment, I have a few requests:

  1. Refrain from phobic or discriminatory speech, or speech that (in the words of s.e. smith) suggests that “people don’t deserve autonomy, dignity, and a place in society.”
  2. Refrain from comments that have the effect of silencing or derailing (see Derailing for Dummies for additional examples).
  3. As a corollary, refrain from questioning the existence of privilege or systematic oppression. There are many resources available online and offline for learning about these issues.
  4. Provide a name or pseudonym that reflects a consistent online presence (as opposed to so-called “throwaway” or “sockpuppet” identities).

Apparently, this is stolen from Christie Koehler’s.

Rust stuff

At work, we’ve been looking at using Go for a rewrite of a major project. I keep trying to dig into it and have been annoyed by a bunch of things. I still think it could be a nice idea, there, but I have this problem where I get strong affinities for things pretty quickly and I’ve gotten pretty interested in Rust as, perhaps, and alternative to Go.

I’ve barely used it yet, but it seems to have nice easy package management, immutable data, a helpful compiler, a type system I can get behind, and whose documentation I can find! For some reason, I feel like it’s been difficult to find good explanation of Go.

In any event, I’ve started working through Rust’s book, after using the emacs setup shared here. This has been a long time coming, because I’ve been hearing about Rust over the years and keep meaning to try it. Reading the blogs above, it turned out that Tim Chevalier worked on Rust, so there was a handy link to a presentation to remind me to check it out!

Both languages are current better than the python 2.7 we use at work, because they both use unicode! Something that should just be standard at this point!

extern crate rand;

use std::io;
use rand::Rng;
use std::cmp::Ordering;

fn main() {
    println!("Guess the number!");

    let secret_number = rand::thread_rng().gen_range(1, 101);

    println!("Please input your guess:");

    loop {
        let mut guess = String::new();

        io::stdin().read_line(&mut guess)
            .ok()
            .expect("Failed to read line");

        let guess: u32 = match guess.trim().parse() {
            Ok(num) => num,
            Err(_) => continue,
        };

        println!("You guessed: {}", guess);

        match guess.cmp(&secret_number) {
            Ordering::Less => println!("Too small!"),
            Ordering::Greater => println!("Too big!"),
            Ordering::Equal => {
                println!("Correct!");
                break;
            }
        }
    }
}
Blog Walk Roundup 2015-12-10

Using Emacs to Study Japanese

Entered on [2015-12-05 Sat 22:02]

Tonight, I took my first steps into the world of emacs lisp!

Last January, when I had more time and energy to devote to studying Japanese, I started wondering about using org mode to help me. I was reading articles from the NHK News Easy website and spending a lot of time going back and forth between that, jisho.org, and emacs (where I was keeping my notes).

If you haven’t used it, already, jisho is a wonderful site that is the best of what you could hope for in an online dictionary. It’s fast, clean, and usually returns the most helpful results without having to fight it too much. I’ve also spent a bunch of time using LEO and, while I appreciate it, it suffers a bit from over design that hurts usability.

Anyway.

I really wanted to find a way to work in emacs with org mode. Maybe just copy articles from the NHK into a study log and then look up words and insert them under the sentence they were from. Last January, I wrote to the makers of jisho and Kim Ahlstrom was nice enough to write back and let me poke around with an API he’d been working on. Today, I spent a few hours learning my first emacs lisp and making a few functions to query it and format some nice defintions for me!

jisho-mode.png

Figure 1: It doesn’t get much more exciting than this!

Starting with a background in Common Lisp was probably pretty helpful, because I was ready to understand the plist‘s and the like that were involved. Some of the json handling was nicer than in Common Lisp, since emacs seems to let keywords be lowercase by default, as are most of the json key names that they’re decoded from. In CL, you need to do a lot of :|property-name| because the reader upcases everything. I also learned that you can modify that behavior and that it is terrifying. I recently had an experience like this, trying to make json access easier for myself:

CL-USER> (readtable-case *readtable*)
:UPCASE
CL-USER> (setf (readtable-case *readtable*) :preserve)
:PRESERVE
CL-USER> :thing
:thing
CL-USER> (print "Hello, world!")
; Evaluation aborted on #<SB-INT:SIMPLE-READER-PACKAGE-ERROR "Package ~A does not exist." {1004729173}>.
CL-USER> (PRINT "Hello, world!")

"Hello, world!"
"Hello, world!"
;; ABORT! ABORT!
CL-USER> (SETF (READTABLE-CASE *READTABLE*) :UPCASE)
:UPCASE
CL-USER> (cl:print "Hello, world!")

"Hello, world!"
"Hello, world!"
CL-USER>

Hopefully, I’ll be able to share this emacs-jsiho integration work, soon, because I think people would like it. I was asked not to make the API public, so I will wait until I have permission to share. I’m excited to have finally dipped a toe into elisp and, hopefully, I’ll have time to refine my code and make it even more useful (like selecting from a list of possible results after searching!) in the meantime, anyway. I was pretty impressed with how easy it was to do API call, parse the JSON and then crawl through it. I have the impression that some parts of elisp are even moldier than CL, but maybe people are making a good effort to modernize it and lower bars.

Using Emacs to Study Japanese

Emacs for Writers and Notmuch

Entered on [2015-11-29 Sun 12:03]

Bored on a Sunday morning and ended up watching Emacs For Writers – a presentation by Jay Dixit, who I’m going to have to look into more, since he seemed like a cool person. It was about how he learned to use org mode to do the work that several word processing programs didn’t quite do. He had a lot of fun customizations in his emacs and I might have to watch it again when I’m bored to work out somee other neat things to change. I think it might also finally be time to put my ~/.emacs.d into git so I can get at it on multiple computers and share the things I find at work/home with myself.

One of the things that flashed by in the video was notmuch, the emacs mail browser. Email is more of a pain in the butt than anything useful, these days, as family and friends use phones to contact me and work primarily uses a chat system, but what the hell, I thought, let’s try doing email in emacs again (I’d previously tried gnus).

I primarily used the guide here, with some tweaks from here. Ended up modifying the latter a bit to gel with the GObject Introspection that might have come into existence after the wiki-page/python module were written. Works fine with it, though.

import gi
gi.require_version('GnomeKeyring', '1.0')
import keyring

def get_password(account):
    return keyring.get_password('offlineimap', account)

It turns out that setting up offlineimap is the bulk of the work and doesn’t run automatically, so I basically would need to automate running it or check my mail manually in a two-step offlineimap -> notmuch workflow? I probably won’t actually continue using it, but we’ll see!

Emacs for Writers and Notmuch

Making a knitting tool

Hey there, friends!  Over the years, I’ve been aspiring to making interseting web apps in Common Lisp.  At the same time, Sarah’s been kniting more and more and I’ve gotten to see some of that world.  Lots of people use Ravelry for posting their work and it’s got a strong community.  I thought it might be interesting to try to make something that formatted knitting patterns in an easy to follow way.  Maybe eventually work up to some sort of markdown extension.  We’ll see where it goes.

A few weeks ago, I stuck an early version up at knttl.co!  I’m sure there are all sorts of little bugs in it.  But it’s fairly pretty and quick and runs on top of PostgreSQL and Common Lisp!  It’s running Eitaro Fukamachi’s woo web server, which is nice and snappy.  It’s ona very low tier DigitalOcean VM and I haven’t configured everything that well for the environment, so it crashes if it gets too much traffic.  While it’s working, though, it’s pretty darn quick.  I wish I had more time/effort available to work on it, but it’s hard to find the motivation after full time programming work during the week.  If you find knttl interesting or useful, though, please let me know!

Making a knitting tool

Exploring the Hudson Valley

Sarah and I took off from work this past week, which I’d been meaning to do for a while now.  You tell yourself you’ll take a break when you finish a project and then it goes on for four months and then you say, ‘enough.’

img_20151016_130932
Looking south over the Hudson from the walkway.

We took a  few days to recover and relax at home, in Queens.  Because sometimes it doesn’t feel like we get to use our home that much.  We didn’t want to just sit around at home for the whole week, though, and Sarah found something that involved the term “vegan brunch,” and I was sold.

Continue reading “Exploring the Hudson Valley”

Exploring the Hudson Valley

Injection

Entered on [2015-07-11 Sat 20:22]

Injection Cover I’ve been doing my work on being a better nerd, lately, and I’ve always wanted to know a bit more about comics. I’ve been reading Saga for a bit (though I’m behind now) and I’ve been trying to find my own stride a bit by looking through the single issues and picking things out. Injection looked like it had a decent balance of things, with some sort of programmer, some sort of wizard, and a smart/crazy professor lady making immediate appearances. I also liked the repeated demands for a sandwich. I think everyone can relate to that. I’ve read the first two, now, and I’m excited to see where the story goes.

It seems to involve the sort of magic that isn’t particularly explained, or isn’t magic. We’ve seen portals to other worlds, but they were locked up in a research institution. Strange flashes in stone circles, leave circling around the angry maybe-wizard. So far, I like that it’s been showing strange, exciting things without explaining much. In visual media, like movies and comics, I think that’s a strong sign that there might be good story telling going on.

Injection