Nisi’s work blog

Nisi’s work blog – programing tips

MySQL variables range


TINYINT
A very small integer
The signed range is –128 to 127. The unsigned range is 0 to 255.

SMALLINT
A small integer
The signed range is –32768 to 32767. The unsigned range is 0 to 65535

MEDIUMINT
A medium-size integer
The signed range is –8388608 to 8388607. The unsigned range is 0 to 16777215

INT or INTEGER
A normal-size integer
The signed range is –2147483648 to 2147483647. The unsigned range is 0 to 4294967295

BIGINT
A large integer
The signed range is –9223372036854775808 to 9223372036854775807. The unsigned range is 0 to 18446744073709551615

FLOAT
A small (single-precision) floating-point number. Cannot be unsigned
Ranges are –3.402823466E+38 to –1.175494351E-38, 0 and 1.175494351E-38 to 3.402823466E+38. If the number of Decimals is not set or <= 24 it is a single-precision floating point number

DOUBLE,
DOUBLE PRECISION,
REAL
A normal-size (double-precision) floating-point number. Cannot be unsigned
Ranges are -1.7976931348623157E+308 to -2.2250738585072014E-308, 0 and 2.2250738585072014E-308 to 1.7976931348623157E+308. If the number of Decimals is not set or 25 <= Decimals <= 53 stands for a double-precision floating point number

DECIMAL,
NUMERIC
An unpacked floating-point number. Cannot be unsigned
Behaves like a CHAR column: “unpacked” means the number is stored as a string, using one character for each digit of the value. The decimal point, and, for negative numbers, the ‘-‘ sign is not counted in Length. If Decimals is 0, values will have no decimal point or fractional part. The maximum range of DECIMAL values is the same as for DOUBLE, but the actual range for a given DECIMAL column may be constrained by the choice of Length and Decimals. If Decimals is left out it’s set to 0. If Length is left out it’s set to 10. Note that in MySQL 3.22 the Length includes the sign and the decimal point

DATE
A date
The supported range is ‘1000-01-01’ to ‘9999-12-31’. MySQL displays DATE values in ‘YYYY-MM-DD’ format

DATETIME
A date and time combination
The supported range is ‘1000-01-01 00:00:00’ to ‘9999-12-31 23:59:59’. MySQL displays DATETIME values in ‘YYYY-MM-DD HH:MM:SS’ format

TIMESTAMP
A timestamp
The range is ‘1970-01-01 00:00:00’ to sometime in the year 2037. MySQL displays TIMESTAMP values in YYYYMMDDHHMMSS, YYMMDDHHMMSS, YYYYMMDD or YYMMDD format, depending on whether M is 14 (or missing), 12, 8 or 6, but allows you to assign values to TIMESTAMP columns using either strings or numbers. A TIMESTAMP column is useful for recording the date and time of an INSERT or UPDATE operation because it is automatically set to the date and time of the most recent operation if you don’t give it a value yourself

TIME
A time
The range is ‘-838:59:59’ to ‘838:59:59’. MySQL displays TIME values in ‘HH:MM:SS’ format, but allows you to assign values to TIME columns using either strings or numbers

YEAR
A year in 2- or 4- digit formats (default is 4-digit)
The allowable values are 1901 to 2155, and 0000 in the 4 year format and 1970-2069 if you use the 2 digit format (70-69). MySQL displays YEAR values in YYYY format, but allows you to assign values to YEAR columns using either strings or numbers. (The YEAR type is new in MySQL 3.22.)

CHAR
A fixed-length string that is always right-padded with spaces to the specified length when stored
The range of Length is 1 to 255 characters. Trailing spaces are removed when the value is retrieved. CHAR values are sorted and compared in case-insensitive fashion according to the default character set unless the BINARY keyword is given

VARCHAR
A variable-length string. Note: Trailing spaces are removed when the value is stored (this differs from the ANSI SQL specification)
The range of Length is 1 to 255 characters. VARCHAR values are sorted and compared in case-insensitive fashion unless the BINARY keyword is given

TINYBLOB,
TINYTEXT

A BLOB or TEXT column with a maximum length of 255 (2^8 – 1) characters

BLOB,
TEXT

