Daily Diary

 

  2nd May 2012

Today was my first day of 6 week training. Our mentor “Dr. H.S. Rai” gave me the task on Lua Programming and FElt.

As soon as Sir assign me the work ,I started exploring it, and found some introduction of FElt.

FElt is an open source system for finite element analysis. The current version of FElt knows how to solve linear static and dynamic structural and thermal analysis problems; it can also do modal and spectral analysis for dynamic problems. FElt’s element library currently contains fourteen elements.

Then I downloaded the tar file of FElt package from sourceforge.net and after extracting it, I executed  ‘make install’ command,but many errors came relating to no such files and directories found. I read the README and INSTALL files again and again and started searching the solution from internet.

After messing up with so many commands and websites, Sir told me to download the package from Github. I did so. I extracted the zip file and again issue command “make install” but this time different kind of errors are coming. Still the work is in progress.

With all this, I also revised the Lua programming syntax and techniques and read the old files that I made earlier.

  

3rd May 2012

I was working on the previous errors I got while installing FElt. I came to know that i need to install many other packages like BISON,FLEX,BOOST and GCC compiler. To install those packages ,I executed following commands:

sudo apt-get install flex

sudo apt-get install bison

sudo pat-get install libboost-dev libbboost-doc

After installing all the above mentioned packages, I issued ‘cmake . ‘ command again and fortunately this time it worked well. (Note: Don’t forget to put ‘dot’ after cmake command)

Then I typed ‘make‘ command, After completing 11 % it gives me error like:

lib/Felt/code.cpp:521:32: error: cast from ‘instruction*’ to ‘int’ loses precision

Still working on the error.

Simultaneously I am studying Lua string pattern Matching and the making a script for that.

4th May 2012

Today ,I spent my most of the time in checking  the errors mentioned above that I got the previous day.

Our Mentor told me ,that the older compilers were unable to find these types of errors , as there were some bugs in those compilers ,so they skipped. But now as I am using latest version of GNU G++ compiler, obviously the version is bugs free thats why the compiler is showing me the error, and code needed to be edit manually. So I surfed my websites regarding this, But C++ is not that easy Man! 😉

5th May 2012

C++ code editing, I feel it the most difficult task by now. Simultaneously I started working upon my Lua script. I was having misconception that I need to launch a connection between Lua program and the MySQL database. So I started working upon this only idea and started searching for the solutions.

The script was actually on the program that reads some data contents from the files and moves into the database tables. I started installing LuaSQL. But again I got installation errors. This was the most irritating and frustating time period, whatever i tried to install gives me error in the files. I was wondering, can’t programmers update their programs and source code timely.

Then I read somewhere that another package named ‘MYSQLOO’ can also solve the purpose , but again sorry man! I was unable to find any installation commands and which was known to me ,were not working. I put this question on Mailing list of Lua. They said to ask this on MySQL mailing list. By this time,I lost my interest.

I was working and surfing but with no output ,no result. arrrggghhh

6th May 2012

Hahaha , The first week of my training ended and today was sunday. But you know what, I just didnot get any single output by now. According to me , as the things were clarified in my mind, neither I was wrong,nor my approach. After all I am a learner and my technical knowledge is still limited.

Our mentor gave us the task of preparing presentation slides of the weeks’ work for the seminar on Monday. Damn!

I dint have any output by now, I was having Only and Only errors. and Preparing a presentation was another challenge as I was having no any contents to add into it.

7th May 2012

Sorry, But I fell ill.  Consumption of chick pea continuously for three days ,make my stomach to suffer from severe pain and indigestion. Ooo . But I am helpless ,chick pea is my favorite dish. 😛 I just can’t resist myself. And I did no work today.

8th May 2012

Sir (our mentor) cleared all my misconceptions and then I noticed that I was working on the wrong track . So how could I reach upto my destination?

What basically I needed to do, was dealing with the string pattern matching, and need to extract information consider some common keywords from file and then showing the output as MySQL queries. Such that when I do login to my Mysql account, then after mentioning the output file generated by Lua source code ,the queries starts working. That was my task.

I will share the whole commands soon. Just have patience folks, I just get the idea ,but the work is still needed to be done. 🙂 .

I am happy Today.

9th May 2012

I got the solution. I  worked upon My task today.

