Skip to main content

Posts about ology

Augmented assignment in Python

If you are new to Python, you should probably stop reading here. But, if you have used Python and numpy, then read on. Before, that try these bits of code.

import numpy
a = numpy.array([1,2])
a = a + 0.5j
print a

The "same thing", in a slightly different way.

import numpy
a = numpy.array([1,2])
a += 0.5j
print a

Both the code blocks, look really the same, until you look carefully. Under normal circumstances a = a + b and a += b behave exactly similarly, and we really don't need to bother about the differences between them.

But, +=, which is an augmented assignment operator, actually tries to perform the operation in-place, unlike the other statement where + actually returns a new object which is again being referenced by the name a.

But, when dealing with numpy arrays, this will lead to trouble. When assigning to an array, it's dtype is not changed and hence the trouble.

The right way to use the augmented assignment operator, would be:

import numpy
a = numpy.array([1,2], dtype=complex)
a += 0.5j
print a

The same thing is explained in this thread. Also, Thanks to Bhanukiran for asking me this.

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.

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

Vimperator and Firemacs!

For the uninitiated, vimperator is an emacs plugin to get Firefox working with vim keybindings and firemacs 1 is for emacs keybindings.

I'm obsessed with emacs (as should already be evident) and can't really edit text without it's key-bindings. There are others like me, and hence the firemacs plugin. It's a blessing for my tribe.

Firemacs is great, except for the one great feature that it lacks - being able to jump to links/textareas without using the mouse. I've seen Nishanth do it with ease, using Vimperator. I wanted to add this feature to Firemacs, by copying some code from Vimperator to Firemacs. I directly started looking at the code, but couldn't make head or tail of it. I got a few doubts about how Vimperator works, since I'd never used it. Nishanth asked me to simply install it and try it out.

And then we had our EUREKA! moment. Vimperator and Emacs both enabled together work seamlessly well. Two obsessed people are happy and satisfied! And hopefully many more. :D

Footnotes:

1

Key-bindings are a religious thing, in the world of editors!

Sage Days 25, Mumbai, India

What is 'Sage Days'?

Sage Days is a confluence of present and prospective SAGE Users and Developers. It is an opportunity to come together to share ideas, brainstorm and hack on Sage. Sage Days 25 is the 25th version of Sage Days, and is being organized in Mumbai, India. In order to cater to an Indian audience and scenario, this version has been tweaked slightly. Sage Days 25 has beginner level tutorials, in addition to the usual talks and sprints, to help new users get started with Sage and help promote the use of Sage in India.

What is Sage?

Sage is a free, open-source mathematics software system licensed under the GPL. It combines the power of numerous existing open-source packages into a common Python-based interface. It's mission is to create a "viable free open source alternative to Magma, Maple, Mathematica and Matlab". Sage has tools for a broad range of mathematical areas like Linear Algebra, Calculus, Symbolic Math, Plotting, Rings & Groups, Graph Theory, Number Theory and Cryptography. Essentially, "it can do anything from mapping a 12-dimensional object to calculating rainfall patterns under global warming" - as Science Daily puts it . Eager to get started? Start here. Apart from being feature rich, it's usability is one of it's greatest strengths. Sage Notebook, a web-interface for all the math you'll ever want to do, is really the killer feature! As the Sage Marketing page says, "The SAGE GUI surely works on your computer box, because it just runs in Firefox!". Try it Now!

Why should you attend?

Sage Days 25 is being attended by the creator and lead developer of Sage, Prof. William Stein. It will also be attended by other developers of Sage. This would be a great opportunity to meet and interact with them! The conference will be attended by a plethora of enthusiastic people from all over the country who use Sage or are interested in doing so. The conference will also see the presence of many mathematicians interested in software. Who knows, you may run into someone you'd want to collaborate with, for your future work! This event will be a great learning experience, if you are even remotely interested in math and software for it!

When and Where?

  • Venue: IIT-Bombay, Mumbai, India
  • Dates: August 9-12, 2010
  • Tentative Schedule
  • Register Here
  • Click here for more info

talk at GNUnify' 10

Shantanu and I conducted a workshop on Scipy at GNUnify '10. It was intended to be an introduction to Scipy and Numpy through Image processing. We expected an audience which was python literate. But GNUnify's schedule wasn't too favorable for us. Ours was the first talk scheduled and we ended up getting people who only "heard" of Python, the language.

We had planned quite a bit of stuff expecting a python literate audience. But unfortunately, we had to start almost from scratch and couldn't do all of what we planned. Still, the workshop wasn't too bad. Nobody left mid-way during the 2 hour workshop; nobody was dozing either. I would have liked my first talk at a FOSS event to be better, though.

Slides and Images that we used. Shantanu's post on the talk is here.

Monikers and the Internet

Like most bloggers, I keep looking at my blogs hits once in a while. (Sometimes inspires to write better; and more often.) The post that gets most hits these days is my post on mailman, postfix, et al. But the search term that's increasingly bringing people to my blog is "punchagan".

This scares me. What makes people search for me? What makes people search more often these days? Why am I scared?

Why do people use monikers or online identities? I started off with the idea of anonymity and privacy; keeping my online identify separate from my real one. But it, obviously, is a folly to have you email id with the same handle. Now, almost anybody who knows me, also knows my online handle. They can find me anywhere and everywhere with just a few keystrokes (and Google). Also, the uniqueness of my handle doesn't help one bit. Any search returns over 90% relevant results.

Is it time to get lost in the crowd with a new handle? ;) Probably not. I don't have much to hide under the covers. Let the world see – who I am, who I have been; where I am, where I have been.

Peace.

numpy, pacman and me