A BLOB or TEXT column with a maximum length of 65535 (2^16 – 1) characters

MEDIUMBLOB,
MEDIUMTEXT

A BLOB or TEXT column with a maximum length of 16777215 (2^24 – 1) characters

LONGBLOB,
LONGTEXT

A BLOB or TEXT column with a maximum length of 4294967295 (2^32 – 1) characters

ENUM
An enumeration
A string object that can have only one value, chosen from the list of values ‘value1’, ‘value2’, …, or NULL. An ENUM can have a maximum of 65535 distinct values.

SET
A set
A string object that can have zero or more values, each of which must be chosen from the list of values ‘value1’, ‘value2’, … A SET can have a maximum of 64 members

.htaccess – user guide


Custom Error pages

ErrorDocument 400 http://new-error-page.htm
ErrorDocument 401 http://new-error-page.htm
ErrorDocument 403 http://new-error-page.htm
ErrorDocument 404 http://new-error-page.htm
ErrorDocument 500 http://new-error-page.htm

Redirects

- great if you change your domain or some portion of your site

Redirect /olddirectory/oldfile.html http://yoursite.com/newdirectory/newfile.html

Links:

http://www.javascriptkit.com/howto/htaccess.shtml

Where to subbmit my webpage/blog


Yahoo:
https://siteexplorer.search.yahoo.com/submit/
You need to have an Yahoo Account (it is free)

Google:
http://www.google.com/addurl/

http://www.google.com/webmasters/sitemaps/

DMOZ:
http://www.dmoz.org/add.html
from dmoz almost every small and big directory in the world get page informations

OTHER search engines & Directoryes
Summit to many directoryes: http://www.submitexpress.com/submit.html

http://ananzi.co.za/Add_site/

How to kill a dragon with various programming languages

This funny text comes from Ibon from the dream team who got it from a Spanish blog.

There’s a beautiful princess, prisoner in the highest tower of a castle, guarded by a mighty dragon, and a fearless knight must rescue her…

This is how each language would manage to rescue the princess from the hands of the dragon

Java – Gets there, finds the dragon, develops a framework for dragon anihilation with multiple layers, writes several articles about the framework… But doesn’t kill the dragon.
.NET – Gets there, sees the idea of the Java developer and copies it. Tries to kill the dragon, but the monster eats him.
C – Arrives, looks down at the dragon, pulls out his sword, beheads the dragon, finds the princess… And ignores her to see the last checkins of linux kernel cvs.
C++ – Creates a basic needle, and gathers funcionality until he has a complex sword that he can barely understand… He kills the dragon, but gets stuck crossing the bridge because of memory leaks.

COBOL – Arrives, sees the dragon and thinks that he is too old to kill a monster that big and rescuing the princess, so he leaves.

Pascal – He prepares for 10 years to create a dragon anihilation system… When the moment comes, he discovers the program can only take lizards as an entry.

VB – Builds a dragon destruction weapon based on several components, jumps to the back of the dragon and in the most critical time he discovers that the sword works only on rainy nights…

PL/SQL – Gets data from other dragon slayers, creates tables with n ternary complexity relations, tridimensional data, OLAP, takes 15 years to process the information… And by then, the princess became a lesbian.

Ruby - Arrives with massive fame, saying he is the best at anything and when he faces the dragon, he shows a lame motion picture of himself killing a dragon… The dragon eats him out of boredom.
Smalltalk – Arrives, analyzes the dragon and princess, turns around and leaves, they are way too inferior.

shell – Creates a very powerful dragon slaying weapon… But in the moment of truth, he can’t remember how to use it.

shell(2) – The guy approaches the dragon with a two line script that kills, cuts, disembowels, impales, chops to pieces and packs the beast, but when he runs it the script grows, it fattens, irritates and puts alcohol in the fire of the dragon…

Assembler – He thinks he’s doing the right and most efficient things… But he writes an A instead of a D and kills the princess to end up f***ing the dragon.

Fortran – Arrives and develops a 45-thousand-code-line-solution, kills the dragon, meets the princess… But she calls him a weakling and runs after the Java programmer who was elegant, and also rich.

FOX PRO – Develops a dragon killing system. It’s gorgeous and works on the outside, but it’s really patched inside, so when he runs the dragon anihilator, he realizes he forgot to index the DBFs.