What I did , I made a program describe below:

#!/usr/bin/lua
string='title="3D Beam Sample Problem (Logan ex. 6.8, p.248)" nodes=4 elements=3'
a=string.match(string,'".*"')
b=string.match(string,'nodes=%d+')
c=string.match(string,'elements=%d+')
print("USE Structure;")
w='INSERT INTO Description(id,title,nodes,element) Values(1,' ..a..',"'.. b..'","'..c..'");'
print(w)

And I executed the above program “test.lua” by command “lua test.lua>test.out” in terminal. I mentioned “test.out” because I wanted my output to be stored in this file.

the output was:

USE Structure;
INSERT INTO Description(id,title,nodes,element) Values(1,"3D Beam Sample Problem (Logan ex. 6.8, p.248)","nodes=4","elements=3");

Then I logged into my MySQL account by typing:

mysql -u <user_name> -p <test.out

The queries executed well and the contents moved into my database. Hurraah!..


11th May 2012

I work upon the same thing today also. But this time I made a little change in my script, like rather than mentioning string in the script, I gave the path of file such that script itself fetch the strings from the file who has the similar patterns. So for that , Internet helped me alot, as I was unable to fetch the string from file though my program was alright but a very small flaw.

I made a program like:

#!/usr/bin/lua
print("CREATE DATABASE Structure;")
print("USE Structure;")
print("Create Table Description (id int(255) not null auto_increment, title Varchar(1000), node_No varchar(1000), element_No varchar(1000),primary key(id));")
file = io.open("/home/sandeep/Desktop/frame.flt",r)
line = file:read()
for line in file:lines() do
a=string.match(line,'".*"')
b=string.match(line,'nodes=%d+')
c=string.match(line,'elements=%d+')
w='INSERT INTO Description(title,node_No,element_No) Values(' ..a..',"'.. b..'","'..c..'");'
print(w)
end
file:close()

But I got a very silly error in this. The script work. But at the end it gives the error like:

lua Lua_script.lua
CREATE DATABASE Structure;
USE Structure;
Create Table Description (id int(255) not null auto_increment, title
Varchar(1000), node_No varchar(1000), element_No varchar(1000),primary
key(id));
lua: Lua_script.lua:14: attempt to concatenate global 'c' (a nil value)
stack traceback:
Lua_script.lua:14: in main chunk
[C]: in ?

I am even unable to belieive, why this kind of error comes when ‘c’ is not a nil value. Still working to remove this error.

13th May 2012

Today was the seminars and the whole day spent in listening to my friends’ task and their projects and their problems.

The part is very interesting, as through this only we came to know that others’ are sailing in the same boat ,we are in. 😉
A boat of project where we are the sailors and the splashing water from all the sides ,is becoming an obstacle. And a Catastrophe is happening with us.
I learnt from this, That the survivors are only those, those who have will power to tackle with the Catastrophe created by water (errors,hurdles), others might get sink (quit). 🙂

I think I have gone off topic :P. Anyways today we discussed about different softwares and those are :

Django , Sagemath, Limesurvey, MyReview, C++ real life programming, MySQL commands, Website designing through css+cgi+c++

14th May 2012

I Study about MySQL databases, as their study going to help me in my further project work. It took 2 hours for me to surf and collect relevant information.

Then I moved on my script, and try to match other strings from the file using ‘Lua String Pattern Matching’. But everything is creating a mess.

I need a few command that can serve my work , But I am unable to find those commands.

I can just helping myself for the solution.  No other option 😦

15th May 2012

Today I spent most of my time in learning things from others because my project got stuck in the mid.
So I thought better to learn something unique rather than wasting time.
Let me share with you all what I have learnt today :

1) A MySQL command that tells about the last access time i.e it will show the time and date when we access our database for the last time.
for this a few set of commands are there, follow below if you wanna try:
Open terminal, and run MySQL using

 mysql -u -p 

Use specific database, where table is located
Run following command:

 select update_time from information_schema.tables where table_name="table" 

The time log will be displayed on your screen

2) Second Thing I learnt , that we can access others Localhost by just knowing his/her IP.
Isn’t this interesting?
3) I got to know about the command by which we can see the current version and other details about our OS.

 lsb_release -a 

16th May 2012

