Archive for the ‘Software’ Category

Printing the binary value of an integer

Posted on May 13th, 2008 in Computer Science, Software | Comments Off

You can printf an integer in many forms, including decimal, octal or hexadecimal. What about binary? This is not the first time someone asks me this, so I’ll just post it here:

>  ./dec2bin 3
3 -> 00000000000000000000000000000011
>  ./dec2bin 4
4 -> 00000000000000000000000000000100
>  ./dec2bin 5
5 -> 00000000000000000000000000000101
>  ./dec2bin 6
6 -> 00000000000000000000000000000110
>  ./dec2bin 7
7 -> 00000000000000000000000000000111

A simple solution could be the function below, note that it is limited to 32 bits:

static char *dec2bin(int dec)
{
        char *str, *ret;
        int i;
        const int bits = 32;
 
        ret = str = malloc(bits);
        memset(str, '0', bits);
 
        for (i = bits-1; i >= 0; i--) {
                if (dec % 2 == 1)
                        str[i] = '1';
 
                dec /= 2;
        }
 
        str[bits] = '\0';
 
        return ret;
}

If you enjoyed this post, make sure you subscribe to my RSS feed!

Openning big files in OpenOffice Spreadsheet

Posted on May 12th, 2008 in Software | Comments Off

When your files are too big, OpenOffice Spreadsheet will ignore anything after line 65536, my suggestion is, split it in other tabs:

marcelo@yogananda:~/Desktop$ wc -l foo-2008-04.csv
73538 foo-2008-04.csv
marcelo@yogananda:~/Desktop$ split foo-2008-04.csv -l 37000 foo
marcelo@yogananda:~/Desktop$ ls foo*
foo-2008-04.csv  fooaa  fooab
marcelo@yogananda:~/Desktop$ wc -l fooa*
  37000 fooaa
  36538 fooab
  73538 total

After this, Insert -> Sheet From File…

If you enjoyed this post, make sure you subscribe to my RSS feed!

Problems to solve with software

Posted on May 5th, 2008 in Software | Comments Off

My uncle is a person that likes to use technology, he has always the newest computer, television, sound system, etc. I suppose that he has a good camera also, since I’ve just received by email five photos from him, the only problem is that each picture has almost 12MB.

Naturally he will share his images with friends and family, the expected result is for everyone to see the images, so it doesn’t need to be that big, as a user of technology he doesn’t need to know that.

We see a clear situation where hardware evolves much faster then software, we have a family of products that interacts with pictures, in this example email clients, and it yet doesn’t answer this problem. The correct behavior could be this email client understanding the profile of the user/place/recipients to identify the best size for these images and resize them.

Of course size is just a matter of time and location, in Japan where most of the population has very fast broadband internet connection, acceptable average size will be much higher then Afghanistan, where technology takes longer to arrive [today].

And if you think longer, you’ll see that you might have dozen devices on different connections, so what would be the correct behavior if I’ll check this email on my cell phone over 3G?

Will software ever evolve fast enough?

If you enjoyed this post, make sure you subscribe to my RSS feed!

Linux 0.01

Posted on May 4th, 2008 in Software | Comments Off

marcelo@yogananda:~/Desktop/storage/projects/linux-0.01$ ls
boot  fs  include  init  kernel  lib  Makefile  mm  tools
 
marcelo@yogananda:~/Desktop/storage/projects/linux-0.01$ du -sh .
512K    .
marcelo@yogananda:~/Desktop/storage/projects/linux-0.01$ ls *
Makefile
 
boot:
boot.s  head.s
 
fs:
bitmap.c     buffer.c    exec.c   file_dev.c    inode.c  Makefile  open.c  read_write.c  super.c     tty_ioctl.c
block_dev.c  char_dev.c  fcntl.c  file_table.c  ioctl.c  namei.c   pipe.c  stat.c        truncate.c
 
include:
a.out.h  asm  const.h  ctype.h  errno.h  fcntl.h  linux  signal.h  stdarg.h  stddef.h  string.h  sys  termios.h  time.h  unistd.h  utime.h
 
init:
main.c
 
kernel:
asm.s      exit.c  hd.c        Makefile  panic.c   rs_io.s  serial.c  system_call.s  tty_io.c
console.c  fork.c  keyboard.s  mktime.c  printk.c  sched.c  sys.c     traps.c        vsprintf.c
 
lib:
close.c  ctype.c  dup.c  errno.c  execve.c  _exit.c  Makefile  open.c  setsid.c  string.c  wait.c  write.c
 
mm:
Makefile  memory.c  page.s
 
tools:
build.c

Few years later:

marcelo@yogananda:~/Desktop/storage/projects/linux-2.6.25$ du -sh .
340M    .

