A couple of counting functions

I had a strict character limit of 180 chars for something I was writing. I just wrote a simple function to count characters in a region or a buffer. Another function to count the words.

(defun count-chars ()
  "Count the number of chars in a buffer or region."
  (interactive)
  (let* ((beg (if (region-active-p) (region-beginning) (point-min)))
	 (end (if (region-active-p) (region-end) (point-max))))
	 (message (number-to-string (- end beg)))))
(defun count-words ()
  "Count the number of words in a buffer or region."
  (interactive)
  (let* ((beg (if (region-active-p) (region-beginning) (point-min)))
	 (end (if (region-active-p) (region-end) (point-max)))
	 (count 0))
    (save-excursion
      (goto-char beg)
      (while (< (point) end)
	(forward-word)
	(setq count (1+ count))))
    (message (int-to-string count))))

Asking vs. Figuring out

Should one take the easy route of asking someone who knows, if she is sitting right next to you? Or should we try and find out first, before asking her? Should one value his time more than others' or others' time more than his own?

Would we learn more if we tried to find out ourselves? Does learning more, make sense? Is it worth spending the extra time?

I'm just talking of simple things that you could figure out by spending a couple of minutes of searching the web or 5 minutes of thinking or 10 minutes of reading a book.

A GNU and a friend

I now have a GNU! I bought it (a GNU soft toy) in memory of my friend swathanthran from #emacs-in. RIP swathanthran

As a bonus, I got the chance to have a photograph with just RMS and me. Also, hoping the monetary contribution will be of some use to FSF-India.

The thrill of getting the GNU (and the GNU itself) and shaking hands, getting photographed with RMS is dedicated to all the lafoots and specially to Voodoo, who taught me the meaning of the word "hacker".

Happy Hacking!

ps: I just hope and pray nobody else does anything as stupid and shocking as what swathanthran did.

Happy Teachers' Day!

Well, it turned out to be not so Happy. I came to know of this sad news. A prof published his students' work as his own, with no mention of their names! This guy is such a shame to his profession! Shame!

I wonder how this guy has even been able to sleep every night. Isn't there something called a conscience?

Richard Stallman in IIT-Bombay

RMS will be in IIT-Bombay on the 6th of this month. He will "speak about the goals and philosophy of the Free Software Movement, and the status and history of the GNU operating system, which in combination with the kernel Linux is now used by tens of millions of users world-wide. "

  • Date: 6th September, 2010
  • Time: 8:30 P.M
  • Venue: PC Saxena Auditorium, IIT Bombay

org2blog on the web

Well, it's been a week of lull on my blog. Not that I'm very busy. But, just didn't have anything to post. I was feeling jobless today and searched the web for org2blog users. Here is what I found.

  • This is a test post from org2blog
  • Posting from emacs and org-mode
  • Vim vs Emacs, or why it really doesn’t matter
  • Posting subtree from org-mode buffer (take 2)
  • Here’s a test post to wordpress for Org2blog – an Emacs plugin
  • Primeiro post usando org2blog
  • Emacs中绘图- ditaa篇
  • org2blog on identi.ca
  • Marcel van der Boom – StatusNet

First 100!

We, Ritesh and I, finished our first 100+km ride – approximately 110km. Yo!

The Route map

IIT-Bombay to Karnala Bird Sanctuary, and back.

Up

Down

The Story

We started at around 0720 and were hoping to reach Karnala Bird Sanctuary by around 1130. We — actually, soot covered clones of us — reached by about 1215 or so. That's pretty decent, considering we were directed to Karnala sports complex, when we were looking for bird sanctuary and there was quite a bit of traffic near Panvel.

While we were getting tickets to get into the sanctuary, a man was amused by Ritesh's polka (dirt) dotted shirt and asks us whether we rode down from JNPT. We got all excited and told him, that we rode down from Powai! He just said, "Gone Mad!" and walked away, as if madness was contagious. Both of us, felt great! We were high! It felt like the best compliment to get after a long, tiring, (blackening) ride. We got in and rushed to a tap and almost had a bath under it. The first touch of cold water was heaven! Just a while later, we got a shock. We couldn't get any food near/inside the sanctuary. We will have to go back 3 km for that. We spent about an hour and a half, getting some oxygen, looking for a few birds, giving up and settling with spiders and clicking some pictures. We got went back 3km to the hotel and spent about an hour there (not all of it eating ;). We started back at around 1515.

The ride back was eventful. We took a slightly different route, tempted by a free Highway(NH4), waiting to be rode on. The road looked awesome, with a hill on the left, and no vehicles in sight. But, as fate would have it, Ritesh's rear tyre gave way. After some search we found a guy fixing tyres of vehicles on the highway. But he refused to fix our bicycle. He refused even to fill air in it, so we could reach the nearest cycle repair shop. After more search, we found who agreed to fill air in the tyre. (It needs a special valve pin. The previous guy, probably didn't have it. But we could've hacked up something.)

