Undoing Git Actions

Git is a wonderful thing and despite its reputation for being really hard to use, is easy to understand and use for the usual cases. The problems occur when you make a mistake and the easy mental model you have of Git doesn’t tell you how to recover.

Over at the GitHub Blog, Joshua Wehner has an excellent post on how to recover from common Git user errors. By “error” he means some action that you wish to undo even though the action itself was legal. Even with a good mental model of how Git works, many of these recoveries are not obvious so it’s well worth your time to read through the post.

It’s valuable enough that I bookmarked it because when I do one of those things, I can never remember how to recover. For example, I learned how to start ignoring some files even though I had already started tracking them. You might think that just adding them to the .gitignore file would do the trick but it doesn’t. It’s easy to fix this problem but it certainly isn’t obvious. Take a look at Wehner’s post to find out how.

Posted in General | Tagged | Leave a comment

Trust Us—We’re Wise

The next time the government asks you to trust in their good and mature judgment, remember this.

Posted in General | Tagged | 1 Comment

Org and Beamer

Presentation software. Windows has Power Point, Apple has Keynote, and Linux has Open Office. Everyone hates presentation software and everyone uses it. If you’re someone who works on multiple platforms, you might have to learn to use two or more of them.

Unless, that is, you’re an Emacs user1. In that case, you can learn how to use Beamer with Org mode and take it with you wherever you go. If you want animated slides with lots of gee whiz features, Beamer probably isn’t for you but if you want to make nice looking slides for a talk or other presentation, it’s easy, portable, and free. You don’t have to worry about the machine that will be projecting the slides since the output is PDF and any PDF projector software will do.

Over at the Worg Site they have a very nice tutorial on generating Beamer slides from Org mode. Even if you don’t know LaTeX or Beamer, you can still generate nice slides directly in Emacs. If you find yourself having to put together slides for a talk, it’s worth taking a look at the tutorial. It’s not too long and afterwards you’ll be able to generate slides on any platform that supports Emacs and LaTeX.

UPDATE: Eric S. Fraga, who authored the Worg tutorial I linked above, writes to point out that there’s a newer tutorial by Suvayu Ali that covers the new(er) exporter.

Footnotes:

1

Or you know LaTeX/TeX sufficiently well to use Beamer directly.

Posted in General | Tagged , , | 2 Comments

I.F. Stone, Call Your Office

Glenn Greenwald has a blistering evisceration of the recent (UK) Sunday Times front page article claiming that the Russians and Chinese have cracked the Top Secret cache of Snowden documents and that MI6 is pulling out their officers to prevent them from being killed. One Home Official official even claimed that Snowden had blood on his hands although the government admits that there is no evidence of anyone being harmed.

I.F. Stone famously said, “All governments are run by liars and nothing they say should be believed.” This appears to be a case in point. The article depends entirely on anonymous British officials without a shred of evidence for their lurid claims.

Although Greenwald’s diatribe is mainly aimed at what he considers journalistic malfeasance, he does describe many of the factual problems with the article. First, Snowden has always insisted that when he left Hong Kong he took no documents with him specifically so that the couldn’t be forced to turn them over to hostile governments. He gave the documents to Greenwald and Laura Poitras but kept no copies for himself.

Then they claim that David Miranda, Greenwald’s spouse, was seized at Heathrow Airport with 58,000 stolen documents after he visited Snowden in Moscow in 2013. The problem is that Miranda hadn’t been in Moscow in 2013 and, in fact, had been stopped at Heathrow after he visited Poitras in Germany.

They also report that Snowden stole 1.7 million documents but even the NSA says that they don’t know how many he took. The 1.7 million figure is an estimate of what he had access to, not what he took.

Greenwald’s article is a fascinating read and well worth your time, especially if you need your eyes opened as to the veracity of what passes for reporting on the Snowden matter.

As they say on those television offers, “But wait; there’s more!” Craig Murray, who has extensive experience in these matters, has an outstanding post on Five Reasons the MI6 Story is a Lie. The most important of these are that the quotes from “knowledgeable sources” use incorrect terminology that a real intelligence officer simply wouldn’t use and that the whole premise of MI6 officers being in danger is simply nonsense. That’s because 99% of such officers operate under diplomatic cover and are well known to the the Russians and Chinese. Furthermore, no officer has been killed by the Russians or Chinese in 50 years.

If you want to read a devastating takedown of the Sunday Times’ article, be sure to read Murray’s piece. It’s terrific.

UPDATE: MI-5 → MI6

Posted in General | Tagged | Leave a comment

Computer Security and the U.S. Government

If you’re interested in security, you really should subscribe to the semiweekly SANS Newsbites newsletter. The subscription is free except for the occasional email notifications of SANS courses and events. Each letter comprises a series of short (typically a paragraph or two) items about security issues.

The lastest edition (v. XVII, n 47) notes1 that in the wake of the OPM breach that exposed the personal information of potentially millions of federal employees, the White House has directed all federal agencies to immediately implement basic security measures such as keeping their patches up to date, using anti-virus products, and checking their logs. Really? This is 2015 and the President of the United States has to tell his agencies to perform the most basic security measures? What does it take to get fired?

One of the Newsbites editors gave the administration credit for doing something but most were incredulous that the government has spent billions of dollars on IT security in the last decade and is still telling its IT departments to do what “a high school freshman studying information security [would] suggest.”

Footnotes:

1

This report is the first item in the newsletter.

Posted in General | Tagged | Leave a comment

A Handy Calc Tip

mxavier has a nifty tip for calc:

It’s hard to put a lot of context into a tweet so let me fill in the blanks. If you’re in the calc buffer, typing【y】 (calc-copy-to-buffer) will copy the top of the stack to the most recently used editing buffer. The documentation clarifies that as