If you enjoyed this post, make sure you subscribe to my RSS feed!

Essential Linux Device Drivers

Posted on May 2nd, 2008 in Computer Science, Software | Comments Off

I was searching around amazon to see new titles and for my surprise there was this brand new book, Essential Linux Device Drivers, dated April/2008, ~750 pages, like my older post, Linux Kernel Development, and my suggestion never posted, Linux Device Drivers, will give you the best tools around to understand and work in Linux, now continuing with the description:

“Probably the most wide ranging and complete Linux device driver book I’ve read.”
Alan Cox, Linux Guru and Key Kernel Developer

“Very comprehensive and detailed, covering almost every single Linux device driver type.”
Theodore Ts’o, First Linux Kernel Developer in North America and Chief Platform Strategist of the Linux Foundation

Read the rest of this entry »

If you enjoyed this post, make sure you subscribe to my RSS feed!

Emacs is sleeping

Posted on April 30th, 2008 in Software | Comments Off

Steve Yegge posted yesterday a book in his blog, XEmacs is Dead. Long Live XEmacs! Ok, it’s not a book - but looks like -, it’s a very interesting article and we share many ideas.

I don’t know how to define it right now, but long time ago, Emacs was my favorite software, I used it for almost everything besides editing files, mail, news, shell, scripting, web browser, irc, calendar, contacts, etc. I even started writing a book about it five years ago, I wanted to finish it a while back, but I got an access denied from my editor, of course.

It doesn’t interests people anymore, Emacs has unbelievable potential, we’re late, very late, but nothing blocks us from getting back in shape, a lot of work has to be done, barriers to be broken, but people need to be creative and reinvent it.

I use it everyday of my life, it’s my favorite editor and I really hope someone do something, but honestly, Emacs is getting old, lazy and fat.

If you enjoyed this post, make sure you subscribe to my RSS feed!

Interview with Donald Knuth

Posted on April 26th, 2008 in Computer Science, Software | Comments Off

Andrew Binstock and Donald Knuth converse on the success of open source, the problem with multicore architecture, the disappointing lack of interest in literate programming, the menace of reusable code, and that urban legend about winning a programming contest with a single compilation.

Andrew Binstock: You are one of the fathers of the open-source revolution, even if you aren’t widely heralded as such. You previously have stated that you released TeX as open source because of the problem of proprietary implementations at the time, and to invite corrections to the code—both of which are key drivers for open-source projects today. Have you been surprised by the success of open source since that time?

Donald Knuth: The success of open source code is perhaps the only thing in the computer field that hasn’t surprised me during the past several decades. But it still hasn’t reached its full potential; I believe that open-source programs will begin to be completely dominant as the economy moves more and more from products towards services, and as more and more volunteers arise to improve the code.

For example, open-source code can produce thousands of binaries, tuned perfectly to the configurations of individual users, whereas commercial software usually will exist in only a few versions. A generic binary executable file must include things like inefficient “sync” instructions that are totally inappropriate for many installations; such wastage goes away when the source code is highly configurable. This should be a huge win for open source.

Yet I think that a few programs, such as Adobe Photoshop, will always be superior to competitors like the Gimp—for some reason, I really don’t know why! I’m quite willing to pay good money for really good software, if I believe that it has been produced by the best programmers.

Remember, though, that my opinion on economic questions is highly suspect, since I’m just an educator and scientist. I understand almost nothing about the marketplace.

Read the rest of this entry »

If you enjoyed this post, make sure you subscribe to my RSS feed!

Re: PCI MAINTAINER change

Posted on April 21st, 2008 in Entertainment, Software | Comments Off

From the LKML:

* Linus Torvalds <torvalds@linux-foundation.org> wrote:
 
> On Mon, 21 Apr 2008, Jesse Barnes wrote:
>
> And now I get to figure out just how much trouble I've gotten myself into...
 
Mwhahahaaa! Sucker. You'll find out.

If you enjoyed this post, make sure you subscribe to my RSS feed!

New baby

Posted on April 16th, 2008 in Business, Computer Science, Hardware, Software | Comments Off

Our new baby is about to born, look how beautiful:

If you enjoyed this post, make sure you subscribe to my RSS feed!

Hacking the Linux 2.6 kernel

Posted on April 15th, 2008 in Software | Comments Off

I was looking for something related to the linux kernel, went to fall in ibm website displaying these two documents, written almost three years ago, introducing some very basic idea of the linux 2.6 kernel, two sets of around 20 pages each, interesting introductory material:

Hacking the Linux 2.6 kernel, Part 1: Getting ready

Hacking the Linux 2.6 kernel, Part 2: Making your first hack

If you enjoyed this post, make sure you subscribe to my RSS feed!