rpm2cpio [package.rpm] |cpio -dvim
it should extract the archive in the current directory
rpm2cpio [package.rpm] |cpio -dvim
it should extract the archive in the current directory
xbacklight is an useful command to change the brightness of your monitor backlight provided you have a supported driver.
xbacklight -get
to retrieve to get present brightness level in %
xbacklight -set value
to set the brightness to desired value in %
Most of the time I need to login to my linux box in my office from home. The obvious choice is to ssh using putty or cygwin (in case i need some X windows). Normally in cygwin – you will run
ssh -l xyz@yourserver.com ………(1)
to login to your account “xyz” in yourserver.com . This would ask for password and if you provide the correct password you would be able to login to the server.
SSH optionally uses public-key encryption – where a public and private key pair can be used to automate the login process. If you are using cygwin( or in fact any other client running ssh) you can do the following to generate your public and private key pair
ssh-keygen…………………………..(2)
It will prompt for a few input – but you can just press ‘enter’ in all the cases. The keys will be created in $HOME/.ssh/as id_rsa(private key) and id_rsa.pub(public key). Now you can copy the id_rsa.pub to the server -yourserver.com’s ‘xyz’s ~/.ssh/ as ‘authorized_keys’ – and you are done. Try running (1) and you should be able to login without the prompt for password.
In case you are using putty – you can use puttygen to generate the public & private key pair. Then you will do the same step – copy the public key to the desired account’s .ssh/authorized_keys and use the private key to login. There are tutorials that explains this with nice diagrams .
I have been working on mozilla codebase quite sometime. Its a huge codebase with millions of lines of code. A simple counting on the numbers of lines in *.cpp files for 3.0b2 release accounts 1778818 lines of code[1]. Most of the time I need to search for function definitions – I used grep -r xyz * as that was the only option I know until recently I have started using cscope which came as a rescue. cscope maintains its own database of symbol definition of the code. You can find the symbol, find a symbol definition, a file , a text within source code. Configuration of the cscope database is simple.
Step 1 . Make a directory to store the cscope db say $HOME/mycscope/mozilla
Step 2. cd /
Step 3. say $HOME/mozilla is the home directory of the project that contains the source files(*.c,*.cpp,*.h)
run find $HOME/mozilla -name “*.cpp” >> $HOME/mycscope/mozilla/cscope.files
run find $HOME/mozilla -name “*.h” >> $HOME/mycscope/mozilla/cscope.files etc.
It will simply populate the cscope.files used by cscope to create the data with the desired filenames.
Step 4. run in $HOME/mycscope cscope -b -q -k which will create the database cscope.out
Step 5. run cscope -d from $HOME/myscope and start searching and browsing code.
In case you want to invoke it from vim add the following lines to your .vimrc
set nocsverb ; supress cscope logging messages
cscope add $HOME/mycscope/cscope.out
You should be able to invoke cscope from vim window now . eg try :cs find 1 XYZ
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1. sum=0;for i in `find . -name “*.cpp” -exec wc -l {} \; |cut -d ‘ ‘ -f 1` ; do sum=`expr $sum + $i`; done; echo $sum
Just got a chance to attend a seminar on Copyright Vs Community by Richard Stallman
I hope most of you are aware of this guy who pioneered the free software movement .
coined the term GNU is not UNIX , developed the most popular gcc compiler and emacs editors .
Free software movement started in early eighties and by now its just as a dominant
race as the non-free softwares . Freedom is our right and proprietary softwares just
donot respect individual freedom . People are entitled to use only the way developer
design that software – there is no freedom to customize it to their need because the
source codes were not available. Stallman defined four degrees of freedom for a software
to be called a free software -
0 – they should be available freely for use \
1 – source code should be available for customized by the user
2 – user can distribute the custom software freely
3 – user can make as many copy of the software as he wants freely .
After this brief introduction he moved to the constraints that hinders the freedom of the users
Here comes the theme of the lecture . He mentioned how the copyright laws came into existence and how they
are helping the corporates to make money and comprising on the freedom of individual in a democratic society.
Example ranging from books to digital music got mention in his talk .
One example that worth mentioning is the music CDs prepared by Sony . Sony hides a copyright management
software in their music disks that runs automatically and and modifies some of the system parameters permanently so that
the software remains hidden from the user and prevent user from making copy of the music.
This caused a permanent security loophole in the system and computers became vulnerable to attacks.
Sony was finally forced to recall million of its CDs .
I personally feel that copyright should be there – but I believe this should not be the same way as they
are today . And when it comes to different category of copyright able subjects they
should be treated differently.He mentioned some innovative way publishers are making money
without sharing much of the revenue with the author or the composer. Stallman mentioned that books , musics
etc are subjected to a limited copyright. In case of softwares , he insisted that their non commercial use
should be free and the above four freedom should exists in the software world to help maintaining a democratic society.
He finally urge everyone to stand against the wave and support the freedom of software .
If you would like to participate in the movement here is a good point to start .
For those who are writing codes in C/C++ using Vim should find this .vimrc configuration file useful . The script should be self explanatory . If you have any question, I will try to answer. or :help should help you out. Put the following lines to your .vimrc and save .
set incsearch “when you start searching ESC /[string] it will start matching as soon as you type
set scrolloff=3 ” there would be atleast 3 lines from the top/bottom of the screen as you edit
set wildmode=longest,list ” ESC :![filename] TAB should give you a list of matched files
set ts=2 ” TAB would be of two char length
set expandtab “expand TAB char to spaces
set ai ” set auto indent
set cindent shiftwidth=4 “enable C style indent
set ignorecase
set smartcase ” together they help you search string ignoring case if you type in lower case
colo evening ” if you like a colorful editing experience
Many people do not like Vista for a lot of reasons. I personally donot like it because I can no longer use my favorite softwares that runs in XP due to compatibility issues. Initially I thought I would just install Windows XP over Vista. But again I had some issues with the drivers for my laptops – they are just made for Vista it seems. Finally I found a turnaround.
Microsoft thankfully provides a virtual desktop environment called Virtual PC. You can use it as a virtual machine in most of the Vista Versions and install Windows XP and other Windows OS on it.
Details on how to set up the Virtual PC on your machine can be found in this link.
I am currently using it and found it powerful and fast enough for my programming stuff.
It comes FREE of cost.
A $100 laptop – with a tablet screen, video camera, microphone, a graphics tablet, game-pad controllers, and a memory-card slot ? Yes, this is the dream of One Laptop Per Child to develop a very low-cost, high-potential, extremely rugged computer for the two billion educationally underserved children in poor countries. And the dream comes true OLPC unveiled their dream machine XO in October.
XO provides regular wireless Internet connectivity as well as mesh networking, and its system software takes up one-fifth of its 1 GB of flash memory storage. The majority of the laptop’s programs can be shared on the mesh network it supports. The XO comes close to the initiative’s original vision of a $100 laptop (it currently costs $200 ) and in November the computer will be offered for sale to the public in industrialized countries for two weeks through OLPC’s “Get 1, Give 1″ program. Under the program, a consumer pays $400, which covers the cost of one XO laptop–complete with tax deduction–for the consumer and one for a student in an impoverished country. One more reason to be happy – XO is built from free and open-source software.
Configuration : (Details can be found here )
“Open Source Northeast” is one more initiative from Prag Foundation. This is supposed to be the first magazine from NE india promoting Open Source for development of North Eastern States. The theme is very novel. The founders are very much motivated to share the benefits of Free and Open Source Software (FOSS) in building Information Communication Technology (ICT) capability for development and success in today’s emerging Knowledge Society.