Today I was searching alot on internet to split lines at spaces in Lua. But All in vain.
I found many commands and many functions but nothing was working.
Then Finally I got some ‘ MUSHClient splitter’, I wasted all my day in installing that and working with that.
But at the end , I got only failure today.

17th May 2012

My comrades and even Sir told me to you shell commands ‘sed’ to solve my purpose. But I was having no idea how to do it.
Finally I got a function ‘ Gsplit’ . I define the function in my script and then afterwards I call that function.
WoW, the lines got splitted at spaces.
Every single word is moving into next line at space character.
But the problem arises, The function was considering first two lines of the original file too, which I never wanted because the first two lines are needed to be considered in some other logic..
Struggling with that.

18th May 2012

Struggle……….
I was just helping myself in omitting those first two lines from my final output with Gsplit function.
I fedded up by the evening and lost all my interest in making script.
I better feel to read some book, may be that can motivate me or change my environment and refresh me.
I took ‘ Revolution 2020 ‘ By Chetan Bhagat.
I took that book because of the name. On reading an excerpt , I feel that may be it can help me in boosting me up as the name say.
And believe me, the name was well describing the book.
It was great.
I enjoyed it alot.
I read that book in just one day i.e by 19th May evening, as I started the book on 18th’s evening.

21st May 2012

I was working with Gsplit function , and split the string .
I used follwoing syntax:

for s in string_gsplit(x, '%s+', true) do
g=string.format("%q",s)
print(g)

It splits the function when the function encounter any space character.
and string .format function displays the splitted string in quotes, like follow:

"x=0"
" "
"y=0"
" "
"constraint=fixed"
" "
"null"
" "
"x=0"
" "
"y=120"
" "
"constraint=free"
" "
"force=side_sway"
" "
"x=120"
" "
"y=120"
" "
"null"
" "
"force=twist"
" "
"x=120"
" "
"y=0"
" "
"constraint=fixed"
" "
"null"

I was happy, atleast I succeeded in splitting the function.


22nd May 2012

Then I try to format the above output as per My MySQL queries.
General syntax of MySQL queries are like:

Insert into table(x,y,constraint,force)values("x=0","y=0","constraint=free","null");

So for this, what I actually need my string should get splitted after 4 lines and fit like a query.
I further try some diffrent codes and found ,I can insert comma, that will solve my purpose upto some extent.

I wrote:

for s in string_gsplit(x, '%s+', true) do
g=string.format("%q,",s)
print(g)

I inserted ‘comma’ after ‘%q’ and it changed my output like.

"x=0",
" ",
"y=0",
" ",
"constraint=fixed",
" ",
"null",
" ",
"x=0",
" ",
"y=120",
" ",
"constraint=free",
" ",
"force=side_sway",
" ",
"x=120",
" ",
"y=120",
" ",
"null",
" ",
"force=twist",
" ",
"x=120",
" ",
"y=0",
" ",
"constraint=fixed",
" ",
"null",

It was giving a problem. I was splitting my function at spaces ,
but the function is not ignoring the spaces but also prints it in the next line.
That was irritating and I was working upon the same how i can remove those spaces.
I searched many things from google like ignoring spaces or not printing or hiding this.
But yet to work more.


23th May 2012

It came to my mind to use if-else statements.

As I was trying if else statements,
I worked upon the same , and wrote the following code:

for s in string_gsplit(x, '%s+', true) do
if
string.match(s,'%a+')
then
g=string.format("%q",s)
print(g)

It has a logic behind, the function gets splitted at spaces but if only if the string matches with character(%a) , then only it prints the output , otherwise ignore.
It worked.


24th May 2012

My output was:

"x=0",
"y=0",
"constraint=fixed",
"null",
"x=0",
"y=120",
"constraint=free",
"force=side_sway",
"x=120",
"y=120",
"null",
"force=twist",
"x=120",
"y=0",
"constraint=fixed",
"null",

The spaces got removed but this time the comma was torturing me.
I needed the comma after every line except 4th,8th,12th and 16th as per MySQL query syntax.
Neither I could remove comma today nor I was able to split the stringafter 4th line. because I want a MySQL insert query after every 4th statement. for that I have to apply loop.
I tried using arrays as I was having not even a single idea how to do.
I study well about Lua arrays and It was in my mind , that it will be the better approach if I somehow arrange the file to go into arrays then I can call the lines through their index numbers and operations will get easy.
I spent my whole day for doing this only, But failed.
But atleast I learn about arrays and thats the positive thing.
I cleared many concepts about arrays.
I used array ,but failed.
I think upon another logic.


