Quantum Mechanic

Content from 2015-12

Blog Walk Roundup 2015-12-10

posted on 2015-12-10 13:34:00

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;
}
}
}
}



Using Emacs to Study Japanese

posted on 2015-12-06 03:02:00

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.