This is a simple C program to check memory limit on a server.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char* argv[]) {
  const int KB = 1024; /* bytes */
  const int MB = 1024 * KB; /* bytes */
  const int GB = 1024 * MB; /* bytes */
  long size = 0;
  void *p = NULL;

  int ctr;
  int j;
  int times = 100000;
  long sum = 0;
  for(ctr = 0; ctr < times; ctr ++ ) {
    size = 10 * MB;
    printf("Allocating %zu bytes memory \n", size);
    p = calloc(1, size);
    if(p != NULL) {
      printf("SUCCESS.\n");
      sum += size;

      for(j=0; j<size; j++) {
  ((char*)p)[j] = 1;
      }

      if(sum < GB) {
  printf("Total allocated so far: %ld MB\n", sum/MB);
      } else {
  printf("Total allocated so far: %ld GB\n", sum/GB);
      }
      if(sum > (1*GB) )  break;
    } else {
      printf("FAIL.\n");
      break;
    }
  }
}

Here is how you run it. On a UNIX/Linux machine do the following:

$ make memory
cc     memory.c   -o memory
$ ./memory
Allocating 10485760 bytes memory 
SUCCESS.
Total allocated so far: 10 MB

... OUTPUT SKIPPED...

Allocating 10485760 bytes memory 
SUCCESS.
Total allocated so far: 550 MB
Allocating 10485760 bytes memory 
SUCCESS.
Total allocated so far: 560 MB
Allocating 10485760 bytes memory 
SUCCESS.
Total allocated so far: 570 MB
Allocating 10485760 bytes memory 
SUCCESS.


Yikes! One of your processes (memory, pid 1130) was just killed for excessive resource usage.
Please contact Support for details.


Killed
$ 

Today I attend the inauguration ceremony of MACLUGMaharaja Agrasen College, GNU/Linux Users Group. I was honoured to have been invited among many esteemed guests to light the lamp of this wonderful new beginning. This reminded me how nine years ago I along with a bunch of enthusiasts started JMILUG.

I shared my thoughts on “Freedom – Community – Science – Innovation”

Four Freedoms

Let me begin with the Four Freedoms. A program is free software if the program’s users have the four essential freedoms:

  • The freedom to run the program as you wish, for any purpose (freedom 0).
  • The freedom to study how the program works, and change it so it does your computing as you wish (freedom 1). Access to the source code is a precondition for this.
  • The freedom to redistribute copies so you can help your neighbor (freedom 2).
  • The freedom to distribute copies of your modified versions to others (freedom 3). By doing this you can give the whole community a chance to benefit from your changes. Access to the source code is a precondition for this.

Why are these freedoms important?

It won’t take much to realize how these Four Freedoms are. For example, lets take parallel between Four Freedoms and other things that affect our lives daily. Take note that these freedoms are applicable for more things than just software programs:

  • Science – standing on the shoulder of the giants
  • Literature and entertainment – Comics books turned into Super Hero TV Series and Movies
  • Internet – wouldn’t be possible if Tim Bernes Lee didn’t share his idea and the technology

What if Newton or Einstein and many other scientists didn’t share their theories? There wouldn’t be modern science. What if all the literature was kept secret? There wouldn’t be no entertainment. And list would go on and on.

We must be aware of the freedoms we carry with chores of daily life.

How do we take these freedoms forward?

We can spread the awareness of the Four Freedoms only through a Community. Community is a social unit of any size that shares common values. The people invest with shared capital ( such as belongingness ) and people communicate ( via words, art, emotions etc ) to share their views. Community consists of creators ( or contributors ) and consumers. All of the people have different roles and it better be organic, so that it can thrive based on these parameters:

  • Motivation
  • Passion
  • Goals

We need to ensure a thriving community keeps everyone aware of these freedoms. I am confident that MACLUG students have these qualities, and I wish them good luck.

Welcome to the world of Free and Open Source Software :-).

For references:

I wanted to view all the different chat windows and the buddy list side by side in a single window. There is no such feature in stock Pidgin installation. Fortunately I found a plugin for same from this ticket.

This plugin is available on Github project dm0-/window-merge ( thanks to David Michael / dm0- for creating it ! ).

You can find the build / install instructions on the wiki, however here is how you can do it on Ubuntu 14.04 and other OSes.

First install Pidgin development headers

sudo apt-get install pidgin-dev

Now build the plugin

git clone https://github.com/dm0-/window_merge.git
cd window_merge
mkdir m4
autoreconf -fi
./configure
make install plugindir=~/.purple/plugins