25th May 2012

Still thinking,
Then I created a logic using split function.
What I did , I call the same function 2 times and used nested loops.
I first split a segment of 4 lines at ‘\n’ i.e. end line into 4 saperate strings.
then I again applied the loop there  and splitted the single string at space characters .

My code was:

for split in string_gsplit(e, '\n', true) do
if
string.match(split,'%a+')
then
x=string.format("%s",split)
print('Insert into Elements(element_id,nodes_joined,material) values("')
i=string.gsub(x, '%s', '","')
print(i)
for s in string_gsplit(x, '%s+', true) do
if
string.match(s,'%a+')
then
g=string.format("%q",s)
print(g)
end
end
end
end

and it worked upto some extent.

but again the comma interrupted me.
I used another function and replace some characters with another and it served my purpose.
My values goes into database.

Yippie…..


26th May 2012

Today was a day of seminar.
I gave evryone a surprise by showing my output.
My program was having some flaws ,that only programmer can judge it.
I got many suggestions for the improvement ,and now I am working upon that.


28th May,2012

Today , frankly saying. I did nothing.
I was having my plans for the further improvements , but on 29th ,it was my birthday. So my friends forced me for a party.
I skipped my training.
I thought of doing work in the evening and will complete the target, but When I started working in the evening, internet was not working.
It seemed that the day was not in the favour of me.


29th May 2012

Happy Birthday to me 🙂

I came a little late on training as I was continuously receiving phone calls for the B’day wishes.

When I gave my presentation, All objected for improvements. For example: Extracting only 4 from the whole word ‘nodes=4’.
I was searching for this type of function from Day 1 of my training. I focussed once again .
It took time.
Simultaneously I taught MySQL database to my comrade.
There was a seminar by our senior on ‘Unified Documentation’.

The seminar took  2-3 hours and then I studied some LaTeX tutorials.


30th May 2012

I got the function that I was searching for.
It was string.sub(string, i ,j)
‘i’ is used for starting value and ‘j’ for terminating value.

I changed my script accordingly and it extracts exactly the same thing I wanted to.
But there was a problem, I was giving the character number values that was a wrong approach.
But i thought,I will look into it later.


31st May 2012

I studied OOPS concepts once again as I wanted to trim my script.
I started from C++ OOPS.


1st June 2012

I taught my comrade about the OOPS concepts ,that I studied.

I too searched for Lua OOP , but Somewhere I got, Lua is not object oriented.
I was unable to find tutorials but I got only complex examples.
I searched a lot and finally 😦

We had a discussion on reverse engg , it was quite interesting.
I surfed about it and got many knowledgeable things.


2nd June 2012

A day of seminars.


4th June 2012

I learnt about web hosting , Studied LaTeX today and installed it.
Learnt about Hacking, and some functions of PHP (preg-match)
Started finding alternative function to Preg-match in Lua.


5th June 2012

I got an alternative function to ‘string.sub(string,i,j)’
This time, I only gave the pattern and it extracts the required set of data.
I changed my whole script.
But got some problems: 1) Some variables were having nil values, and I got problem while concatenation.
2) Database tables were not in proper manner, because of the problem mentioned in 1
3) I wanted to trim my script, but my script goes more lengthy 😦

6th June 2012

I mentioned some problems yesterday.
I solved problem 1 as well problem 2.

I am happy.
and now working upon problem 3.
This is not the problem actually, but improvement in my script Otherwise my script is completed but I am not satisfied until I trim it..
I am using Lua functions for this thing.

7th June 2012

Today was a very tiring day ,but I enjoyed the work too.
I connect MySQL database using C Code and fetch all the data from tables.
I was creating an array so that MySQL queries work in loop.
Some how I succeeded, bt got segmentation fault after fetching two tables out of six.

I again started working on FELT.
Seeing into the errors.

8th June 2012

Spent whole day in installing FELT.

This time ,I downloaded the package from sourceforge.net. and on compiling, got to know some packages are missing.

I downloaded about 10 packages, but nothing worked ,to fetch header files.

