- by admin
At some point, you may have a situation where you want to center multiple elements (maybe<div>
elements, or other block elements) on a single line in a fixed-width area. Centering a single element in a fixed area is easy. Just add margin: auto
and a fixed width to the element you want to center, and the margins will force the element to center.display: inline
in an IE6-only declaration, but your code will still be somewhat messy because of the extra code to get the first and/or last item to behave. Also, the last box could fall to the next line in IE.inline-block
and control white space#parent {
width: 615px;
border: solid 1px #aaa;
text-align: center;
font-size: 20px;
letter-spacing: 35px;
white-space: nowrap;
line-height: 12px;
overflow: hidden;
}
.child {
width: 100px;
height: 100px;
border: solid 1px #ccc;
display: inline-block;
vertical-align: middle;
}
child
, and each 100 pixels by 100 pixels. The boxes are naturally block-level elements, but the CSS changes them to inline-block
, which allows them to flow naturally with text and white space. Of course, since we don’t have any text in the parent container, controlling the text and white space will not be a problem.parent
in this example) has four key text properties set, and the children have two:text-align
makes all inline child elements centeredletter-spacing
controls the size of each white space unit between boxeswhite-space: nowrap
keeps the last element from potentially dropping to the next lineoverflow: hidden
prevents the box from stretching in IE6vertical-align: middle
(on the children) keeps the boxes on the same vertical plane as each other when content is addeddisplay: inline-block
(obviously)inline-block
. To get those browsers to show virtually the same result, you need to add the following CSS:.child {
*display: inline;
*margin: 0 20px 0 20px;
}
display
property is taking advantage of a bug in those browsers that makes a block element work like its inline when you declare display: inline-block
followed by display: inline
.- by admin
You can push the branch up to a remote very simply:git push origin newfeature
origin
is your remote name and newfeature
is the name of the branch you want to push up.git push origin :newfeature
newfeature
branch on the origin
remote, but you’ll still need to delete the branch locally with git branch -d newfeature
.
- by admin
The most simple way is adding the following new command in the X11-> application -> customize:xterm -geometry 72x34+100+40 -fn *-fixed-*-*-*-20-* &
- by admin
After Xcode installation and trying to build mc I've got:configure: error: C compiler cannot create executables
sudo ln -s /usr/bin/llvm-gcc-4.2 /usr/bin/gcc-4.2
sudo ln -s /usr/bin/llvm-g++-4.2 /usr/bin/g++-4.2
- by admin
Error:postdrop: warning: uid=48: File too large
% /usr/sbin/postconf -e message_size_limit=XXXXXXXXXXX
% postconf -e mailbox_size_limit=0
# postconf -d | grep size
berkeley_db_create_buffer_size = 16777216
berkeley_db_read_buffer_size = 131072
body_checks_size_limit = 51200
bounce_size_limit = 50000
header_size_limit = 102400
mailbox_size_limit = 51200000
message_size_limit = 10240000
- by admin
By default, the OS X installation does not use a my.cnf, and MySQL just uses the default values.cd /usr/local/mysql/support-files/
sudo cp my-huge.cnf /etc/my.cnf
cd /etc
sudo nano my.cnf
- by admin
In order to get the next Auto Increment number in MySQL just run:SHOW TABLE STATUS LIKE '$tablename';
- by admin
Selecting a database:
mysql> USE database;
Listing databases:
mysql> SHOW DATABASES;
Listing tables in a db:
mysql> SHOW TABLES;
Describing the format of a table:
mysql> DESCRIBE table;
Creating a database:
mysql> CREATE DATABASE db_name;
Creating a table:
mysql> CREATE TABLE table_name (field1_name TYPE(SIZE), field2_name TYPE(SIZE));
Ex: mysql> CREATE TABLE pet (name VARCHAR(20), sex CHAR(1), birth DATE);
Generate the create statement of a table in MySQL:
mysql> SHOW CREATE TABLE tblname;
Load tab-delimited data into a table:
mysql> LOAD DATA LOCAL INFILE "infile.txt" INTO TABLE table_name;
(Use \n for NULL)
Inserting one row at a time:
mysql> INSERT INTO table_name VALUES ('MyName', 'MyOwner', '2002-08-31');
(Use NULL for NULL)
Retrieving information (general):
mysql> SELECT from_columns FROM table WHERE conditions;
All values: SELECT * FROM table;
Some values: SELECT * FROM table WHERE rec_name = "value";
Multiple critera: SELECT * FROM TABLE WHERE rec1 = "value1" AND rec2 = "value2";
Reloading a new data set into existing table:
mysql> SET AUTOCOMMIT=1; # used for quick recreation of table
mysql> DELETE FROM pet;
mysql> LOAD DATA LOCAL INFILE "infile.txt" INTO TABLE table;
Fixing all records with a certain value:
mysql> UPDATE table SET column_name = "new_value" WHERE record_name = "value";
Selecting specific columns:
mysql> SELECT column_name FROM table;
Retrieving unique output records:
mysql> SELECT DISTINCT column_name FROM table;
Sorting:
mysql> SELECT col1, col2 FROM table ORDER BY col2;
Backwards: SELECT col1, col2 FROM table ORDER BY col2 DESC;
Date calculations:
mysql> SELECT CURRENT_DATE, (YEAR(CURRENT_DATE)-YEAR(date_col)) AS time_diff [FROM table];
MONTH(some_date) extracts the month value and DAYOFMONTH() extracts day.
Pattern Matching:
mysql> SELECT * FROM table WHERE rec LIKE "blah%";
(% is wildcard - arbitrary # of chars)
Find 5-char values: SELECT * FROM table WHERE rec like "_____";
(_ is any single character)
Extended Regular Expression Matching:
mysql> SELECT * FROM table WHERE rec RLIKE "^b$";
(. for char, [...] for char class, * for 0 or more instances
^ for beginning, {n} for repeat n times, and $ for end)
(RLIKE or REGEXP)
To force case-sensitivity, use "REGEXP BINARY"
Counting Rows:
mysql> SELECT COUNT(*) FROM table;
Grouping with Counting:
mysql> SELECT owner, COUNT(*) FROM table GROUP BY owner;
(GROUP BY groups together all records for each 'owner')
Selecting from multiple tables:
(Example)
mysql> SELECT pet.name, comment FROM pet, event WHERE pet.name = event.name;
(You can join a table to itself to compare by using 'AS')
Currently selected database:
mysql> SELECT DATABASE();
Maximum value:
mysql> SELECT MAX(col_name) AS label FROM table;
Auto-incrementing rows:
mysql> CREATE TABLE table (number INT NOT NULL AUTO_INCREMENT, name CHAR(10) NOT NULL);
mysql> INSERT INTO table (name) VALUES ("tom"),("dick"),("harry");
Adding a column to an already-created table:
mysql> ALTER TABLE tbl ADD COLUMN [column_create syntax] AFTER col_name;
Removing a column:
mysql> ALTER TABLE tbl DROP COLUMN col;
(Full ALTER TABLE syntax available at mysql.com.)
Batch mode (feeding in a script):
# mysql -u user -p < batch_file
(Use -t for nice table layout and -vvv for command echoing.)
Alternatively: mysql> source batch_file;
Backing up a database with mysqldump:
# mysqldump --opt -u username -p database > database_backup.sql
(Use 'mysqldump --opt --all-databases > all_backup.sql' to backup everything.)
- by admin
/**
* Convert a string into a url safe address.
*
* @param string $unformatted
* @return string
*/
public function formatURL($unformatted) {
$url = strtolower(trim($unformatted));
//replace accent characters, forien languages
$search = array('À', 'Á', 'Â', 'Ã', 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Ź', 'ź', 'Ż', 'ż', 'Ž', 'ž', 'ſ', 'ƒ', 'Ơ', 'ơ', 'Ư', 'ư', 'Ǎ', 'ǎ', 'Ǐ', 'ǐ', 'Ǒ', 'ǒ', 'Ǔ', 'ǔ', 'Ǖ', 'ǖ', 'Ǘ', 'ǘ', 'Ǚ', 'ǚ', 'Ǜ', 'ǜ', 'Ǻ', 'ǻ', 'Ǽ', 'ǽ', 'Ǿ', 'ǿ');
$replace = array('A', 'A', 'A', 'A', 'A', 'A', 'AE', 'C', 'E', 'E', 'E', 'E', 'I', 'I', 'I', 'I', 'D', 'N', 'O', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'Y', 's', 'a', 'a', 'a', 'a', 'a', 'a', 'ae', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 'n', 'o', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u', 'y', 'y', 'A', 'a', 'A', 'a', 'A', 'a', 'C', 'c', 'C', 'c', 'C', 'c', 'C', 'c', 'D', 'd', 'D', 'd', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'G', 'g', 'G', 'g', 'G', 'g', 'G', 'g', 'H', 'h', 'H', 'h', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'IJ', 'ij', 'J', 'j', 'K', 'k', 'L', 'l', 'L', 'l', 'L', 'l', 'L', 'l', 'l', 'l', 'N', 'n', 'N', 'n', 'N', 'n', 'n', 'O', 'o', 'O', 'o', 'O', 'o', 'OE', 'oe', 'R', 'r', 'R', 'r', 'R', 'r', 'S', 's', 'S', 's', 'S', 's', 'S', 's', 'T', 't', 'T', 't', 'T', 't', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'W', 'w', 'Y', 'y', 'Y', 'Z', 'z', 'Z', 'z', 'Z', 'z', 's', 'f', 'O', 'o', 'U', 'u', 'A', 'a', 'I', 'i', 'O', 'o', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'A', 'a', 'AE', 'ae', 'O', 'o');
$url = str_replace($search, $replace, $url);
//replace common characters
$search = array('&', '£', '$');
$replace = array('and', 'pounds', 'dollars');
$url= str_replace($search, $replace, $url);
// remove - for spaces and union characters
$find = array(' ', '&', '\r\n', '\n', '+', ',', '//');
$url = str_replace($find, '-', $url);
//delete and replace rest of special chars
$find = array('/[^a-z0-9\-<>]/', '/[\-]+/', '/<[^>]*>/');
$replace = array('', '-', '');
$uri = preg_replace($find, $replace, $url);
return $uri;
}
- by admin
Here what I found and like most.// Set the allowed types for reading and upload.
$types = array ('jpg', 'jpeg', 'txt');
// Start a variable.
$dir_files = array();
// If it is a directory add all the files.
if (is_dir ($dir)) {
// Open the directory.
if ($handle = opendir($dir)) {
// Read the file names of all the files available.
while (false !== ($file = readdir($handle))) {
// Make sure the file is not this directory or its parent and not the .DS_Store file.
if ($file != "." && $file != ".." && $file != '.DS_Store') {
// Get the file parts.
$file_parts = pathinfo($file);
// Make sure the extension is allowed.
if (in_array(strtolower ($file_parts['extension']),$types)) {
// Add the file to the array.
$dir_files[] = array ('original_name'=>$file, 'type'=>$file_parts['extension']);
}
}
}
// Close the handle.
closedir ($handle);
}
}
// If any files exist in the upload directory check them for viruses.
if (count ($dir_files) > 0) {
// Get the dir and prepare it for the command line.
$real_path = realpath ($dir);
$safe_path = escapeshellarg($real_path);
// Set the variables for the cmd.
$return = -1;
$out ='';
$cmd = '/usr/local/clamXav/bin/clamscan ' . $safe_path;
// Execute the cmd.
exec ($cmd, $out, $return);
// If a virus is found loop through each of the files and delete the virus, write the user a message, and add them to a db table.
if ($return != 0) {
// Loop through the files.
foreach ($dir_files as $k=>$v) {
// Get the dir and prepare it for the command line.
$real_path = realpath ($dir . $v['original_name']);
$safe_path = escapeshellarg($real_path);
// Reset the values.
$return = -1;
$out ='';
$cmd = '/usr/local/clamXav/bin/clamscan ' . $safe_path;
// Execute the command.
exec ($cmd, $out, $return);
// If the file is clean do nothing.
if ($return == 0){}
// If the file contains a virus remove it and add a note to the db.
else if ($return == 1) {
// Delete the file.
unlink ($dir . $v['original_name']);
// Unset the file from the records.
unset ($dir_files[$k]);
// Notify the user.
$message .= "The file {$v['original_name']} contained a known virus. It has been deleted from the server.<br />";
$message_class = 'error';
// Add the user who uploaded the file to the db and a time and date.
// Query the db to record who uploaded the file, not necessary but fun info to have.
}
else {
// Delete the file.
unlink ($dir . $v['original_name']);
// Unset the file from the records.
unset ($dir_files[$k]);
// Notify the user.
$message .= "The file {$v['original_name']} caused an unknown error and was removed from the server.<br />";
$message_class = 'minor_error';
}
}
}
}