Skip navigation

Emacs tip: bulk operations on buffers

When I use Emacs for my work, I usually have dozens of buffers open: every file I edited, plus different consoles, process outputs etc. Emacs allows to handle this volume easily because it doesn’t have stupid tabs which I need to scroll and click, but instead every buffer is accessible by entering a couple of chars from its name.

The main problem I encountered is that when I’m working simultaneously on several versions of the same project, I’m starting to have many similarly named buffers. I already set up uniquify plugin to have file names prepended with directory names, but the risk of changing a file from other version of project is still high.

The obvious solution to get rid of unneeded buffers is to close Emacs and open again, but for Emacs this is analogous to OS reboot—ideally, you don’t need this. The better solution is to close all files that were opened from a specific directory. What is the easiest way to do this? As I’ve learned from Emacs wiki, the Ibuffer plugin offers a great interface for such operations.

So, how I delete all buffers that has files opened from a particular location? First, I’m opening Ibuffer:

M-x ibuffer-list-buffers

A fancy colored table of buffers is shown. Now I’m marking buffers having a filename to satisfy a specified regular expression criteria: % f and then pressing D to delete them. That’s all!

dbext.vim cheat sheet

I’ve created a cheat sheet for dbext Vim plugin. Hope somebody may find it useful.
About dbext:

While editing your SQL (and without leaving Vim) you can execute database commands, run queries, display results, and view database objects. dbext understands various programming languages, and can parse and prompt the user for [host] variables and execute the resulting statement. See below for more details.

dbext-screenshot3
Download.

Today I had this nice idea…

I wanted to implement some simple persistence support for my objects that probably contain at most 5-7 fields and the total number of objects would be at most 20-30. I didn’t want to put database and ORM in place for such a small task.

So I thought I’m going to develop something like:


#persons.properties
name = John
lastName = Smith
age = 28

Where I can:


PropertiesX properties = new PropertiesX().load("persons.properties");
Person person = properties.mapTo(Person.class);

My Person class:


@PropertyObject
public class Person {
	private String name;
	private String lastName;
	private int age;

	@PropertyMethod
	public void setName(@Property(key="name") String name) {
		this.name = name;
	}
	......
}

Or if I want to get all objects I would do something like:


#persons.properties

# all person's ids
persons = 0, 1, 2

person.0.name = James
person.0.lastName = Smith
person.0.age = 28

person.1.name = John
person.1.lastName = Smith
person.1.age = 23

person.2.name = Joe
person.2.lastName = Doe
person.2.age = 34

And java code would look like


// where second argument is the property prefix and the third is the array of person ids from the property file.
Person[] persons = properties.mapToArray(Person.class, "person", "persons");

//or I could do something like the following where ids is arbitrary list of ids :
Person[] persons = properties.mapToArray(Person.class, "person", ids);

Then I realized that property file with 30 objects might look a kind of ugly and googled for “Java JSON”.
And then I lost fun I was going to have for today. I found this – a simple library to serialize objects to Xml or JSON and back again.

Fun with parentheses

Oh… I almost forgot what fun it is to learn functional programming. During one of the semesters in university, we took “Functional programming” course. It was a new world of something that I hadn’t seen before, so unusual, so charming.

That new world of lists and operations on them was something “weird” because it wasn’t similar to what I had known before. After that semester in the university I almost haven’t touched Lisp nor any other function language until recently.

The subject of functional programming appeared few times on my horizon a couple of weeks ago. I decided to recap what I knew almost ten years ago and learn something new.

If you want to quickly grasp what functional programming is I would recommend “The little Schemer”.
This book is only about two hundred pages which is good and has lots’ of blank space. :) However it is very valuable book, written in an interesting way of questions on the left side of a page and answers on the right. The book is full of small tasks that you solve as you read and if you can’t don’t worry there is an answer on the next page. That’s a fun book indeed.

 

For those who has read “The little Schemer” there are “The Seasoned Schemer” and “The Reasoned Schemer” which I haven’t done yet. These books give more insight into the language and cover more advanced topics. They are written in the same manner of series of questions and answers which I have much fun with solving as I’m reading first book. I’m sure I’m going to get these books soon.

 