Then luckily I got one pacakge. “libxaw7-dev
And yes FELT get INSTALLED 🙂
I worked till 3 am (night) just for installing FELT.

9th June 2012

Had a Terrible Day today.
I was so very excited after installing FELT that I want to share this thing with my Comrades and after waking up in the morning, I powered  on my laptop,then I got to know.
MY UBUNTU WAS NOT WORKING WELL.
This thing was next to hell for me. I was Not understanding the problem , and solution = I was blank.
My excitement suddenly turned up into anger, frustation.
I was having no any back up data to my On going project. My heart was sinking ,thinking of losing of all project related data. 😦
See the change, few hours ago, I Wanted to dance after instaling FELT, and after seeing Ubuntu , I Wanted to CRY . ;-( arrggghhhh
But Thank God, I was able to login through Console mode. I checked ,my data was on Desktop. I tried to transfer data into drives, but the process was not working well.
Neither I was getting list of data present in my drives.
It was that time when my heart failed ,that I lost My WHOLE DATA.
My windows was crash, no way to check inside drives.
I repaired window and looked inside drives, fortunately all data was there only ubuntu was not showing due to some permission errors.

Problem I faced after this:
Net was not working in ubuntu.
Pendrive was not working.
Was not able to look inside ubuntu data through windows.
Couldn’t even do ssh because of non availability of internet.
Live CD of ubuntu was also not solving my purpose.

THEN:
I got an idea of connecting wireless through commands as console was working.
Somehow it didn’t worked.
THEN:
I got idea of mounting pendrive in console window.
AND GOT SUCCESS IN COLLECTING ALL DATA.
About Mounting pendrive in console mode, you can follow:
https://sandeepghai.wordpress.com/2012/06/09/mount-usb-using-ubuntu-console-mode/


Where There Is a Will There Is a Way

 

11th June 2012

Felt got installed, I studied documentation of FElt and tried to install Velvet too.
I was still getting some errors but those errors were only for graphics and we actually don’t need to install graphics.

12th June 2012

I tried using my script with different files.
I put the in a array ,then call one by one.

I also made an array for queries for creating database and tables and keep them in another file.
I succeeded but then I need to do a lilte more changes in my script like creating more tables, and fields for database columns as per requirement of felt files.

 

13th June 2012

I got problem while reading Description headings and titles from felt files using my script.
Pattern matching goes wrong.
I did a little change in script and everything went okay.

 

14th June 2012

I uploaded everything on the server.
But then I check, my connection was not working using C++ file on server, because I was giving IP details rather then mentioning localhost.

Then Sir told me to use localhost even there also, and problem got solved.
But the problem of segmentation fault still resist, so I used php code to establish connection.
But loop for diffrent queries to fetch data from diffrent tables was not working, Dont know why.
Vigas helped me with the code, but it was still not showing the output.

 

15th June 2012

My charger got spoiled again. Full day wasted for the new charger and for studying about new laptops.

 

16th June 2012

I was excited in buying new laptop, so I studied hard about processors , technology used in them.
Got to know much about i5 ,i3 processors and diffrence betwwen technologies used in 1st generation,2nd generation and 3rd generation processors.
We too had seminars on diffrent technologies today.

 

18th June 2012

Sir told me to put every query in csv file for easy reading and for easy insertion by user and to use variables in scripts.

I did the same, and use variable for database name, and make everything as per requirement.

 

19th June 2012

I worked hard upon C++ code for establishing connection between mysql as nobody was satisfied for php code.
I did it.. Yes.

Loop was working very well.No segmentation fault this time.

I was happy. 🙂

 

5 responses to this post.

  1. arvinder40's avatar

    Posted by arvinder40 on May 21, 2012 at 9:48 pm

    I see ur script on webpage http://202.164.53.122/~sandeepghai/frame.flt….but i don’t knw how to write scripts on web address as 202.164.53.122………can u plz explain…

    Reply

  2. arvinder40's avatar

    Posted by arvinder40 on May 12, 2012 at 10:36 pm

    Plz post the work of the current days…..

    Reply

Leave a comment

Sandeep Ghai

looking forward for the best happenings

surbhikapoor

A great WordPress.com site

my net house

WAHEGURU....!

Design a site like this with WordPress.com
Get started