PROCESS ANALYST – Approaches the dragon with two tons of documentation, develops the unified dragon-killing process, he develops a DFD to free the princess and marry her, convinces the dragon that it’s the best for him and it won’t hurt. When he executes the process, he estimates the effort and the damage he will cause with a plan signed by the Pope, Buddha and Michael Jackson. Then he buys a couple of nukes, 45 cannons, an aircraft carrier and hires 300 heavily armed men… When all he needed was the sword he was holding in his hand in the beginning…

CLIPPER - Sets up a routine that loads a codeblock array to insult the dragon, serenade the princess, load the sword in memory, beat the crap out of the dragon, clean the mess, prepare a raspberry milkshake for the princess, make love to her, take a bath, start the car, put it some gas and come back home. When he runs it, he gets a “Bound Error: Array Access” and the dragon eats him with fries.
Lisp, where the famous knight-errant, after speaking with numerous experts in dragon-killing, and modeling the knowledge they posess, he programs the system, and when he runs it he realizes he forgot a bracket (bender the offender).

HTML - Mounts a web on famous swords used to kill dragons, but he ignores the W3C standards. When he meets the dragon, he finds out the code isn’t compatible with his browser, so he’s left swordless. The dragon eats him as an appetizer.

Prolog - Thinks he needs a weapon to kill the dragon. Searches in a catalog for 182014 weapons. By the time the princess dies of her age, he’s achieved to know how to make every weapon starting with

A - Atomic Bombs, Anti-Air Weapons, Arches, Ammunition, Axes…

PHP - Creates a web page that when he executes it would eliminate the $dragon selecting from a weapons databese in MySQL over an Apache server. Nevertheless he forgot the WHERE in the DELETE query and kills the princess, the dragon, the peasants, the witch, the sorceror and the programmer himself.

JavaScript - The programmer tries to kill the great green dragon that spits fire throug his mouth. He creates a script that will delete the dragon when he loads a webpage, to create seconds after, some damsels to throw him flowers and make clapping sounds. Unfortunately he didn’t take into account the DOM structure of the lizard, also known as Mozilla, and the only thing he gets is to fill his console of errors and that the Book of Mozilla tells how he was devoured.

ActiveX - The programmers create a tunnel to enter the dragon’s lair from the castle and run a program that will kil the dragon from a safe and prudential distance. The dragon discovers the tunnel, eats the workers who dug, the dragon slayers, and enslaves every servant in the castle. The castle becomes a dragon-breeding place, full of little dragons that the dragon sends in pop-ups to other castles. The untasty remains of the knights are put in cans of Spam and sent to other castles as well as a warning. (aquelquesiente)

Basic - He creates a weapon able to kill paper dragons, but no matter how they improve it, they discover it’s not good enough to kill any dragon bigger than a baby poodle.

Matlab - They create a loop that calculates the trajectories to shoot a giant arrow at the dragon. The program works flawlessly. What they need now are the voluntaries caoable to launch tha arrow with the necessary strength and accuracy.

Videogame Programmer - Spends two years programming a state-of-the-art sword with shaders and all. When the time comes to kill the dragon, he finds that half the knights aren’t strong enough to raise the sword. Then someone programs a patch that reveals the sex scenes with the princess and Hillary Clinton makes it a scandal.

LINQ to XML (C#) create new xml document

How to create a new xml with LINQ

[sourcecode language='csharp ']

var objCars= new[]
{
new {CarID = 2, CarName = “Ford”, Fuel = “Diesel”},
new {CarID = 3, CarName = “Audi”, Fuel = “Diesel”},
new {CarID = 4, CarName = “Mercedes”, Fuel = “Diesel”},
new {CarID = 1, CarName = “BMW”, Fuel = “Diesel”}
};

XElement _cars = new XElement(“cars”,
from c in objCars
select new XElement(“car”,
new XElement(“name”, c.CarName),
new XAttribute(“ID”, c.CarID),
new XElement(“Fuel”, c.Fuel)
)
);
Console.WriteLine(_cars);

[/sourcecode]
so this will print something like:

Ford
Diesel

Audi
Diesel

Mercedes
Diesel

BMW
Diesel