Showing posts with label OldPosts. Show all posts
Showing posts with label OldPosts. Show all posts

Friday, February 2, 2007

Importing Old Posts : Done

I have imported my old posts from my old blog at msn live spaces. See them in this tag "OldPosts".

Friday, February 3, 2006

OldPosts: Programs Digest

Like the links digest.
OllyDbg http://www.ollydbg.de/ - A really great (assembly-level) debugger, I used it to patch WinRAR 3.51

OldPosts: Links digest - Volume 1

http://channel9.msdn.com/ - Channel9, not sure what it is, but it looks good
http://geekswithblogs.net/Mohamed/ - Mohammad A. Meligy's Blog
http://rewayatmasreya.com/ - Rewayat Masreya, has very good articles
http://www.hackr.org/ - Test your hacking abilities
http://www.try2hack.nl/ - A harder hacking test
http://wikipedia.com/ - Really great site to search for anything about programming (or about anything)
http://www.devx.com/tips/Tip/12582 - new Operator usage (there is information you might not know anywhere else)
http://www.zaon.com/company/articles/3d_rendering.php - How to choose a 3D Application (for designers)
http://c-faq.com/ - A must-visit site for any C/C++ programmer
http://www.cuj.com/documents/s=7998/cujcexp1902alexandr/ - Using 'volatile' keyword in C++ to develop thread-safe applications
This is a new idea. Instead of keeping URLs unvisited in my Bookmarks/Favorites, I just keep them here, for me to check them later or for anyone who wants to visit them. Unfortunately adding them day by day will create too much entries. So I will just modify a sinlge entry to add new links, when the entry is big enough i will create the next Volume.
Hope you find it useful.
Note: once I repair my old PC, and have access to my 'old' Favorites you will find thousands of links here :D

OldPosts: My Blogging Type

I've got the link from Mohammad el Meligy's Blog http://geekswithblogs.net/Mohamed/ .
Quote:
***Your Blogging Type is Pensive and Philosophical***

You blog like no one else is reading...
You tend to use your blog to explore ideas - often in long winded prose.
Easy going and flexible, you tend to befriend other bloggers easily.
But if they disagree with once too much, you'll pull them from your blogroll!
EndQuote

Wednesday, February 1, 2006

OldPosts: Time travel

Quote from http://forums.lycaeum.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=9&t=000979 :

How can something move in time? It can move along the x-axis and it's velocity is dx/dt. If it moved along the time axis it's velocity would be dt/dt or 1. dimensionless one, at that. There can be no time travel.

(IMHO = in my humble opinion / OTOH = on the other hand)

Defining Travel : travel is a movement in some dimension. A movement is a change in the position of that dimension(s). A change can't happen on it's own; it must follow some external change. One would ask, the external change would need another change too. Yes, IMHO that it is an infinite loop. The change in X would affect Y which will affect Z which on the end would affect X and so on.

So to describe movement, we need to describe what changes can affect it. Before we do that we must say how was the movement described before. It was described in terms of displacement. But displacement is not enough. Because it does not uniquly identify a movement. I can move 10 meters north, or west, each is a different movement. So we need to make it more specific. We add direction. Which as may jump to the readers mind as a vector of X,Y and Z. Yes. But this is also not enough. One moving to USA in a plane at 500 KM/H and one is also moving but in a boat of 50 KM/H. Is not analogous types of movement though at the end will be the same place. At this point we needed velocity (speed). First, we ask, now we have that movement depends on displacement, thus if change in displacement = 0, there will be no movement. Direction depend on movement; if there is no movement there is no direction. Velocity introduces a new parameter. Time. If change in time = 0, there will be no displacement. But what does changes time ?

