Algorithms, Theory, Spirituality, Life, Technology, Food and Workout : trying to sort these deterministically in $\Theta(1)$ time (constant time).
Tuesday, November 29, 2005
Life of a hyderabadi....
Script2Executable project....
So now my ideal is to create a program which takes the interpreter name and the file (script) and create a compiled executable file, which can run standalone. There are several advantages of this program one thing is that this hepls the developers to hide the code of the scripts, what are the other advantages??....
To create this generic solution, I started thinking about this idea
STEP1:
o I'll create a dummy executable file compiled, with a placeholder for the script as follows
#include
static char buffer_space_for_script[MAX_SCRIPT_FILE_SIZE]="#Cheating perl hahaha...";
/*Driver program to launch the script, similar to piping except the program reads from static buffer and writes into the pipe.*/
int main(){
int fd[2], pid;
/*create a pipe all finer details avoided*/
pipe(fd);
dup2(1,fd[1]);
pid = fork()
........
if(pid==0){
dup2(0,fd[0]);
exec(perl/other interpreter);
.....
}
else{
write(1,buffer_space_for_script,MAX_SCRIPT_SIZE); /*write into stdout will be read by interpreter in the child*/
}
Now I wanted to compile this program and use 'hexdump -c a.out" find the seek location(byte in the physical file of the buffer_space_for_script and write the contents of the script file into the file a.out)....
I almost coded it but suddently realized that the major objective of this has been breached since hexdump -c will read out the ascii, thus a intelligent user can read the script using hexdump, even though we have created a compiled executable from the script.....
:(
Monday, November 07, 2005
Algorithm to build DFA's to test divisibility
Problem: Create a DFA to test the divisibility of a binary string by 3. (Assume the string can be scanned from left to right....ex 11 , 110 )
During the scan of the binary string the current state (Value of the binary string scanned till now) can be in one of the following states
1. 3K 2. 3K+1 3. 3K+2
So if the current state of the DFA is 3K+1 and we scan a '0' the value becomes 2*(3K+1) == 3k+2. If we scan a '1' it becomes 2*(3K+1)+1 == 3K. Similarly if we scan '0' in state '3k+2' it becomes 2*(3k+2) == 6k+4 == 3k+1. So now we have 3 states and move according to the following table.
CURRENT STATE SCAN_LITERAL NEXT_STATE
3k (final state) 1 3k+1
3k (final state) 0 3k
3k+1 1 3k
3k+1 0 3k+2
3k+2 1 3k+2
3k+2 0 3k+1
We can now extened this for the divisibility test for any 'k' that requires a D.F.A of kstates (can we minimize?). With this we can solve problems like the following.
Problem: Design a DFA for the set of string in {0,1,2}* that are ternary(base 3) representations, leading zeros permitted, of numbers that are not multiples of four.
Thought that this would be a useful piece of information.......Cheers Vamsi.
Sunday, September 18, 2005
Small observation in our life
Sunday, September 11, 2005
klists an ideal way for building asynchronous applications.......
Ok let me put this in much lucid terms... 1. I have some data to be shared across process's (not threads). 2. This shared data is accessed asynchronously. We get this type of context typically in telecom applications ( I recall from my experience from moto****). They have a unix based system, with several process's running each communicating with each other.
Ok talked a lot about the problem so whats a unix way of solving it. BTW way the data should be consistent and pocess the ACID (Atomic .....dont remember :-p) behaviour i.e a typical transcational behavior, basically the solution should'nt be error prone to race conditions occuring due to asynchronous behaviour within the process's. So how do you architect this kind of applications?
Ok let me give you some really shoddy professional solution which MOTOSHIT has sold to _NEXTEL_ (being soooo dump bought it from moto***a). 1. Moto***a had a real dumb soultion, to make sure that the data is consistent across the process's they seem to use a DATABASE :)).... 2. I have seen code which tries to access a shared variable as a row in the database table. 3. They just dumbly put every shared suff in the database...to make sure that the data is having ACID properties during the modification of the data by these asynchronous process's. 4. And more ludicrously they buy a database from a shoddy database vendor informix....and just heard that they are lobbying for support form IBM for this outdated product. really amazed by the quality (the romantic quality form zen and art of motorcycle maintenance :-p) of the approach to this problem. After knowing about klists I just felt that kernel which also has asychronous stuff inside does it in a much smarter way using KLIST. (KLIST is worth a reading please use the link above).
Monday, August 22, 2005
Solving serious problems....
Surely this kind of attitude will not help serious problems. But I have that innate feeling that I'am not doing any challenging and substantial stuff at work, so during the last few months I adopted an attitude shift in my thought "rather than complaining about the dark try to light a candle", I took all the pain to refactor every thing except the inane attitude of the superiors around, but they seem to have an attitude similar to some examples in my last post.
I quickly realised that they were just using me to their own glorification. Surely my managers are not my ideals but try to force that thought on people that they are great role models, I just keep mum. I really feel that they could really drive innovation and conceive innovative things, rather than drinking that materialistic vine.
Maan I just feel that I should do something different.
Friday, August 19, 2005
The power of intention.
1. A tiny and thin beam of sunlight suddenly thought that is was the sun...
2. A mild ripple in the middle of the ocean suddenly beleives that its the ocean...
Yes its really true on how ego can really doom a person. If you are reading this just dont be egoistic ever in your life, just relax and think about it again.
Thursday, July 28, 2005
Why this vacuous discernment between senior and junior?
All my mood is off when I see this guy walking ostentatiously all around, with a sneer unfurling those perverse insinuations, to motrify me. I guess his vanity has reached a zenith. All this is because of the discrimination the management shows between experienced and people with little experience. They just seems to despise our ideas with a prejudice that only experienced people only can make successful things and get things working, the management seems tout excessively that they will give weight to everyones views.
Its just because they think they are really privileged , they demand obligation....I really feel these are not the ideal people, no one is a junk. I'am not writing this out of jealously that they are getting paid more and are accessible to more stuff, these are words right out of a morbid mind twarthed by such inane seniors guys working along....I just learned one thing out of it although its a hard way to learn, I will never show that attitude when I become experienced. In fact I will never become a manager, its really a job with massive sagacity not to create any internal humilation among the people working under the manager.....I strongly feel that there should'nt be any discrimination among people interms of experience.
Thursday, June 30, 2005
Verminous ego stench .........
BTW the book I'am studying this week is "If tomorrow comes" , really a good one by sheldon makes us feel how a sapped, anguish and vindictive mind with a sedative torso feels. It was a story of a dejected lover tracy withney who tries to endure with a slender hope to seek vengeance.
TGIT (Thank God Its Thursday)
V@msi
Sunday, June 26, 2005
Fervent gaming hermit....
Tuesday, June 21, 2005
Don't be afraid of making mistakes.......
Tuesday, June 07, 2005
Transmeta lessons.......
I feel it as a small practical reminder about how one should always keep track of the infliction points, at any instance there are millions and millions of people competing with you and a slight negligence might create a infliction point with negative slope............ Think big to conceive a marvel.
Monday, May 23, 2005
Podcasting with itunes...
BTW the following are radiostations I'have been listening all my downtime
http://feeds.feedburner.com/ITConversations-EverythingMP3
http://www.hackermedia.net/wp-rss2.php
http://www.binrev.com/radio/podcast/
http://daily-horoscope.libsyn.com/rss/
Sunday, May 15, 2005
Its podcasting revolution.....
Monday, May 09, 2005
Love you momma!!
Hmmm......have been thinking about too many things these days, finally I got some time to write about momma.
I just shut my mind up for few minutes and start thinking about momma feeling a little nostalgic. Momma made me realise that "success is going from failure to failure with out loss of enthusiasm", without her motivation, I would'nt have accomplished any thing till now. In fact every day is a mothers day for me.......I love you momma!!!
Wishing all of you a happy mothers day
Friday, April 29, 2005
Solace for the weekend.....
Tuesday, April 26, 2005
Corporate victimization of enthusiasm.......
Tuesday, April 19, 2005
IPOD Mini on the go......
Recently bought an IPOD mini for just
$199 . I felt this to be really great no hassles of batteries, no hassles of space (4GB). I really feel like throwing my samsung YEPP-90S (64 MB) mp3 player.
The great thing about IPOD's is their integration with audible ( click here). I could really play all my audiobooks in audible format without converting them into mp3's. Yes now I turned out into an audible freak listening tons of audio books in my down time.....guys wondering why I have photo of mine rather than an IPOD mini here??......keep guessing
Monday, March 14, 2005
Turned into a RSS Freak
:-p Vamsi
Tuesday, February 22, 2005
There is no AI only RI (Real Intelligence)
Jeff Hawkins, the man who created the PalmPilot, Treo smart phone, and other handheld devices, has reshaped our relationship to computers. Now he stands ready to revolutionize both neuroscience and computing in one stroke, with a new understanding of intelligence itself.
Hawkins develops a powerful theory of how the human brain works, explaining why computers are not intelligent and how, based on this new theory, we can finally build intelligent machines.
The brain is not a computer, but a memory system that stores experiences in a way that reflects the true structure of the world, remembering sequences of events and their nested relationships and making predictions based on those memories. It is this memory-prediction system that forms the basis of intelligence, perception, creativity, and even consciousness.
Monday, February 21, 2005
The Aviator........
-- Howard Hughes describing his way of working and the mistakes made in building the "Spruce Goose."
Monday, January 31, 2005
How to avoid BROKEN PIPE errors in code (SIGPIPE)
void *stream = (FILE *)......; ............ ............ //To make sure the data is written to disk (HA) if(!fflush((FILE *)stream)){ printf("Flush failed due to %d error refer error.h\n",errno); } //This is really very dangerous code if you dont have a signal handler //written for SIGPIPE (either you write a sig handler for SIGPIPE) or //use the following code// /*Safe Code*/ if(!fsync(fileno((FILE *)stream)))){ printf("Sync failed due to %d error refer error.h\n",errno); }I found the standards guide on context of libc functions really useful
http://www.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_05.html
Hope you will not go through the same pain....
Vamsi
Monday, January 17, 2005
Symbol referencing errors for static variable in C++
What could be wrong in the following definition of a c++ class to find out how many instances of MyClass are created??
class MyClass{ private: static int __instance_count; public: MyClass(){ __instance_count++; } int getInstances(){ return __instance_count; } }; main(){ .... }When complied with g++ says that __instance_count is not defined...this can be resolved by defining __instance_count outside the class definition,as follows.
int MyClass::__instance_count;Why do we need this seperate definiton of static variables?
Saturday, January 01, 2005
04 to 05 with a 4-5 puzzle....
here cut it into 5 pieces and solve it.....finally keep track of how much time you took to solve this and this will be proportional to the hard times you will have to face in 2005....how about people who solved this already :)) not problems at all in 2005??