More specifically, this is the most recently used buffer which is displayed in a window and whose name does not begin with ‘*’. If there is no such buffer, this is the most recently used buffer except for Calculator and Calc Trail buffers.

This makes it easy to pop into calc, make some calculations, and then copy the result back to the buffer you were working in. Actually, calc-copy-to-buffer is a bit more flexible. You can read the Yanking into Other Buffers section of the manual to get the details. It’s short and well worth a look.

Posted in General | Tagged , | 2 Comments

Storing and Retrieving Files by Tags

Wilfred Hughes points us to this interesting paper on tag-based file systems. The idea is that rather than storing files in the traditional hierarchical manner, they are stored and retrieved by tags. The idea of tags is quite general and can even include key word searches. If you’re like me, the idea of doing away with hierarchical file systems is unnerving. Still, I find that a great deal of my workflow amounts to exactly that through my use of Org mode.

I file notes, links, and other information in a handful of files and retrieve that data via tags. Org mode makes this easy and natural and I can even do regular expression searches through the same Org mode interface. I’ve become very interested in this approach after hearing and reading about Karl Voit’s work on Memacs.

If you’re interested in this sort of thing, Voit has a research implementation that you can try out. He also has some interesting papers on the system and related ideas. On a smaller scale, there’s Memacs. If you’re on Linux, it looks to be pretty easy to get it going. If, like me, you’re on OS X, it’s going to take more work but looks doable. I’m slowly implementing much of the same capabilities and will probably steal and adapt some of his scrips as I add more data gathering functionality.

Posted in General | Tagged , | Leave a comment

Adding Custom CSS to a WordPress Site

When I first started blogging with WordPress, I needed some custom CSS. Being a WordPress n00b, I simply added it to the theme’s CSS file that controls what the site looks like. Of course, that bad decision came back to bite me in the butt and I moved to using a child theme to separate my custom CSS from the theme’s.

Timo Geusch over at The Lone C++ Coder’s Blog has another way of adding CSS to your site. His method requires the jetpack plugin but is easy to use once you have jetpack installed. Geusch says that he thinks adding a child theme is too heavy duty for what he wanted to do but I didn’t find it any more complicated that what he did. For example, here is my entire child theme

/*
 Theme Name:   Twenty Ten Child
 Theme URI:    http://irreal.org/twentyten-child/
 Description:  Twentyten Child Theme
 Author:       jcs
 Author URI:   http://irreal.org
 Template:     twentyten
 Version:      1.0.0
 Tags:         light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
 Text Domain:  twentyten-child
*/

@import url("../twentyten/style.css");

/* =Theme customization starts here
-------------------------------------------------------------- */
pre {
        font-family: "Courier 10 Pitch", Courier, monospace;
        border: 1pt solid black;
        padding: 3pt;
        background-color: #F0F8FF;
        overflow: auto;
}
.key, kbd {
        border:solid 1px #989898;
        border-radius: 3px;
        background-color: #F4F4F4;
        padding-left: .25ex;
        padding-right: .25ex;
        font-family: monospace;
}
.footpara:nth-child(2) { display: inline; }
.footpara { display: block; }
.footdef  { margin-bottom: 1em; }
#site-title {
        float: left;
        font-size: 60px;
        line-height: 36px;
        margin: 0 0 18px 0;
        width: 700px;
}

Other than the header, it’s just my custom CSS. Exactly like Geusch’s solution.

Whatever method you like best, be sure to use one of them if you want to add some custom CSS. Believe me, you don’t want the pain that messing with the theme’s CSS will bring you.

Posted in General | Tagged , , | Leave a comment

Sacha on Supplying an Argument to a Capture Template Function

Org mode capture templates are more flexible than you might think. You can specify that the entry be stored in a file in a variety of ways. You can, for instance, ask that it be put in a date tree at the proper place. That’s just what you want for something like a journal or other date-based file. You can check the documentation to see the available methods.

The most general method is to supply a function that determines where to place the captured data. One downside of that is that you can’t specify an argument to the function. That’s not fatal, of course, because you can always supply nearly identical functions to different templates that have the argument specified implicitly. Of course, as programmers we find that an objectionable solution.

Happily, Sacha Chua has our backs with a neat hack to supply an argument to a template function. The idea is to pass your argument as a property that gets saved in the template’s plist and then have the function retrieve the argument with plist-get. Check out Chua’s post for the details and an example.

Posted in General | Tagged , | Leave a comment

Writing Mastering Emacs

Mickey Petersen has a really interesting post on the technical details of how he wrote Mastering Emacs. It’s not surprising that he used Emacs, of course, but less obviously he chose reStructedText as his source format. That choice was driven by the fact that he wanted to produce both PDF and ePub output. My first thought was, “Why not use Org?” but Mickey says that Org documents have problems being converted to other formats. I export Org to HTML and LaTeX all the time with no problems at all but I don’t know how the ePub would play. Even Knuth won’t recommend an ePub version of The Art of Computer Programming because he can’t make the output faithful to his intentions.

Many publishers these days require that a book manuscript be delivered in docx format. My thoughts on Word are well known. I would never undertake to write a book—or anything, really—in Word (or any of its unholy siblings) but it does provide one very useful feature: the ability for copy/technical editors to suggest changes in the manuscript, which the author can accept or reject on a per suggestion basis. Mickey shows how to do the same thing with ediff.

As with all of Mickey’s writings, you’re sure to learn a couple of things you didn’t know from his post so it’s worth reading even if you have no interest in writing a book. If you are interested in producing a book, it’s essential reading.

Posted in General | Tagged | 1 Comment