I'm now officially a part of the Arch Linux community! Arch Linux is a lightweight and flexible Linux® distribution that tries to Keep It Simple.

I have started using arch from less than a week or so. It took me a while, not too long, to realize the beauty of this distro. I was trying to tweak the settings of my org-mode's remember (on Karmic), trying to make it work the way I liked it. After breaking my head with .emacs and lisp for a while, I realized the version of my org-mode was way different from the version of the docs, I was reading. It didn't take long to figure out, which version of org-mode to get. As a matter of curiosity, I checked AUR for the version, and true to Arch's reputation it was bleeding edge! I was still using Karmic, since I hadn't got my Arch installation working the way I like it, yet. Out of laziness. sudo reboot; to hell with laziness!

I was setting up things I regularly use, tweaking my way around. After a day or so, I find python-numpy is out of date. And to top it, an orphaned package! I didn't feel one bit good about this. After some futile attempts to suppress my discomfort, I sat down to work.

After an afternoon of effort, I created my first PKGBUILD. :) I now have python-numpy installed using pacman! Pleasure to join the Arch User Community! Also, thanks to lifeeth and Lynus Vaz, for the sparks.

PS: I'm using Arch with Openbox. It's neat! PPS: org-mode is really awesome! It's a world in itself. life in plain text, truly!]

Stress and us

[Cross-posted on the FOSSEE Blog]

Don't tell me I didn't warn you, if you walk into our lab sometime and mistake it for a game zone in your neighbourhood. You are indeed in "the" lab. If you came looking for Prof. Prabhu you'll have to return. You'll only find PR vowing to see the end of baali, for having a nice time pawning him. You won't find me around - I'm cloaked and busy creating havoc. Unless, of course, you are the seer KD. Watch your step extremely carefully or you won't know when and how fuchmed's GM hit you. And don't dare venture anywhere near madrazr, jumping all around with a shockwave, unless you are capable enjoying some real nasty shocks. Well, the team is busy in one of it's two SB sessions per day. SB (short for Stress Buster) sessions are intense 15 minute rounds of bzflag - 3D first person tank battle game.

Hope you didn't start thinking, I'm just goofing off here, doing nothing at all. If it's not already clear, SB sessions are exactly what they are called - Stress Busters. Just to refresh ourselves and get back to work, with greater force. What then, am I doing for the rest of my time?

Mainly I've been developing course content that we have been working on, called Software Tools, Techniques and Practices. I have been working on a session for elementary LaTeX and basic Linux tools. I've also been attending classes of Digital Control and trying to Python-ize the Matlab/Scilab code that the course uses.

But, that's not all. I've helped a guy restore a Joomla site on Day-1. I screwed up a brand new installation of a server with some real skill; then expect to be screwed but get some encouragement with the words, "It was a good learning experience for us." Seen a Debian server upgrade from Etch to Lenny in under 10 minutes. Installed an instance of twiki and struggled to configure it. Helped a Humanities Scholar with LaTeX. Attended a workshop on Instruction Design. Restored Qmail on an old Fedora 3 server. Goofed around in gimp, for a CD cover and a T-shirt design. Chipped in with bits, for mutating Ubuntu into "LivePython". Did a bit of css and javascript tweaking… The list goes on!

Now, don't you think we deserve the SB's? ;)

Postfix + Mailman for Multiple Domains.

Well, there are a hazaar tutorials on setting up Postfix and Mailman for Debian for a single domain. There were a few for doing that for multiple domains also, but nothing comprehensive, if I could say so. This link is pretty comprehensive and details all the steps for setting up Postfix for a single domain. Here is all you'll want to know about setting up Virtual domains in Postfix.

You only need to make a few changes for adding a second (or more) domain. You just need to add the virtual_alias_domains and add virtual_alias_maps. Here is a glimpse of how my main.cf looks:

myhostname = mail.abc.in
mydomain = abc.in
mydestination = $myhostname, $mydomain, localhost.$mydomain
myorigin = /etc/mailname
virtual_alias_maps =
                hash:/etc/postfix/virtual-xyz,
                hash:/etc/postfix/virtual-abc,
                hash:/var/lib/mailman/data/virtual-mailman
virtual_alias_domains = xyz.in, mail.xyz.in

virtual-xyz and virtual-abc contain the virtual aliases for each domain. Note that Postfix expects hash files and hence you need to run postmap /etc/postfix/virtual-abc each time the file is changed, to keep the hash file in sync with the text file that you edit. Also, you need to run postfix reload, each time you make changes to main.cf or master.cf

Fairly straight forward, right? But it took me quite sometime to get it all right, since this was the first time I was doing anything with Mail Transfer Agents or the like.

Now, onto Mailman. Well the Installation Manual of Mailman, literally has it all. Here is a look at how my mm_cfg.py looks:

DEFAULT_EMAIL_HOST = 'abc.in'
DEFAULT_URL_HOST   = 'mail.abc.in'
add_virtualhost(DEFAULT_URL_HOST, DEFAULT_EMAIL_HOST)
POSTFIX_STYLE_VIRTUAL_DOMAINS=['xyz.in']
add_virtualhost('mail.xyz.in', 'xyz.in')
MTA='Postfix'

The only trouble was to get mailing lists with same names on both the domains (which I couldn't get working). I experimented with multiple mailman instances but that won't work because the MTA can't differentiate between the two instances of mailman. The alternative is probably to have two instances of postfix running too. But that I felt was like going too far, and gave up. [What if we wanted to add another domain to the list?!]

Also, I had to make a few alterations to the Apache file to allow access to the mailman pages without breaking the Zope redirection that was already set-up.

[Thanks to Shantanu and Vattam (and all the hazaar people using Postfix and Mailman and cared to document things for the sake of others, and of course Google)]