Once it is installed, you have to enable it from Tools -> Plugins, then enable “Window Merge”. Here is a preview of window merge in action:

Enjoy!

In the year 2006, I had created a project as a part of my academics. I finally managed to find the source code and complete project report which I have uploaded to Github. Mainily, I have updated the source code to use cmake build tool. The project documentation is in Asciidoc. Although it is quite an old piece of code, it works:

plyloviz — Phylogenetic Trees Visualization

phyloviz: phyloviz is Phylogenetic Trees Visualization tool. For more details visit Generation and Visualization of Phylogenetic Trees.

Technologies: C, C++, Qt4, ClustalW 1.83, Coin3D, Bioinformatics

I hope it is useful for someone already working in the field of Bioinformatics / Computational Biology.

Everytime I load a heavy application such as Eclipse or Thunderbird, I see this annoying message which keeps repeating even if I press “Wait”.

"Eclipse" is not responding.
You may choose to wait a short while for it to continue or force the application to quit entirely.
[Force Quit] [Wait]

I tried to search for a solution and found that the question is unanswered in both Ubuntu forum as well as Fedora forum.

So I decide to figure out what code is making the popup window appear. It turns out that the function named delete_ping_timeout_func is called whenever a timeout happens. Code with exact line number is present here .

However I didn’t find any code which reads a timeout value from some configuration file. Is there a mechanism using which I can configure the delete window timeout value? Essentially I would like to make the timeout value to about 4 minutes.

As an aside, I see that metacity developers mailing list has not had any post since year 2011. So is it worth asking it on that mailing list?

OAuth2.0 supercedes OAuth1.0 protocol, specifically in making it simpler to use. It supports different workflows as described in its specification RFC-6749. The most concise pictorial representation I found is here.

I created a Play! 2.0 Application in Scala which supports server to server token exchange using OAuth2.0 Protocol. You can find the project source code on GitHub at play-oauth2-server. Its a complete working server codebase, with:

  • Basic User login
  • Client registration with Callback URL
  • Auth Code generation
  • Authentication Token and Refresh Token generation

This application also demonstrates the following:

  • Twitter Bootstrap library using WebJars
  • Typesafe Slick 2 library for database access
  • Scoverage for Scala code coverage
  • and Specification Tests

To play with it, folow project README document. Please report any issues here.

This post is about the talk I was supposed to give at Ruby Camp 2014, Delhi/NCR. After all the preparation, slides and code I missed it. Unfortunately, I fell sick overnight and I couldn’t make it. Apologies for that.

The best I could do is upload all the material online on GitHub and my website.

  • the code is on GitHub at this repository: tuxdna/rubyml.
  • the generated slides are also online here

Thats all!

Lets say you have a bunch of source code files in a project. Whenever you change them, you want some HTML to be generated. After that you go to browser to see how the change looks now. Here is the workflow:

  • Step 1: Change file(s)
  • Step 2: Run a build script to generate HTML
  • Step 3: Open / Reload the page in browser

Well we can automate all the three steps into one using a couple of tools and some scripting magic. We will need a inotify-tools, NetCat nc tool and MozRepl.

Install inotify tools and netcat:

sudo yum install -y inotify-tools nc6

Install MozRepl as described here: Refresh Firefox page from Emacs

Make sure that you have started MozRepl by restarting Firefox. Then Alt+T then Select MozRepl then Start.

Now create a simple script to watch for changes like so:

while inotifywait -r -e modify src/
do
  # put your command here to generate the html from modified files
  make

  # now refresh the browser
  echo "BrowserReload();" | nc localhost 4242  > /dev/null
end

Keep this script running while you make changes to the source code. You can also automate this with other build tools ( such as Maven, SBT etc. ) and editors ( such as Emacs )

References

I was using Chromium Browser on Linux, to see World Cup 2014 videos on YouTube. Some videos were not available in my region because of restrictions by region. If you are also seeng the same message, the you may want to setup a SOCKS proxy, and use that to bypass the YouTube restriction. For this to work, you need an SSH server what is located in some region from where you can access such videos.

Setup Socks v5 proxy:

ssh -CND 1080 user@some-ssh-server.example.net

Start Chromium browser with this proxy by default:

$ chromium-browser --proxy-server="socks5://localhost:1080" --host-resolver-rules="MAP * 0.0.0.0 , EXCLUDE localhost"
ATTENTION: default value of option force_s3tc_enable overridden by environment.

Now you can watch those restricted by region videos.

Enjoy!

References