Mar
24

Fast and simple element (min) height CSS hack

CSS          Trackback

Did you ever make something which looked great in Firefox, and than opend that same thing in IE, and you saw bunch of crap? One of the reasons is IEs lack of support for CSS min-height attribute, and here is fast and simple hack for that. Just use this class for element you would like to have fixed min-height, and your life is going to be much easier.

.minheight {
	min-height: 250px;
	height: auto !important;
	height: 250px;
}


not only that but you can use as a min-width hack:

.minwidth {
	min-width: 250px;
	width: auto !important;
	width: 250px;
}


Mar
24

Useful regular expressions

RegEx          Trackback

Phone Numbers:
(999) 999-9999
999-999-9999
999.999.9999

[\(.]?[2-9]\d\d[\).]?[ -]?[2-9]\d\d[-.]\d{4}

USA ZIP Codes
12345
12345-1234

\d{5}(-\d{4})?

Canadian postal codes
A1B 2C3

[ABCEGHJKLMNPRSTVXY]\d[A-Z] \d[A-Z]\d

UK postal codes
A12 3BC

[A-Z]{1,2}\d[A-Z\d]? \d[ABD-HJLNP-UW-Z]{2}

US Social Security Number
123-45-6789

\d{3}-\d{2}-\d{4}

IP Address
123.234.123.234

(((\d{1,2})|(1\d{2})|(2[0-4]\d)|(25[0-5]))\.){3}((\d{1,2})|(1\d{2})|(2[0-4]\d)|(25[0-5]))

URL
http://www.zemoon.comhttp://localhost:80

https?://[-\w.]+(:\d+)?(/([\w/_.]*)?)?


Complete URL
http://www.zemoon.com/index.htm
http://blog.zemoon.com/index.php?p=1

https?://(\w*:\w*@)?[-\w.]+(:\d+)?(/([\w/_.]*(\?\S+)?)?)?

Email Address
someone@something.com

(\w+\.)*\w+@(\w+\.)+[A-Za-z]+

HTML Comments
<!– This is comment –>

C style comments

//.*

Credit card numbers
Mastercard

5[1-5]\d{14}


Visa

4\d{12}(\d{3})?


AmericanExpress

3[47]\d{13}


Discovery

6011\d{14}


Diners

(30[0-5]|36\d|38\d)\d{11}


All credit cards

(5[1-5]\d{14})|(4\d{12}(\d{3})?)|(3[47]\d{13})|(6011\d{14})|((30[0-5]|36\d|38\d)\d{11})


Mar
12

Simple MySQL table backup & restore

SQL          Trackback

Here is simple MySQL table backup script. You can use it to easily create backup of your MySQL table, so you can play with that table without fear of losing your valuable data. First line will delete table named “tablename_backup” (if table with that name exists). Second line will create “tablename_backup” table using same structure as tablename is using. And third line will copy data from tablename to tablename_backup.

DROP TABLE IF EXISTS tablename_backup;
CREATE TABLE tablename_backup LIKE tablename;
INSERT tablename_backup SELECT * FROM tablename;


I already hear you asking, what about restoring of that backup. And here it is:

DROP TABLE IF EXISTS tablename_temp;
RENAME TABLE tablename TO tablename_temp,
tablename_backup TO tablename,
tablename_temp TO tablename_backup;


If there is table named “tablename_temp” we will delete it, and then we have to make some table name tumbling. We can use one command (renaming operations are done from left to right) to make 3 rename operations. First we are renaming table “tablename” to temporary table “tablename_temp”, then we are restoring our backup from “tablename_backup” to “tablename”, and at the end we are saving starting table as new backup “tablename_backup”…

Pretty simple and effective?


top