metahacker [entries|archive|friends|userinfo]

[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

Hello, and a place for questions [Jan. 1st, 2037|12:00 am]

So -- you've found my journal. If I know you, hi. If I don't know you, hi -- introduce yourself. Remind me why I might know who you are, or where you bumped into me and my journal -- all comments are screened by default. (You could also just email me directly if you're overly concerned about secrecy.)

Want to leave me a note? Comment here.

General questions? Comment here.

Remember that what I write here I retain the copyright to. In general, I love it when people link to (public) posts, and almost always give permission to repeat elsewhere what I've said here; but I do depend on my words and ideas to earn my pay, so if you want to use my words and ideas to make money, drop me a line first.

Have fun!
Linkpost comment

In my defense the yak looks VERY tidy [Feb. 21st, 2015|08:28 pm]
[Tags|, ]

Just spent near on an hour writing six lines of perl, to do some pokayoke on my writing process.

Less nerdy explanation: My computer will save/stop me from thinking I'm done when I haven't hit "save" in my editor.

More nerdy explanation:

When writing, I use vim. Which is lovely, because vim auto-saves nearly constantly, and in a real file (named something like .foo.swp), which means I've never ever lost data in vim due to a computer crash or a connection hanging.

The problem is, I'll often background vim and do stuff, and then I forget I haven't hit save, and then...

Well, see, I also use git. Because git lets me commit versions of my writing, so I won't lose stuff, and in the 1:100 times when I want to fetch something out of the history, it's there. And I can merge across machines, so I can write "anywhere" and merge it all up later.

So I'll CTRL-Z out of vim, do some stuff, forget it's hanging in the background, do a git add / git commit / git push, and then...oh, hey, hadn't actually hit :w, so those changes aren't in. Or worse, pull a version from elsewhere with that vim session still hanging there. Then, assuming I notice, I have to save-as, and merge. Pain!

Step one was to modify my prompt so it tells me the number of background processes. In magenta, because while this isn't an error state, it's not normal, either. ZSH makes this relatively easy--there's a prompt variable (%j, sensibly enough, for jobs) which counts the number of background jobs, and you can conditionalize so you don't have a false-positive 0:
set prompt=%h %B%F{blue}%m:%~%f%b%(1j| %F{magenta}<%j>%f|)%#
(I underlined the relevant part; the rest is just my normal crowded prompt.) This means I see something like this when I have a few background processes:
134 panacea:~/Documents/text/fiction/seekritstory <2>%

when I type.

Fine. But...that's just a warning. How about preventing?

Well, it turns out that git, sensibly enough, has hooks--scripts that run when you do stuff. In this case I wanted the "pre-commit" hook, which, yay, exists. If you return non-0, it halts the commit.

Obviously the condition for halting is "are there any .*.swp files in my working tree?", but this turns out to be slightly tricky to compute. First, git doesn't flat-out tell you where the working directory is. It turns out you can use git rev-parse --show-toplevel (/obviously/), but...not when you're inside the .git directory, like you are when hooks are executed. Augh! Or you can trust that said .git directory is itself in the top-level, and just execute the find on .., which is what I did.

But find is slow and this is perl. Turns out there's a Find utility. Which...well, its usability isn't great. But hey! someone wrote Find::NoReally::Find, which is actually called Find::Rule, and lets you specify things in a more sensible fashion (basically file()->name(whatever)->in(directory)). Yay!

So yay, now we have a list of swap files, or an empty set, and can warn.

Except it's hard to see and looks sort of like the "yay we committed" message you get when things succeeded. Oops. Time for judicious use of color.

Err, I forget the escape characters. Grr.

Oh, wait! There's that ANSIColor thing. Right.
use Term::ANSIColor qw(:constants);
Neat. Now I can just say
print WHITE ON_RED "Error! Swap files open!"
and it'll say
Error! Swap files open!

That's nice and hard to miss. And print out the names of the swap files, while we're at it, case.

Problem solved, and gosh, this yak sure does look nice.
Link5 comments|post comment

A decent primer on what people mistakenly think I do at work [Feb. 16th, 2015|03:22 pm]
Link2 comments|post comment

Sancho, hand me my gat [Feb. 15th, 2015|04:52 pm]
[Tags|, ]


A good man, pushed too far by the world's wickedness, decides takes up arms.
A woman of questionable virtue. She doesn't need saving, but he's going to try.
A lone knight, in a futile battle against the underbelly of society, armed only with his fists and his dogged determination.

...Is Don Quixote the first Noir flick?
Link4 comments|post comment

Wednesday[1] poll: Arthurian! [Feb. 13th, 2015|08:00 pm]
[Tags|, ]

I'm interested to see how knowledgeable my friends are about the various King Arthur legends, at this moment in time. I actually took a class(!) on Arthurian Legend in college, and it's always been a side interest, and I forget everyone doesn't know stuff.

As usual, please don't go and look these questions up before answering; that defeats the purpose.

fun poll is fun! also, footnotesCollapse )
Link11 comments|post comment

"The dumbest idea in the world" [Feb. 7th, 2015|02:49 pm]
Salesforce CEO Slams 'The World's Dumbest Idea': Maximizing Shareholder Value
Link2 comments|post comment

Twelfth Annual Arisia Poll! [Jan. 11th, 2015|06:52 pm]
Poll #1995108 Arisia poll 2015

Will you be at Arisia?

Link4 comments|post comment

Time and tide [Jan. 2nd, 2015|02:46 pm]

Today I found out my 13" laptop* has less battery capacity than my iPad Mini**.


I guess that's why it runs down after only a little while?

(* design capacity: 5770 mAh, current capacity: 4500 mAh after ~700 cycles)
(** design capacity: 6471 mAh, current capacity probably ~90% of that)
Linkpost comment

(no subject) [Dec. 29th, 2014|09:59 am]
Link2 comments|post comment

Dose of culture [Dec. 25th, 2014|07:27 am]
[Tags|, ]

New addictions: Trevor Noah, and W. Kamau Bell's "Totally Biased"...

I stumbled on Trevor Noah a few months ago looking for spoken Xhosa, and his career is really taking off might have seen the below Daily Show clip.

The Daily Show -- Spot the Africa with Trevor Noah
Trevor Noah: Crazy Normal (full 1h30m show)

Then a junction point:
Totally Biased: Kamau Talks to Trevor Noah
The Most Racist Things of All Time
Anything You Want to Say to a White Guy?

Back in the mid-90s, I used to work up around 125th Street not far from where that last video was shot; it'd be interesting to see how local reactions have changed. I feel like we're more racist now than we were in those days.
Linkpost comment

[ viewing | most recent entries ]
[ go | earlier ]