We rushed to Kalamboli and got the tyre fixed. Then we headed back in the route that we had come on. It'd been raining on and off through out the morning. But first rain on the return only started near Nerul. It was a great relief. My cycle started moving more smoothly… I loved it. We got lost a bit near Ghatkopar. Also, the traffic was quite bad there. (Why do drivers get so bad, once it starts raining? It's not unique to Mumbai, but quite visible here. We were back in Campus by around 2040.

Ritesh was energized after the puncture was fixed. He rode like crazy, after that. The sole of my feet started hurting — something like a cramp. I don't know what exactly happened. Also, my groin was hurting quite a bit. My only motivation at that point was seeing Ritesh ride like crazy. He was at his best, then! I'm still wondering where he got all that energy from. It was a great ride, for both of us! Motivating each other to keep going. :)

Ritesh, where to next?

Some lessons for future

  • The Cycle needs to be as close to perfect, as it possibly can be.
  • Carry your route map along. Enquiring the route a colossal waste of time and sometimes unreliable, too.
  • A pollution mask is a must for Mumbai (or any other city.)
  • Carry enough water and food. (We drank about 7L of water between us)
  • Need to learn how to fix punctures. Need a tool kit.
  • A helmet, shorts with padding would be good.
  • An odometer would be useful too.
  • Learn to use the hand-pump or carry along a normal pump.
  • I should probably ride along with some Cycling group for the experience of it. I'll get to learn a lot of things.

Photos

Photos will come soon, hopefully.

org/elisp - sorting list of org-links on description

A small utility function that I used to sort the names of people who commented on my blog.

(defun org-get-link-desc-from-list ()
  """ Get link description of a list item containing just links """
  (let* ((item-beg (point))
       (item-end (org-end-of-item))
       (cur-item (buffer-substring-no-properties
		  item-beg item-end)))
    (goto-char item-beg)
    (org-columns-compact-links cur-item)))

sort-lines wasn't good enough for me, since it was sorting alphabetically and it ended up being the sorted order of the urls and not the names. This function, when used with org-sort-entries-or-items gave me what I wanted.

Thanks to benny (on #org-mode), I also learnt the difference between let and let*.

Contributing to FOSS

gora asked for some good links (on ##linux-india) to redirect newbies, enthusiastic about contributing to FOSS.

I dug up a few links from the web - some that I read, when I was starting off with using GNU/Linux and FOSS, others are newer links.

Just making a note of them here; hoping someone would find it useful.

  • How to Become a Hacker - A definitive how-to on becoming a hacker. Answers all the right questions. :)
  • Philosophy of the GNU Project - This is the page, where I started. Thanks to Voodoo for giving me the link to this page. I distinctly remember that day. :) I'm going to pass on this link to any newbie who comes my way, no matter how much bashing I get from other FOSS evangelists.
  • 6 Easy Ways To Get Started Programming Open Source - A neat list giving steps to get started with programming for open source. I like #4. Understanding the social dynamics of the project is an important thing which is often overlooked by newbies.
  • OpenHatch - A community site to help newbies get started with contributing to FOSS. A cool site. Also, here is a story about OpenHatch.
  • Look at the Numbers! - an interesting paper giving quantitative data in support of using FOSS.
  • Ubuntu - Code of Conduct - A nice description of general conduct expected in any of the FOSS communities, not just Ubuntu.

I'd be happy to add any other links that any of you share. Thanks!

One Hundred

The previous post, was the One Hundredth post on this blog. As 9 suggested, I just want to say Yay! and thank my readers!

I'd like to thank all the people who gave me those small nudges to write something down here and hope at least one person has found something useful here.

Thanks to all the people dropping in here, regularly; Bearing with whatever sort of stuff I put up here. :)

Thanks to everybody who took the time to comment here.

  • 9
  • Abhijeet
  • Aditya Sengupta
  • Akash
  • AlexM
  • [Amit Sethi]
  • Anagha
  • arunchaganty
  • [arunvudem]
  • avinashsonee
  • chaitu
  • Cuckoo
  • damodar
  • fangzhzh
  • [Illipi]
  • leezii
  • Madhusudan.C.S
  • neha
  • niku
  • [Phillip Hagge]
  • [priya]
  • rahul
  • ringO
  • Rini
  • Ritesh
  • rohitj
  • Sacha Chua
  • Sandeep
  • [Shantanu]
  • [Srinivas Chaganti]
  • [srujan]
  • Stefan
  • Sumanth
  • Surya
  • सु
  • Swapnil
  • Syam
  • uc
  • Vandith
  • vinaywarrier

Special thanks to niku, Rini, and ntveem for inspiring me with their blogs. [All three of them have moved on to better things than blogging.]