The last one that I’d like to mention is a book that available online, and I would say, the most robust book about functional programming and Scheme, I know of is “Structure and Interpretation of Computer Programs”.

It teaches not so Scheme language but programming itself using Scheme as a language to express “pure” ideas.

“The Structure and Interpretation of Computer Programs” is the entry-level subject in computer science at the Massachusetts Institute of Technology. It is required of all students at MIT who major in electrical engineering or in computer science, as one-fourth of the “common core curriculum,” which also includes two subjects on circuits and linear systems and a subject on the design of digital systems. We have been involved in the development of this subject since 1978, and we have taught this material in its present form since the fall of 1980 to between 600 and 700 students each year. Most of these students have had little or no prior formal training in computation, although many have played with computers a bit and a few have had extensive programming or hardware-design experience.

If you already know a couple of object oriented programming languages and would like to learn something new I would suggest to learn one of Lisp’s dialects. It’s mind opening experience and it’s fun. :)

Thanks to Mikhail for pointing out those books to me.

Movies about software developers and entrepreneurs, Pt. 2

Preface

Watching how the current economy crises brings the NASDAQ down (it is fluctuating around 1550 as I write these words), the Dot-com bubble crises comes to mind. We have a good opportunity to look back on these times by watching movies about dot-com start-ups. In my bucket I’ve got these: the recently released fiction movie August, and two dot-com-times documentaries: e-Dreams and Startup.com.

August

Fiction pseudo-documentary movies always have a drawback of over-emphasizing presentation side and blowing out facts. August is no exception. Here we have glamorous interiors of a Landshark “web-something” company packed with funny-looking Macs of 2001, over-emotional actors’ play, and lack of understanding what the heck the Landshark’s business is really about. 

Josh Harnett playing Tom Sterling, the Landshark’s co-founder, tries hard to perform like Tom Cruise playing Steve Jobs, but he really lacks charisma and passion that have both of them. The only rousing moment for me was Tom’s speech on “eSymposium” event where he says the following: “Are we making the world a less sucky place or more sucky? How do we every day impacting the suckage?” By the way, a good question for everybody in the IT industry to ask themselves.

Two things that are interesting in this movie besides the speech. First: it emphasizes the difference in a behavior of founders and employees in company’s hard times. Founders are struggling, employees are thinking about an escape. Second: relatives and family comprise an essential part of entrepreneurs and developers life. This point is often missing in blogs, which speak more about technologies and “cool stuff”.

e-Dreams

This is a documentary, so here the company’s business model is explained clearly. Kozmo.com performs a 1-hour delivery of books, CDs, etc. after a purchase in an Internet-shop. The coolness of the idea flows down from founders onto all employees and drives them up. This helps the company to gain a momentum and spin up.

As a programmer, I found really boring that the whole movie is about money. The only justification for this is that Kozmo.com really raised lots of money — more than $250 million, and it’s even without an IPO!

Also, the movie lacks material about families or private life of co-founders. We only see the mother of Joseph Park (co-founder) telling how proud she is of her son. But the theme of founders vs. employees is traced in e-Dreams maybe even better than in August. When the company perceives problems with cash, interviews with delivery bikers are interleaved with shootings of top-management meeting. This a really embarrassing moment.

Startup.com

Had I to advice a single movie to watch, I would choose this one. Startup.com achieves a good balance between being spectacular and delivering facts. Telling the story of govWorks.com startup, it covers all-important problems like searching for investors (as it is observed by one of participants, “VC isn’t a synonym for charity”), work vs. life disbalance in founders’ life, competitors activities, product release, etc.

To some extent, Startup.com movie is a real-world, “proper” version of August. What lacks coverage in the movie is the theme of employees. There’s almost no participation of them on the scene. E.g. close to the govWorks.com collapse, we only see short notes about company’s employees headcount, and they go down from 233 to 50 almost in a blink of an eye.

Conclusion

Personally, I enjoyed watching these movies. If you like startup success stories told by Paul Graham and Joel Spolsky, you can also be interested in watching complementary videos about startup failures.