So far we defined Movement as undirectly depending on changes of time. Thus time restricts movement. There is some different argument : if movement = 0, will time change ? Some one will say 'Sure'. It may be changing. But how can you tell ? Movements will exists as long as time changes. So, if one can STOP movements, all movements. He theoritically will STOP time. OTOH, argument would say : which by contradiction, is proved if larger changes of Movement will cause time to change with the same amount. Einstien proved that, as one approaches light speed, time will shrink until it reaches zero. This is contradictory. As meaning if you are Moving in light speed, you will STOP time. But as concluded earlier this will make Movements = 0. As far as i conclude, this means that once you reach light speed, your speed will equal zero. OTOH, as your speed increase, time changes will dicrease. which lead to dicreasing in your speed. Actually time shrinking will not make your speed dicrease. If speed = dx/dt, as dt approaches zero, speed approaches infinity.

From the above one can conclude that if your speed increase then the displacement is still the same. Directly from what did Einstein proove. Given that time changes depend on the speed, and speed depends on the displacement per time unit; meaning that speed is inversly proportional to time unit. That is true if Displacement per time unit is constant. But in real life, speed only increases when the displacement per time unit increases. Which means that if we can increase the speed, while keeping the same displacemnt per time unit, then we can decrease the time unit. which will force us to recursivly decrease displacement to keep the ratio constant. When displacement reaches zero, time unit will equal zero. This is undefined as displacement zero is undefined. This was to shrink the time unit. Shrinking the time until means that we move faster relative to other slower entities. Ironically, in a race moving faster means that you reach the finish line first, which is other racers future . Meaning if you can increase the speed and decrease the displacement you will move to future. Descreasing the displacement is only meaning to decrease the new disp/t after t decrease, so it means slowing down while you increase your speed. This is moving to future. Moving to past means jumping over the zero time barrier, which is met when you are moving at the speed of infinity and not moving out of your place (note that this means going to infinite future). Jumping over the barrier requires you moving at negative infinity , while you are moving "inside you place" (displacement zero). As you reach -n speed where n <>

This all is an argument which expresses the conditions for Time travel IMHO. It shows a lot of contradictions. Which if sometime is solved it might happen to travel through time.

Thursday, January 26, 2006

OldPosts: RDBMS - a 'sql' server of my own

