February 25, 2009

Quick Tip: 'Download' YouTube (or like) Videos, Linux only

You watch videos on YouTube, Google videos, and all those FLV powered video sharing portals. You want to download it and save it for your later pleasure. Ofcourse, lots of desktop and online portals are available. Well, if you are on Linux (atleast; don't know about other Unix), you need none.

The video that you are currently viewing is on your Linux in a file: /tmp/FlashFOO (the FOO can be any random string. After the video is completely buffered, you just have to copy the file to your local disk for persistent storage. That is it.

You can watch as many you want and copy them too. Each of the Flash* files have a unique random character string.

February 21, 2009

Linux Kernel 2.6 compilation Guide, User Mode Linux (UML), Ext4 support

When I wrote this guide 3 years ago, it was my first ever attempt at writing articles which I had yearned to start. I had to get bluetooth support on my Linux 2.4 kernel and the easier and better way out was to upgrade to a 2.6 series kernel. Hence the guide. Its still good. Let me know, if otherwise.

Today, I wanted to play around with the Ext4 filesystem and User Mode Linux. Hence I am recompiling a vanilla 2.6.28 kernel, the first time after I had written that article. I am reproducing it here with some modifications and the theme as compilation of a vanilla kernel, rather than the upgradation and spelling corrections specific to User Mode Linux (UML) and ext4.

The idea is to build a 'ext4' and a UML enabled kernel, then some newbie style playing with the UML and 'ext4' filesystem. I am using Debian 5.0 "Lenny" on VirtualBox (I don't have much to loose, that way :-))

Obtaining the kernel source code

Get the latest kernel source code (I am using 2.6.28) and extract it to a directory under your $HOME.



Kernel Configuration


You will need to enable the 'ext4' support under 'Filesystems' and also specify that we are building a UML kernel:

debian:/home/amit/kernel/sources/linux-2.6.28# make depconfig ARCH=um
debian:/home/amit/kernel/sources/linux-2.6.28# make menuconfig ARCH=um

Save the configuration.

Building the Kernel

Once the configuration is over, you can start the build process:

debian:/home/amit/kernel/sources/linux-2.6.28# make linux ARCH=um

After the build process is over, you will have a binary, linux which is the kernel just built for you with UML support.

Booting into UML

Before you can boot, you will need a UML root file system. You can either download one from here or build one yourself, or you may boot your host file system. I am using the root filesystem image for DSL provided in the earlier mentioned link:
./linux ubd0=./DSL-4.4-root_fs
Locating the bottom of the address space ... 0x0
Locating the top of the address space ... 0xc0000000
Core dump limits :
soft - 0
hard - NONE
Checking that ptrace can change system call numbers...OK
Checking syscall emulation patch for ptrace...OK
Checking advanced syscall emulation patch for ptrace...OK
Checking for tmpfs mount on /dev/shm...OK
Checking PROT_EXEC mmap in /dev/shm/...OK
Checking for the skas3 patch in the host:

.
.


and finally you will get a root# prompt. To ensure, that we are really in UML, cat /proc/cpuinfo :

processor : 0
vendor_id : User Mode Linux
model name : UML
mode : skas
host : Linux debian 2.6.26-1-686 #1 SMP Sat Jan 10 18:29:31 UTC 2009 i686
bogomips : 10643.04

Well, we just got started. You might want to try lots of other things. Networking, Jails, blah blah. Visit the UML homepage for more resources. Also, read the UML documentation in the Kernel source tree under Documentation/.

Trying Ext4

We will need to do some extra things to start playing around with 'ext4'.

We will have to: create a new kernel image, make the modules, install them and boot into the new kernel (as mentioned here). Once booted into the new kernel, try out some of the stuffs as in here

I tried one of the alpha releases of Kubuntu 9.04, which supports 'ext4'. It was pretty much blazingly fast.



February 18, 2009

Higher-Order Procedures

Higher-Order procedures is my attempt to introduce the topic in an easy way. Please post your comments/suggestions here. (PDF)

February 2, 2009

Book Review: Programming Groovy

I have zero experience with Groovy before this. However, I am well versed with the Java language and hence this review should be read from the point of view of a Java guy but a Groovy newbie. My goal in reading this book is get acquainted with the Groovy language and keep the knowledge in my sub-conscious mind so that I am ready when I need it :-)

Programming Groovy
is a great starting point to the Groovy language and more so if you are already decently acquainted with Java . The whole book is divided into three parts, each part looking at different features of the language.

Part I: Beginning Groovy

As the name of this part suggests, in this part of the book, the author begins with instructions on how to go about setting up your system for Groovy development. Among other things, working with the Groovy shell is demonstrated.

Being well acquainted with Java, I skimmed over the chapters 2 and 3. Things are very familiar in these chapters. Chapter 4- Dynamic Typing talks about data types in Groovy and some other essential information of typing in Java world and its counterpart in the Groovy world. This chapter also introduces multi-methods. Chapter 5- Using Closures was the first major interesting roadblock for me. I intended to understand it fully and so I read this chapter and worked on it for a couple of times. Co-incidentally, I was also reading about closures in Common Lisp. You will need to understand at-least, what closures are and how they can be used- Sections 5.1-5.3 (as you will later see) that closures are widely used in Groovy. Most of the times, you will be passing a closure around to standard method calls in Groovy. So, understanding how a closure works is very useful. You may also want to read more about closures here. Chapter 6- Working with Strings, introduces the GString ( he he )- which are interpolated strings, and also talks a bit about the GString Lazy Evaluation Problem. Some other topics include: Groovy's own String Convenience Methods, and Multiline Strings. The last chapter in this part- Working with Collections talks about working with the usually available data structures: lists, maps and arrays, alongwith the convenience methods made available by Groovy.

Part I is over and I haven't yet learnt to take a User Input or is it assumed that I am a Java developer?

Part II: Using Groovy

Using Chapter 8: Exploring the GDK, looks at the extensions provided by the GDK to make the JDK more groovy.

In the next three chapters, the author will help you start using Groovy in your daily tasks, like Working with XML files, Databases (GSQL) and mixing and matching Groovy and Java.


Part III: MOPping Groovy

This part of the book looks at the implementation of the Meta-Object Protocol in Groovy and essentially builds upon it to present other very useful concepts such as Unit Testing and Mocking (where you are shown how to write Unit tests for your Java classes in Groovy), Groovy Builders and finally, at Creating DSLs in Groovy. This part can be classified as some serious and advanced Groovy and is a great collection of some very cool concepts in Groovy.


Overall, this book of is a great introduction to Groovy for the Java developer. I am not sure, how non-Java developer would benefit at all from this book, or for that matter Groovy.

Great work by the author and the whole team!

To learn more about the book, errata and discussions, please go to http://www.pragprog.com/titles/vslg/programming-groovy


Many thanks to O'Reilly UG program for providing with a review copy to BOJUG. This review is also published at the BOJUG blog at http://bojug.in/blog/?p=49

February 1, 2009

BOJUG Meet Pictures

We had this month's BOJUG meet yesterday. Some pictures here at the fficial Blog post entry: http://bojug.in/blog/?p=45