Volume-I of the magazine covers a few interesting topics such as Open Access and Open Course Ware. You will find links to various organization, especially the universities, that houses various courses online and free for all. In India ,a similar kind of initiative is taking place in IIT Bombay (http://www.dep.iitb.ac.in/). I think there will be much more information about open course ware in the coming issues of the magazine.
If you want to buy a PC for yourself here are the tips for you in the Know How section. A good review of OpenOffice is also in place as per the software reviewed in this issue.
I feel Open Source Northeast is a good start. Contents are good and well written except for some occasional typos. There are lot more scope to improve the current layout to create better look and feel experience.
For all those interested to read out the mag should find a soft copy here. And please dont forget to leave your comments to editor. !
AHEAD, as discussed in the previous article defines the following tasks for generating complete software from features. .
A. define numbers of features
B. semantics to create an algebraic equation from features (feature refinement)
C. define a composer to compose the final feature out of the equation and produce the final software (assuming composer performs the final compilation)
This approach requires the selection of different features available to be specified in compile time. Every new refinement would require step B and C to be repeated.
The purpose of this short article is to show a different FOP approach where feature selection happens in runtime. In this approach – all the features are loaded at compile time and the selection of features is deferred till we run the application. The user is provided with a configuration that is read by the program to activate only those features specified in the configuration. By this we can complete the requirement of different feature selection by providing different configuration with the same executable. This ensures that we reduce the time spent in compilation for different combinations of features.
Sample Implementation
The implementation I am currently using is inspired by the “registry of singleton” mentioned in Design Patterns – Elements of Reusable Object-Oriented Software (GOF).
All features are derived from a base class – Feature. Every feature (Feature1, Feature2), in this example, assigns a different value to printStr. The features are registered with a FeatureManager that acts as a store house for features. The user specifies the features he wants to use as a command line input to the test program.
You may download the source and makefile from this link.
Base class – Feature.h
#ifndef _F_H_
#define _F_H_
#include<iostream>
class Feature
{
public:
virtual void print()
{
std::cout << printStr << std::endl;
}
protected:
std::string printStr;
};
#endif
File: Feature1.h
#ifndef _F1_H_
#define _F1_H_
#include<iostream>
#include “FeatureManager.h”
#include “Feature.h”
class Feature1 : public Feature
{
public:
Feature1()
{
printStr = “1″;
FeatureManager::Register(printStr ,this);
}
};
#endif
File:Feature1.cpp
#include “Feature1.h”
static Feature1 f1;
File: Feature2.h
#ifndef _F2_H_
#define _F2_H_
#include<iostream>
#include “FeatureManager.h”
#include “Feature.h”
class Feature2 : public Feature
{
public:
Feature2()
{
printStr = “2″;
FeatureManager::Register(printStr,this);
}
};
#endif
File: Feature2.cpp
#include “Feature2.h”
static Feature2 f2;
File: FeatureManager.h
#ifndef _FM_H_
#define _FM_H_
#include<iostream>
#include<map>
#include “Feature.h”
class FeatureManager
{
public:
static void Register(const std::string& name, Feature* f);
static FeatureManager* GetInstance();
static Feature* Lookup(const std::string& name);
private:
static FeatureManager* _instance;
static std::map<std::string, Feature*> _registry;
};
#endif
File: FeatureManager.cpp
#include “FeatureManager.h”
FeatureManager* FeatureManager::_instance = NULL;
std::map<std::string,Feature*> FeatureManager::_registry;
FeatureManager* FeatureManager::GetInstance()
{
if(_instance == NULL)
{
return (_instance = new FeatureManager());
}
else
return _instance;
}
void FeatureManager::Register(const std::string& name, Feature* f)
{
_registry[name] = f;
}
Feature* FeatureManager::Lookup(const std::string& name)
{
std::map<std::string,Feature*>::iterator it = _registry.find(name);
if( it != _registry.end())
{
return (*it).second;
}
else
{
return NULL;
}
}
File: test.cpp
#include <iostream>
#include “FeatureManager.h”
#include “Feature.h”
int main(int argc, char **argv)
{
FeatureManager * mgr = FeatureManager::GetInstance();
//loop through the features provided
for(int i = 1; i<argc; i++) {
Feature *f = mgr->Lookup(argv[i]);
if(f)
f->print();
}
}
Test run
$ ./test 1 2
1
2
$ ./test 2
2
Comments