RDBMS : Relational Database Management Systems.
Actually this idea came to me while i was thinking of what project to do in the compilers course; that was last summer. It was orignally about parsing SQL, but it was extended to a full idea of a DBMS.
I liked the idea. Overtime, ideas to implement and how to implement it started to accumulate. Until it had to burst out. Knowing how to do something, and wanting to do it, is a powerful force. So i started seriuosly thinking about implementing it this vacation. I started by reading some book called "Database management systems, 2nd edition". A great introduction which gave me a great backgroung on the basics of the database theory and Relational algebra and calculus ( search for it in http://wikipedia.com ).
There is different kinds of DBs, i will mention the names only, not diving in details. Old systems includes Navigational databases. Then about 70s they invented the well-known commonly-used Relational databases. Now there is Object Databases, supporting OOP. This is NOT the whole list, it is just what i could remember for the moment.
What really made me think seriously about making one myself, is an articel i read on Mohamed Meshref's Blog about one student who made one server which can -under some circumstances- execute some queries faster than Oracle's.
With all that information on my head, i opend Visual C++, created an empty header file, gazed at the screen for about 10 minutes trying to figure how to start. As from experience i knew that all systems starts small, i did that. I made a small program that saves an array of structs in a file. And then focused my "grey brain cells" -like Agatha Christie said- on how to generalize that to any user input; on the same struct ( username, pk, and age ). I figured it needs a SQL parser, so i left that part, and went in the other direction, how to generalize the struct contents first ?. I found a great one here http://groups.google.com/group/comp.lang.c/browse_thread/thread/527b451b96ce957a/d612253f370e6aab?q=variable+length&rnum=3#d612253f370e6aab . So i started designing the datastructures required.
I forgot to mention that in coincidence i read in "Introcution to Algorithms" about B-Trees and how they are used in DBMS to index tables in order to minimize disk I/O. Imagine thay can minimize disk I/O for a billion-record table from 32 IO read ( using binary search ), to only 3 IO reads ( of course it traded-off to 3000 comparisons ).
The second step after designing the data structure is defining the way of altering a table's content. Then after that build a way to handle 'parsed' queries and mapping them to these APIs. Parsing SQL is not an issue, some hours with Yacc/flex, and BOOM we have one.
The only remaining part, is what is required "exactly" from a DBMS. The basic implementation/engine is defined by Relational calculus. Other parts will just complay to any SQL standard, i have chosen SQL-92.
As usual i feel this is too short article, maybe i will follow up sometime with part2 or something continuing the in-depth details of the data-structures and how i 'will' -isA- handle the data integrity checks, and table altering, and the indexing problems - B-Trees is not easy to implement yo know !
I'll just go complete the data-structure heirarchy now, wish me luck!

Wednesday, January 4, 2006

OldPosts: A new programming language

I've recently discovered a new programming language called Ruby ( in Arabic it means ياقوت ) http://ruby-lang.org. It have a very easy and intiuitive syntax. As it follows the POLS : Principle of Least Surprise its output is bug-free most of the time and you rarely need to debug.

A RAD ( Rapid Application Development ) web application framework for it called Ruby On Rails ROR is comparable to Apache Struts for Java. Using ROR you can be highly productive, a complete weblog system, like this one ( MSN weblog ), can be completed entirely from scratch including testing and administrative interface in 15 minutes. I did not believe this at first until i downloaded the movie in http://rubyonrails.org/screencasts .

ROR, just like Struts, employs MVC ( Model-view-controller ) pattern for its web applications. And one of its powerful features is that it automated ORM ( Object relational model ) for you. For example, after you create the database and create your web application ( not by typing anything, just by one click ) you'll find the web pages which displays the content and the pages modifies it is ready. If you added a column in a table in the database and just refreshing the page in your browser you'll find a new text area ( or the corresponding control to the new column data type ) is added and fully working in both the view and the edit pages!

All of the typing you will ever do, if you wanted, is that you'll just rename the page title,or reorder how the data is displayed only. Validations is declarative, not imperative. You just say "validate_exist field_name". Same with special relations like one-to-many you only say "has_many object_name". After that you will never have to write any SQL query, well, any SQL at all.

In the sample weblog he only wrote 58 lines of code. with 45 of them auto-generated. Which reminded me of a system i worked on before. It was a J2EE web application which handles the registration of a credit-hours college system. It was 3 months, 37 classes, and more than 2300 lines of code. I had to hand it with some known bugs because the college started and i had no time to fix them. After I've seen that ROR sample I estimated that all the work can be done in 30 minutes. This seems unbelievable, I know. Although I didn't actually rewrote it using ROR but we can count the time estimated. I will not include the time for database because it is already made. Say 1 minute to "click" to generate the solution, 10 minutes to navigate in the generated solution and change the "order" and "place" of data. Another 10 minutes to correct the "validations" and "test" them. This is total of 10+10+1 = 21 minutes. The other 9 minutes is for "yawning" and grabbing something to eat or drink a hot drink !! Now let's compare that to if it was done using J2EE ( not Struts ). First, create a list of the actions in the system ( 2 days ). Write the model - including a loooot of SQL statements and interfacing Java Date with SQL Data ( 3 weeks ). Implement the actions ( 2 weeks ). Implement the view - HTML/JSP pages ( 1 week ). Test ( 2 weeks, there is a lot of data to test ) [Note: ROR can generate tests for you too ]. In total of 3 + 2 + 1 + 2 = 8 weeks = 2 months ( and 2 days ). The other month was for learning Java and JSP and MVC. To be fair, i think using Struts it would take less than a week, excludsing the time needed to learn Struts. In ROR i didn't have to learn MVC nor JSP, and Ruby is so intiuitive that you can learn it in 15 minutes See: http://tryruby.hobix.com/ for a 15-minutes tutorial. Conclusion, the system can be made in 45 minutes, INCLUDING learning the langauge and ROR! ROR is so simple that it can be learnt from a few examples not even a tutorial.

I would like to write more about the origin of the language and its history with a detailed list of programming langauges popularity and Ruby's place in that list but i am really busy with the exams so I think I can add that later. Thanks for reading.

Monday, December 19, 2005

OldPosts: Me and compilers

I was always fond of compilers, one of the reasons i joined Faculty of computers and information was to be be able to construct a compiler.
Compilers to me means symbolic power of the ability of understading the user input. And how to be able to utilize the computing power of the machine to do extremely large things that needs tedious work of a human; by changing a few lines, you can do a big difference - imagine doing it with no computers at all - like moving a mountain along a path which follows a car! It's a strange idea but it somehow reflects my idea of the power of computers.
I always was trying to learn more about compiler since the moment - or even before - i joined the college. So i was able to gather a lot of knowledge about them before we study the Compilers course. Though it was not enough to understand them well enough to be able to actually construct a compiler, I gained enough knowledge about what we should study in that course exactly. Disappointingly, what we actually studied was only 30% of what we should, and what all other courses, outside Egypt, did study.
We have studied Regular Expressions, DFA, and Context free grammars, and LL parsing. Regular Expressions and DFA was supposed to be studied in another course ( named - as in other colleges outside Egypt : Automata theory and Formal languages), leaving more time to focus on compiling related topics - Supposedly, parsing only is a Parsing theory, so we did study Parsing theory, Not compilers. We even didn't study the full parsing theory; we should have studied LR parsing, as LL is history, and nothing compared to LR. We should also have studied Context sensetive grammars, and attribute grammars, which is essential for semantic analysis. Outside parsing theory, we should have studied Run-time environments, the link between Architecture and Compiler, and a way to enlighten us of how to produce executable files, and also of how our code we compile everyday does actually run.
Another thing that really made me mad, is the project. In graphics course we did use DirectX as a tool to implement something big. But if we did implement the low-level graphics ourselves, it would have lead us nowhere and we would have produced something that is useless and so little. The same for compilers, we should have used a Parser, and Lexer generator tools, so we can produce something big, and actually employ our - supposed - knowledge of semantic analysis and run time analysis so that we can actually produce a full working compiler for a big language and also outputs an executable file. But what happened was the opposite; we spent time and effort implementing a lexer and a parser, hardcoded, which no one in the world do anymore; even the Java CUP parser generator last version was 1999.
Finally, I would really feel sorry for being so held back, that other people did these stuff 20 years ago, and we are still doing the same. The compiler industry are way looking so much far, on the loosely typed languages, and Aspect-Oriented Programming, and Zero-code data-binding, we didn't even hear about Object-Oriented Programming in the compilers course. Hopefully, in 20 or 30 years, I will be able to feel Hope again .

Monday, December 5, 2005

OldPosts: Fermat's last theorm

Fermat's last theorem

The theorem says :
x^n + y^n = z^n has no non-zero solution for n > 2. About year 1500 C.E. it was not proven yet. It was proven about 1990's. I have seen the proof, about 100 pages, not a line I did understood :S. Anyway the theorm implies that you can't divide a cube into two cubes, and so, for higher diemnsions. It is not true for n=2 because of Pythagorean theoerm of the right triangle, which proved that you can divide a square into two squares x^2 + y^2 = z^2.
I am trying to read more about mathematics to be able to understand this theorem, and how it was proved, so i can be able to prove stuff like this. Nontheless, it wouldn't hurt if I just read more about math, but not enought to understand it.

Sources :
* Definition : http://en.wikipedia.org/wiki/Fermat's_last_theorem
* Proof : http://math.stanford.edu/~lekheng/flt/wiles.pdf