Posts Tagged ‘C’

MySQL-Definition

Thursday, July 24th, 2008

MySQL is a relational database management system (RDBMS) based on SQL (Structured Query Language). First released in January, 1998, MySQL is now one component of parent company MySQL AB’s product line of database servers and development tools.

Many Internet startups became interested in the original open source version of MySQL as an alternative to the proprietary database systems from Oracle, IBM, and Informix. MySQL is currently available under two different licensing agreements: free of charge, under the GNU General Public License (GPL) open source system or through subscription to MySQL Network for business applications.

MySQL runs on virtually all platforms, including Linux, Unix, and Windows. It is fully multi-threaded using kernel threads, and provides application program interfaces (APIs) for many programming languages, including C, C++, Eiffel, Java, Perl, PHP, Python, and Tcl.

MySQL is used in a wide range of applications, including data warehousing, e-commerce, Web databases, logging applications and distributed applications. It is also increasingly embedded in third-party software and other technologies. According to MySQL AB, their flagship product has over six million active MySQL installations worldwide. Customers include Cisco, Dun & Bradstreet, Google, NASA, Lufthansa, Hyperion, and Suzuki.

SQL is Not C

Thursday, July 24th, 2008

C is the canonical procedural programming language and the greatest pitfall for a programmer looking to show off his database-fu is that he fails to realize that SQL is not procedural (nor is it functional or object-oriented, for that matter). Rather than thinking in terms of data and operations on data one must think of sets of data and relationships among those sets. This usually crops up with the improper use of a subquery:
SELECT a.id,
(SELECT MAX(created)
FROM posts
WHERE author_id = a.id)
AS latest_post
FROM authors a

Since this subquery is correlated, i.e., references a table in the outer query, one should convert the subquery to a join.
SELECT a.id, MAX(p.created) AS latest_post
FROM authors a
INNER JOIN posts p
ON (a.id = p.author_id)
GROUP BY a.id

JavaScript vs Java

Wednesday, July 16th, 2008

Although the names are much alike, JavaScript is primarily a scripting language for use within HTML pages, while Java is a real programming language that does quite different things from JavaScript. In addition Java is much harder to learn. It was developed by Sun for use in pretty much anything that needs some computing power.

JavaScript was developed by Brendan Eich, then working at Netscape, as a client side scripting language (even though there’s no fundamental reason why it can’t be used in a server side environment).

Originally the language was called Live Script, but when it was about to be released Java had become immensely popular (and slightly hypey). At the last possible moment Netscape changed the name of its scripting language to “JavaScript”. This was done purely for marketing reasons. Worse, Eich was ordered to “make it look like Java”. This has given rise to the idea that JavaScript is a “dumbed-down” version of Java. Unfortunately there’s not the slightest shred of truth in this story.

Java and JavaScript both descend from C and C++, but the languages (or rather, their ancestors) have gone in quite different directions. You can see them as distantly related cousins. Both are object oriented (though this is less important in JavaScript than in many other languages) and they share some syntax, but the differences are more important than the similarities.

If you are a C++ or Java programmer you will be surprised by some of JavaScript’s features. Since I don’t have any previous programming experience, the differences are not described on this site. The best you can do is buy David Flanagan, “JavaScript, the Definitive Guide”, 5th edition, O’Reilly, 2006. In this book the differences between C++/Java and JavaScript are clearly explained. I co–edited a few chapters of this book.

PHP:Protect your data from user input

Monday, June 30th, 2008

I came to a point where I needed to filter the user input (not just tell the user something like : “The username isn’t in the right format” or “Please choose a valid name for your username”), I mean let him to input in the form anything he wanted too but in the end what we store in the database is his processed input (only A-Z, a-z and 0-9).
I had the Visual Basic and C++ thinking .. I must do that and that and that to get rid of unwanted characters. It was a little time consuming and I was in hurry so I googled and I reached the ereg_replace help page on PHP.net website. Suddenly all became much much easier :D, just write a regular expression (ohh, by the way .. if someone asks I can write a small tutorial on regular expressions) like this : “[^A-Za-z0-9]” and that was it :).

Below is a small example on how to filter (remove all characters except uppercase/lowercase letters and numbers)

1. <?php
2. //our string
3. $str = “nek#$#hbet|20&&07″;
4. $filtered = ereg_replace(”[^A-Za-z0-9]“, “”, $str);
5. print $filtered; // will print ‘nekhbet2007′
6. ?>

PHP is a strong language with a lot of functions that help us to decrease the development time. So before thinking how to do a certain thing just take a look first at www.php.net and see if what you need isn’t already done

Gmail Shortcuts

Wednesday, June 18th, 2008

Note: Must have “keyboard shortcuts” on in settings.

C: Compose new message.

Shift + C: Open new window to compose new message.

Slash (/): Switch focus to search box.

K: Switch focus to the next most recent email. Enter or “O” opens focused email.

J: Switch focus to the next oldest email.

N: Switch focus to the next message in the “conversation.” Enter or “O” expands/collapses       messages.

P: Switch focus to the previous message.

U: Takes you back to the inbox and checks for new mail.

Y: Various actions depending on current view:

Has no effect in “Sent” and “All Mail” views.

Inbox: Archive email or message.

Starred: Unstar email or message.

Spam: Unmark as spam and move back to “Inbox.”

Trash: Move back to “Inbox.”

Any label: Remove the label.

X: “Check” an email. Various actions can be performed against all checked emails.

S: “Star” an email. Identical to the more familiar term, “flagging.”

R: Reply to the email.

A: Reply to all recipients of the email.

F: Forward an email.

Shift + R: Reply to the email in a new window.

Shift + A: Reply to all recipients of the email in a new window.

Shift + F: Forward an email in a new window.

Shift + 1 (!): Mark an email as spam and remove it from the inbox.

G then I: Switch to “Inbox” view.

G then S: Switch to “Starred” view.

G then A: Switch to “All Mail” view.

G then C: Switch to “Contacts” view.

G then S: Switch to “Drafts” view.