1. The purpose of a deceleration lane is:
to allow the driver to slow down when approaching a highway
to allow the driver to speed up when approaching a highway
to allow the driver to slow down when leaving a highway/expressway
all of the above
Your answer was correct!
2. When a driver holds their left arm straight out the window it means he will
stop
turn right
turn left
yield
Your answer was correct!
3. An eight sided sign is
a stop sign
a yield sign
a warning sign
none of the above
Your answer was correct!
4. At an uncontrolled intersection who goes first
the person on right
the person on the left
the person driving fastest
none of the above
Your answer was correct!
5. A truck takes how much longer to stop than a car if it is raining?
75%
100%
15%
25%
Your answer was correct!
6. A motorist must stop
at the direction of a traffice officer
when a squirrel is in the road
at a yellow light
none of the above
Your answer was correct!
7. A triangle sign means
stop
slow down
yield
all of the above
Your answer was correct!
8. An habitual offender is someone who
is caught drinking and driving two times
a person with three suspensions in a year / 3 years
a person with only DUI offenses
none of the above
Your answer was correct!
9. If a GDL driver commits any GDL conditions other than a moving vioation they will receive a fine of
$100
$500
loss of license and $150
none of the above
Your answer '$500' was incorrect.
10. When turning onto a 4 lane road from a 2 lane road it is best to turn into
The far right lane
The lane nearest the center of the road
The far left lane
none of the above
Your answer was correct!
11. It is the law to yield
when pedestrians are in a cross walk
when behind a vehicle yielding to pedestrians
when there is a stop sign
all of the above
Your answer was correct!
12. When we drive in the city we use the
10 second rule
2 second rule
15 second rule
12 second
Your answer was correct!
13. You have to notify MVC of a name change within
60 days
one week
two weeks
none of the above
Your answer was correct!
14. To get a special learner's permit the student must be at least:
17 years old
16 years old
16 and 1/2 years old
18 years old
Your answer '16 and 1/2 years old' was incorrect.
15. A common mistake for a new driver is:
hitting the brake to hard
not hitting the brake hard enough
speeding
none of the above
Your answer was correct!
16. If a student permit driver commits a traffic offense, the responsibility lies with
the student
the instructor
the parent
both B and C
Your answer was correct!
17. What should you do when your car goes into a skid
take your foot off the gas
turn in the direction the rear of the car is going
do not brake suddenly during the skid
all of the above
Your answer was correct!
18. If you turn the steering wheel to the right while in reverse, the rear of the car will
go to the right
go to the left
go straight
none of the above
Your answer was correct!
19. You should only use your high beams when
driving in bad weather
driving at night
driving in the city
driving on country roads with little or no traffice
Your answer was correct!
20. A driver should always yield to:
people in a cross walk
fire engines
police cars
all of the above
Your answer was correct!
21. An acceleration lane is used when
entering a highway
leaving a highway
entering a two lane road
none of the above
Your answer was correct!
22. You can pass a school bus when its red lights are flashing only if:
the bus is going below the speed limit
never
if the bus has pulled in front of a school to pick-up or drop off students
both a and c
Your answer was correct!
23. Every lecensed driver must have three items with them while driving they are:
a valid permit, a supervinsing driver and insurance
a valid license, a supervising driver and insurance
a valid license, valid insurance and registration
none of the above
Your answer was correct!
24. An orange triangle sign with a red border means:
a stop sign
a yield sign
a warning sign
slow moving vehicle
Your answer 'a yield sign' was incorrect.
25. Rearview mirror blind spots are found
behind rear window post
on the left side
on the right side
all of the above
Your answer was correct!
26. Hydroplaning can cause
flat tires
braking problems
tires to ride up on a film of water and not contact the pavement
engine failure
Your answer was correct!
27. The good host law states:
The host may become involved in a law suit if someone leaves their home and has an accident
The host will loose their license
The host can be fined and face jail time
none of the above
Your answer was correct!
28. Wearing seat belts will help
prevent someone from being thrown from the car
preventing the driver from sliding and loosing control of the car
keeping front seat passengers from hitting the windshield
all of the above
Your answer was correct!
29. Under a GDL permit of license seat belts should be worn by
only those in the front seat
only those under 18 years old
only those under 21
any person in the car regardless of age
Your answer was correct!
30. If you are under 21 years old, you are considered under the influence if your BAC is:
0.10%
0.08%
0.02%
all of the above
Your answer was correct!
31. One 5 ounce glass of wine has the same amount of alcohol as:
1 and 1/2 ounces of 86 proof liquor
one 5 ounce glass of beer
a margarita
none of the above
Your answer was correct!
32. When are right turns allowed at a red light
after a full stop when there is not a no turn on red sign and when traffice has been checked
only when entering a one-way street
never in NJ
both A and B
Your answer was correct!
33. A basic driver's license is awarded to someone who is at least
16
17
18
21
Your answer was correct!
34. Drivers may use studded snow tire between
November 15 and April 1
December 31 and March15
November 1 and March 1
October 15 and April 15
Your answer was correct!
35. If you are 21 or over, you are considered under the influence if your BAC is
0.15%
0.10%
0.05%
0.08%
Your answer was correct!
36. A high BAC can only be lowered by
time
eating
drinking water
drinking coffee
Your answer was correct!
37. Stopping distance depends on
individuals reaction time
speed
vehicles weight
all of the above
Your answer was correct!
38. Under what circumstance can a driver get a conditional license in NJ?
If the person is over 21 and takes a safe driver course
If the person is over 18 and takes a safe driver course
Never
If the person has an important job and is over 21
Your answer was correct!
39. Drugs and alcohol can affect:
coordination
vision
decision making
all of the above
Your answer was correct!
40. At an uncontrolled intersection always yield to the driver on the
left
right
in front of you
none of the above
Your answer was correct!
41. A new vehicle does not get inspected for
2 years
must go every year
4 years
3 years
Your answer was correct!
42. The speed limit in a business district is
15mph
25mph
50mph
10mph
Your answer was correct!
43. The colors of a stop light from top to bottom are:
red, yellow, green
green, yellow, red
yellow, red, green
none of the above
Your answer was correct!
44. Driving while your license is suspended can result in
up to a $500 fine and 6 months of additional suspension
three years in jail
three year additional suspension
one year additional suspension
Your answer was correct!
45. When do you use the 2 second rule?
when passing another car
when driving in the city
when determining following distance
when driving in the dark
Your answer was correct!
46. An aggressive driver may exhibit the following
pass illegally
weave in traffice
both a and b
none of the above
Your answer was correct!
47. As a car enters a curve, it tends to go
to the right
to the left
straight
to fast
Your answer was correct!
48. An uncontrolled intersection is:
an intersection with a yield sign
an intersection with a stop sign
an un-marked intersection
none of the above
Your answer was correct!
49. A state resident must transfer their license:
within 60 days or until the out of state license expires which ever is last
within 30 days
within 14 days
within 60 days or until the out of state license expires whichever is first
Your answer was correct!
50. To communicate with other drivers during the day it is best to
wave to them
use your horn
flash your lights
yell out the window
Your answer was correct!
Saturday, July 3, 2010
Check email POP 3
Check e-mail on a pop3 server using telnet
--------------------------------------------------------------------------------
These steps show how to check your e-mail on a pop3 server using a telnet client.
Telnet to the pop3 server.
telnet pop3.somedomain.com 110
You should recieve a reply to this effect.
Trying A.B.C.D...
Connected to pop3.somedomain.com.
Escape character is '^]'.
+OK (rwcrpxc13) POP3 server
Enter your username for the pop3 e-mail account using the "user" command.
user username_here
You should recieve the following reply.
+OK
Enter your password for the pop3 e-mail account using the "pass" command.
pass password_here
You should recieve the following reply.
+OK Maildrop ready
List the mail on the pop3 e-mail account using the "list" command.
list
You will see the list of messages on the server.
+OK scan listing follows
1 1489
2 7652
.
To see one of the messages issue the retrieve command "retr" and the message id.
retr 1
You will see the whole e-mail headers and all.
+OK 1489 octets
Return-path:
Received: from blah (blah.somedomain.net [a.b.c.d])
by blah2.somedomain.net
(iPlanet Messaging Server 5.2 HotFix 1.16 (built May 14 2003))
with ESMTP id <0hhf00c6kk6nxj@blah2.somedomain.net> for
me@here.net; Wed, 02 Jul 2003 23:54:23 -0400 (EDT)
Date: Wed, 02 Jul 2003 23:52:59 -0400
From: Me
Subject: test
To: you@there.net
Reply-to: me@here.net
Message-id: <200307022352.59679.me@here.net>
Organization: Pantz.org
MIME-version: 1.0
Content-type: text/plain; charset=us-ascii
Content-transfer-encoding: 7bit
Content-disposition: inline
User-Agent: KMail/1.5.1
Original-recipient: rfc822;me@here.net
test
If you would like to delete the message issue the dele command with the message id.
dele 1
You will then see a delete confirmation.
+OK message deleted
To finish issue the quit command.
quit
+OK
Connection closed by foreign host.
--------------------------------------------------------------------------------
These steps show how to check your e-mail on a pop3 server using a telnet client.
Telnet to the pop3 server.
telnet pop3.somedomain.com 110
You should recieve a reply to this effect.
Trying A.B.C.D...
Connected to pop3.somedomain.com.
Escape character is '^]'.
+OK (rwcrpxc13) POP3 server
Enter your username for the pop3 e-mail account using the "user" command.
user username_here
You should recieve the following reply.
+OK
Enter your password for the pop3 e-mail account using the "pass" command.
pass password_here
You should recieve the following reply.
+OK Maildrop ready
List the mail on the pop3 e-mail account using the "list" command.
list
You will see the list of messages on the server.
+OK scan listing follows
1 1489
2 7652
.
To see one of the messages issue the retrieve command "retr" and the message id.
retr 1
You will see the whole e-mail headers and all.
+OK 1489 octets
Return-path:
Received: from blah (blah.somedomain.net [a.b.c.d])
by blah2.somedomain.net
(iPlanet Messaging Server 5.2 HotFix 1.16 (built May 14 2003))
with ESMTP id <0hhf00c6kk6nxj@blah2.somedomain.net> for
me@here.net; Wed, 02 Jul 2003 23:54:23 -0400 (EDT)
Date: Wed, 02 Jul 2003 23:52:59 -0400
From: Me
Subject: test
To: you@there.net
Reply-to: me@here.net
Message-id: <200307022352.59679.me@here.net>
Organization: Pantz.org
MIME-version: 1.0
Content-type: text/plain; charset=us-ascii
Content-transfer-encoding: 7bit
Content-disposition: inline
User-Agent: KMail/1.5.1
Original-recipient: rfc822;me@here.net
test
If you would like to delete the message issue the dele command with the message id.
dele 1
You will then see a delete confirmation.
+OK message deleted
To finish issue the quit command.
quit
+OK
Connection closed by foreign host.
MySQL commands
This is a list of handy MySQL commands that I use time and time again. At the bottom are statements, clauses, and functions you can use in MySQL. Below that are PHP and Perl API functions you can use to interface with MySQL. To use those you will need to build PHP with MySQL functionality. To use MySQL with Perl you will need to use the Perl modules DBI and DBD::mysql.
Below when you see # it means from the unix shell. When you see mysql> it means from a MySQL prompt after logging into MySQL.
To login (from unix shell) use -h only if needed.
# [mysql dir]/bin/mysql -h hostname -u root -p
Create a database on the sql server.
mysql> create database [databasename];
List all databases on the sql server.
mysql> show databases;
Switch to a database.
mysql> use [db name];
To see all the tables in the db.
mysql> show tables;
To see database's field formats.
mysql> describe [table name];
To delete a db.
mysql> drop database [database name];
To delete a table.
mysql> drop table [table name];
Show all data in a table.
mysql> SELECT * FROM [table name];
Returns the columns and column information pertaining to the designated table.
mysql> show columns from [table name];
Show certain selected rows with the value "whatever".
mysql> SELECT * FROM [table name] WHERE [field name] = "whatever";
Show all records containing the name "Bob" AND the phone number '3444444'.
mysql> SELECT * FROM [table name] WHERE name = "Bob" AND phone_number = '3444444';
Show all records not containing the name "Bob" AND the phone number '3444444' order by the phone_number field.
mysql> SELECT * FROM [table name] WHERE name != "Bob" AND phone_number = '3444444' order by phone_number;
Show all records starting with the letters 'bob' AND the phone number '3444444'.
mysql> SELECT * FROM [table name] WHERE name like "Bob%" AND phone_number = '3444444';
Show all records starting with the letters 'bob' AND the phone number '3444444' limit to records 1 through 5.
mysql> SELECT * FROM [table name] WHERE name like "Bob%" AND phone_number = '3444444' limit 1,5;
Use a regular expression to find records. Use "REGEXP BINARY" to force case-sensitivity. This finds any record beginning with a.
mysql> SELECT * FROM [table name] WHERE rec RLIKE "^a";
Show unique records.
mysql> SELECT DISTINCT [column name] FROM [table name];
Show selected records sorted in an ascending (asc) or descending (desc).
mysql> SELECT [col1],[col2] FROM [table name] ORDER BY [col2] DESC;
Return number of rows.
mysql> SELECT COUNT(*) FROM [table name];
Sum column.
mysql> SELECT SUM(*) FROM [table name];
Join tables on common columns.
mysql> select lookup.illustrationid, lookup.personid,person.birthday from lookup left join person on lookup.personid=person.personid=statement to join birthday in person table with primary illustration id;
Creating a new user. Login as root. Switch to the MySQL db. Make the user. Update privs.
# mysql -u root -p
mysql> use mysql;
mysql> INSERT INTO user (Host,User,Password) VALUES('%','username',PASSWORD('password'));
mysql> flush privileges;
Change a users password from unix shell.
# [mysql dir]/bin/mysqladmin -u username -h hostname.blah.org -p password 'new-password'
Change a users password from MySQL prompt. Login as root. Set the password. Update privs.
# mysql -u root -p
mysql> SET PASSWORD FOR 'user'@'hostname' = PASSWORD('passwordhere');
mysql> flush privileges;
Recover a MySQL root password. Stop the MySQL server process. Start again with no grant tables. Login to MySQL as root. Set new password. Exit MySQL and restart MySQL server.
# /etc/init.d/mysql stop
# mysqld_safe --skip-grant-tables &
# mysql -u root
mysql> use mysql;
mysql> update user set password=PASSWORD("newrootpassword") where User='root';
mysql> flush privileges;
mysql> quit
# /etc/init.d/mysql stop
# /etc/init.d/mysql start
Set a root password if there is on root password.
# mysqladmin -u root password newpassword
Update a root password.
# mysqladmin -u root -p oldpassword newpassword
Allow the user "bob" to connect to the server from localhost using the password "passwd". Login as root. Switch to the MySQL db. Give privs. Update privs.
# mysql -u root -p
mysql> use mysql;
mysql> grant usage on *.* to bob@localhost identified by 'passwd';
mysql> flush privileges;
Give user privilages for a db. Login as root. Switch to the MySQL db. Grant privs. Update privs.
# mysql -u root -p
mysql> use mysql;
mysql> INSERT INTO db (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv) VALUES ('%','databasename','username','Y','Y','Y','Y','Y','N');
mysql> flush privileges;
or
mysql> grant all privileges on databasename.* to username@localhost;
mysql> flush privileges;
To update info already in a table.
mysql> UPDATE [table name] SET Select_priv = 'Y',Insert_priv = 'Y',Update_priv = 'Y' where [field name] = 'user';
Delete a row(s) from a table.
mysql> DELETE from [table name] where [field name] = 'whatever';
Update database permissions/privilages.
mysql> flush privileges;
Delete a column.
mysql> alter table [table name] drop column [column name];
Add a new column to db.
mysql> alter table [table name] add column [new column name] varchar (20);
Change column name.
mysql> alter table [table name] change [old column name] [new column name] varchar (50);
Make a unique column so you get no dupes.
mysql> alter table [table name] add unique ([column name]);
Make a column bigger.
mysql> alter table [table name] modify [column name] VARCHAR(3);
Delete unique from table.
mysql> alter table [table name] drop index [colmn name];
Load a CSV file into a table.
mysql> LOAD DATA INFILE '/tmp/filename.csv' replace INTO TABLE [table name] FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' (field1,field2,field3);
Dump all databases for backup. Backup file is sql commands to recreate all db's.
# [mysql dir]/bin/mysqldump -u root -ppassword --opt >/tmp/alldatabases.sql
Dump one database for backup.
# [mysql dir]/bin/mysqldump -u username -ppassword --databases databasename >/tmp/databasename.sql
Dump a table from a database.
# [mysql dir]/bin/mysqldump -c -u username -ppassword databasename tablename > /tmp/databasename.tablename.sql
Restore database (or database table) from backup.
# [mysql dir]/bin/mysql -u username -ppassword databasename < /tmp/databasename.sql Create Table Example 1. mysql> CREATE TABLE [table name] (firstname VARCHAR(20), middleinitial VARCHAR(3), lastname VARCHAR(35),suffix VARCHAR(3),officeid VARCHAR(10),userid VARCHAR(15),username VARCHAR(8),email VARCHAR(35),phone VARCHAR(25), groups VARCHAR(15),datestamp DATE,timestamp time,pgpemail VARCHAR(255));
Create Table Example 2.
mysql> create table [table name] (personid int(50) not null auto_increment primary key,firstname varchar(35),middlename varchar(50),lastnamevarchar(50) default 'bato');
MYSQL Statements and clauses
ALTER DATABASE
ALTER TABLE
ALTER VIEW
ANALYZE TABLE
BACKUP TABLE
CACHE INDEX
CHANGE MASTER TO
CHECK TABLE
CHECKSUM TABLE
COMMIT
CREATE DATABASE
CREATE INDEX
CREATE TABLE
CREATE VIEW
DELETE
DESCRIBE
DO
DROP DATABASE
DROP INDEX
DROP TABLE
DROP USER
DROP VIEW
EXPLAIN
FLUSH
GRANT
HANDLER
INSERT
JOIN
KILL
LOAD DATA FROM MASTER
LOAD DATA INFILE
LOAD INDEX INTO CACHE
LOAD TABLE...FROM MASTER
LOCK TABLES
OPTIMIZE TABLE
PURGE MASTER LOGS
RENAME TABLE
REPAIR TABLE
REPLACE
RESET
RESET MASTER
RESET SLAVE
RESTORE TABLE
REVOKE
ROLLBACK
ROLLBACK TO SAVEPOINT
SAVEPOINT
SELECT
SET
SET PASSWORD
SET SQL_LOG_BIN
SET TRANSACTION
SHOW BINLOG EVENTS
SHOW CHARACTER SET
SHOW COLLATION
SHOW COLUMNS
SHOW CREATE DATABASE
SHOW CREATE TABLE
SHOW CREATE VIEW
SHOW DATABASES
SHOW ENGINES
SHOW ERRORS
SHOW GRANTS
SHOW INDEX
SHOW INNODB STATUS
SHOW LOGS
SHOW MASTER LOGS
SHOW MASTER STATUS
SHOW PRIVILEGES
SHOW PROCESSLIST
SHOW SLAVE HOSTS
SHOW SLAVE STATUS
SHOW STATUS
SHOW TABLE STATUS
SHOW TABLES
SHOW VARIABLES
SHOW WARNINGS
START SLAVE
START TRANSACTION
STOP SLAVE
TRUNCATE TABLE
UNION
UNLOCK TABLES
USE
String Functions
AES_DECRYPT
AES_ENCRYPT
ASCII
BIN
BINARY
BIT_LENGTH
CHAR
CHAR_LENGTH
CHARACTER_LENGTH
COMPRESS
CONCAT
CONCAT_WS
CONV
DECODE
DES_DECRYPT
DES_ENCRYPT
ELT
ENCODE
ENCRYPT
EXPORT_SET
FIELD
FIND_IN_SET
HEX
INET_ATON
INET_NTOA
INSERT
INSTR
LCASE
LEFT
LENGTH
LOAD_FILE
LOCATE
LOWER
LPAD
LTRIM
MAKE_SET
MATCH AGAINST
MD5
MID
OCT
OCTET_LENGTH
OLD_PASSWORD
ORD
PASSWORD
POSITION
QUOTE
REPEAT
REPLACE
REVERSE
RIGHT
RPAD
RTRIM
SHA
SHA1
SOUNDEX
SPACE
STRCMP
SUBSTRING
SUBSTRING_INDEX
TRIM
UCASE
UNCOMPRESS
UNCOMPRESSED_LENGTH
UNHEX
UPPER
Date and Time Functions
ADDDATE
ADDTIME
CONVERT_TZ
CURDATE
CURRENT_DATE
CURRENT_TIME
CURRENT_TIMESTAMP
CURTIME
DATE
DATE_ADD
DATE_FORMAT
DATE_SUB
DATEDIFF
DAY
DAYNAME
DAYOFMONTH
DAYOFWEEK
DAYOFYEAR
EXTRACT
FROM_DAYS
FROM_UNIXTIME
GET_FORMAT
HOUR
LAST_DAY
LOCALTIME
LOCALTIMESTAMP
MAKEDATE
MAKETIME
MICROSECOND
MINUTE
MONTH
MONTHNAME
NOW
PERIOD_ADD
PERIOD_DIFF
QUARTER
SEC_TO_TIME
SECOND
STR_TO_DATE
SUBDATE
SUBTIME
SYSDATE
TIME
TIMEDIFF
TIMESTAMP
TIMESTAMPDIFF
TIMESTAMPADD
TIME_FORMAT
TIME_TO_SEC
TO_DAYS
UNIX_TIMESTAMP
UTC_DATE
UTC_TIME
UTC_TIMESTAMP
WEEK
WEEKDAY
WEEKOFYEAR
YEAR
YEARWEEK
Mathematical and Aggregate Functions
ABS
ACOS
ASIN
ATAN
ATAN2
AVG
BIT_AND
BIT_OR
BIT_XOR
CEIL
CEILING
COS
COT
COUNT
CRC32
DEGREES
EXP
FLOOR
FORMAT
GREATEST
GROUP_CONCAT
LEAST
LN
LOG
LOG2
LOG10
MAX
MIN
MOD
PI
POW
POWER
RADIANS
RAND
ROUND
SIGN
SIN
SQRT
STD
STDDEV
SUM
TAN
TRUNCATE
VARIANCE
Flow Control Functions
CASE
IF
IFNULL
NULLIF
Command-Line Utilities
comp_err
isamchk
make_binary_distribution
msql2mysql
my_print_defaults
myisamchk
myisamlog
myisampack
mysqlaccess
mysqladmin
mysqlbinlog
mysqlbug
mysqlcheck
mysqldump
mysqldumpslow
mysqlhotcopy
mysqlimport
mysqlshow
perror
Perl API - using functions and methods built into the Perl DBI with MySQL
available_drivers
begin_work
bind_col
bind_columns
bind_param
bind_param_array
bind_param_inout
can
clone
column_info
commit
connect
connect_cached
data_sources
disconnect
do
dump_results
err
errstr
execute
execute_array
execute_for_fetch
fetch
fetchall_arrayref
fetchall_hashref
fetchrow_array
fetchrow_arrayref
fetchrow_hashref
finish
foreign_key_info
func
get_info
installed_versions
last_insert_id
looks_like_number
neat
neat_list
parse_dsn
parse_trace_flag
parse_trace_flags
ping
prepare
prepare_cached
primary_key
primary_key_info
quote
quote_identifier
rollback
rows
selectall_arrayref
selectall_hashref
selectcol_arrayref
selectrow_array
selectrow_arrayref
selectrow_hashref
set_err
state
table_info
table_info_all
tables
trace
trace_msg
type_info
type_info_all
Attributes for Handles
PHP API - using functions built into PHP with MySQL
mysql_affected_rows
mysql_change_user
mysql_client_encoding
mysql_close
mysql_connect
mysql_create_db
mysql_data_seek
mysql_db_name
mysql_db_query
mysql_drop_db
mysql_errno
mysql_error
mysql_escape_string
mysql_fetch_array
mysql_fetch_assoc
mysql_fetch_field
mysql_fetch_lengths
mysql_fetch_object
mysql_fetch_row
mysql_field_flags
mysql_field_len
mysql_field_name
mysql_field_seek
mysql_field_table
mysql_field_type
mysql_free_result
mysql_get_client_info
mysql_get_host_info
mysql_get_proto_info
mysql_get_server_info
mysql_info
mysql_insert_id
mysql_list_dbs
mysql_list_fields
mysql_list_processes
mysql_list_tables
mysql_num_fields
mysql_num_rows
mysql_pconnect
mysql_ping
mysql_query
mysql_real_escape_string
mysql_result
mysql_select_db
mysql_stat
mysql_tablename
mysql_thread_id
mysql_unbuffered_query
Below when you see # it means from the unix shell. When you see mysql> it means from a MySQL prompt after logging into MySQL.
To login (from unix shell) use -h only if needed.
# [mysql dir]/bin/mysql -h hostname -u root -p
Create a database on the sql server.
mysql> create database [databasename];
List all databases on the sql server.
mysql> show databases;
Switch to a database.
mysql> use [db name];
To see all the tables in the db.
mysql> show tables;
To see database's field formats.
mysql> describe [table name];
To delete a db.
mysql> drop database [database name];
To delete a table.
mysql> drop table [table name];
Show all data in a table.
mysql> SELECT * FROM [table name];
Returns the columns and column information pertaining to the designated table.
mysql> show columns from [table name];
Show certain selected rows with the value "whatever".
mysql> SELECT * FROM [table name] WHERE [field name] = "whatever";
Show all records containing the name "Bob" AND the phone number '3444444'.
mysql> SELECT * FROM [table name] WHERE name = "Bob" AND phone_number = '3444444';
Show all records not containing the name "Bob" AND the phone number '3444444' order by the phone_number field.
mysql> SELECT * FROM [table name] WHERE name != "Bob" AND phone_number = '3444444' order by phone_number;
Show all records starting with the letters 'bob' AND the phone number '3444444'.
mysql> SELECT * FROM [table name] WHERE name like "Bob%" AND phone_number = '3444444';
Show all records starting with the letters 'bob' AND the phone number '3444444' limit to records 1 through 5.
mysql> SELECT * FROM [table name] WHERE name like "Bob%" AND phone_number = '3444444' limit 1,5;
Use a regular expression to find records. Use "REGEXP BINARY" to force case-sensitivity. This finds any record beginning with a.
mysql> SELECT * FROM [table name] WHERE rec RLIKE "^a";
Show unique records.
mysql> SELECT DISTINCT [column name] FROM [table name];
Show selected records sorted in an ascending (asc) or descending (desc).
mysql> SELECT [col1],[col2] FROM [table name] ORDER BY [col2] DESC;
Return number of rows.
mysql> SELECT COUNT(*) FROM [table name];
Sum column.
mysql> SELECT SUM(*) FROM [table name];
Join tables on common columns.
mysql> select lookup.illustrationid, lookup.personid,person.birthday from lookup left join person on lookup.personid=person.personid=statement to join birthday in person table with primary illustration id;
Creating a new user. Login as root. Switch to the MySQL db. Make the user. Update privs.
# mysql -u root -p
mysql> use mysql;
mysql> INSERT INTO user (Host,User,Password) VALUES('%','username',PASSWORD('password'));
mysql> flush privileges;
Change a users password from unix shell.
# [mysql dir]/bin/mysqladmin -u username -h hostname.blah.org -p password 'new-password'
Change a users password from MySQL prompt. Login as root. Set the password. Update privs.
# mysql -u root -p
mysql> SET PASSWORD FOR 'user'@'hostname' = PASSWORD('passwordhere');
mysql> flush privileges;
Recover a MySQL root password. Stop the MySQL server process. Start again with no grant tables. Login to MySQL as root. Set new password. Exit MySQL and restart MySQL server.
# /etc/init.d/mysql stop
# mysqld_safe --skip-grant-tables &
# mysql -u root
mysql> use mysql;
mysql> update user set password=PASSWORD("newrootpassword") where User='root';
mysql> flush privileges;
mysql> quit
# /etc/init.d/mysql stop
# /etc/init.d/mysql start
Set a root password if there is on root password.
# mysqladmin -u root password newpassword
Update a root password.
# mysqladmin -u root -p oldpassword newpassword
Allow the user "bob" to connect to the server from localhost using the password "passwd". Login as root. Switch to the MySQL db. Give privs. Update privs.
# mysql -u root -p
mysql> use mysql;
mysql> grant usage on *.* to bob@localhost identified by 'passwd';
mysql> flush privileges;
Give user privilages for a db. Login as root. Switch to the MySQL db. Grant privs. Update privs.
# mysql -u root -p
mysql> use mysql;
mysql> INSERT INTO db (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv) VALUES ('%','databasename','username','Y','Y','Y','Y','Y','N');
mysql> flush privileges;
or
mysql> grant all privileges on databasename.* to username@localhost;
mysql> flush privileges;
To update info already in a table.
mysql> UPDATE [table name] SET Select_priv = 'Y',Insert_priv = 'Y',Update_priv = 'Y' where [field name] = 'user';
Delete a row(s) from a table.
mysql> DELETE from [table name] where [field name] = 'whatever';
Update database permissions/privilages.
mysql> flush privileges;
Delete a column.
mysql> alter table [table name] drop column [column name];
Add a new column to db.
mysql> alter table [table name] add column [new column name] varchar (20);
Change column name.
mysql> alter table [table name] change [old column name] [new column name] varchar (50);
Make a unique column so you get no dupes.
mysql> alter table [table name] add unique ([column name]);
Make a column bigger.
mysql> alter table [table name] modify [column name] VARCHAR(3);
Delete unique from table.
mysql> alter table [table name] drop index [colmn name];
Load a CSV file into a table.
mysql> LOAD DATA INFILE '/tmp/filename.csv' replace INTO TABLE [table name] FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' (field1,field2,field3);
Dump all databases for backup. Backup file is sql commands to recreate all db's.
# [mysql dir]/bin/mysqldump -u root -ppassword --opt >/tmp/alldatabases.sql
Dump one database for backup.
# [mysql dir]/bin/mysqldump -u username -ppassword --databases databasename >/tmp/databasename.sql
Dump a table from a database.
# [mysql dir]/bin/mysqldump -c -u username -ppassword databasename tablename > /tmp/databasename.tablename.sql
Restore database (or database table) from backup.
# [mysql dir]/bin/mysql -u username -ppassword databasename < /tmp/databasename.sql Create Table Example 1. mysql> CREATE TABLE [table name] (firstname VARCHAR(20), middleinitial VARCHAR(3), lastname VARCHAR(35),suffix VARCHAR(3),officeid VARCHAR(10),userid VARCHAR(15),username VARCHAR(8),email VARCHAR(35),phone VARCHAR(25), groups VARCHAR(15),datestamp DATE,timestamp time,pgpemail VARCHAR(255));
Create Table Example 2.
mysql> create table [table name] (personid int(50) not null auto_increment primary key,firstname varchar(35),middlename varchar(50),lastnamevarchar(50) default 'bato');
MYSQL Statements and clauses
ALTER DATABASE
ALTER TABLE
ALTER VIEW
ANALYZE TABLE
BACKUP TABLE
CACHE INDEX
CHANGE MASTER TO
CHECK TABLE
CHECKSUM TABLE
COMMIT
CREATE DATABASE
CREATE INDEX
CREATE TABLE
CREATE VIEW
DELETE
DESCRIBE
DO
DROP DATABASE
DROP INDEX
DROP TABLE
DROP USER
DROP VIEW
EXPLAIN
FLUSH
GRANT
HANDLER
INSERT
JOIN
KILL
LOAD DATA FROM MASTER
LOAD DATA INFILE
LOAD INDEX INTO CACHE
LOAD TABLE...FROM MASTER
LOCK TABLES
OPTIMIZE TABLE
PURGE MASTER LOGS
RENAME TABLE
REPAIR TABLE
REPLACE
RESET
RESET MASTER
RESET SLAVE
RESTORE TABLE
REVOKE
ROLLBACK
ROLLBACK TO SAVEPOINT
SAVEPOINT
SELECT
SET
SET PASSWORD
SET SQL_LOG_BIN
SET TRANSACTION
SHOW BINLOG EVENTS
SHOW CHARACTER SET
SHOW COLLATION
SHOW COLUMNS
SHOW CREATE DATABASE
SHOW CREATE TABLE
SHOW CREATE VIEW
SHOW DATABASES
SHOW ENGINES
SHOW ERRORS
SHOW GRANTS
SHOW INDEX
SHOW INNODB STATUS
SHOW LOGS
SHOW MASTER LOGS
SHOW MASTER STATUS
SHOW PRIVILEGES
SHOW PROCESSLIST
SHOW SLAVE HOSTS
SHOW SLAVE STATUS
SHOW STATUS
SHOW TABLE STATUS
SHOW TABLES
SHOW VARIABLES
SHOW WARNINGS
START SLAVE
START TRANSACTION
STOP SLAVE
TRUNCATE TABLE
UNION
UNLOCK TABLES
USE
String Functions
AES_DECRYPT
AES_ENCRYPT
ASCII
BIN
BINARY
BIT_LENGTH
CHAR
CHAR_LENGTH
CHARACTER_LENGTH
COMPRESS
CONCAT
CONCAT_WS
CONV
DECODE
DES_DECRYPT
DES_ENCRYPT
ELT
ENCODE
ENCRYPT
EXPORT_SET
FIELD
FIND_IN_SET
HEX
INET_ATON
INET_NTOA
INSERT
INSTR
LCASE
LEFT
LENGTH
LOAD_FILE
LOCATE
LOWER
LPAD
LTRIM
MAKE_SET
MATCH AGAINST
MD5
MID
OCT
OCTET_LENGTH
OLD_PASSWORD
ORD
PASSWORD
POSITION
QUOTE
REPEAT
REPLACE
REVERSE
RIGHT
RPAD
RTRIM
SHA
SHA1
SOUNDEX
SPACE
STRCMP
SUBSTRING
SUBSTRING_INDEX
TRIM
UCASE
UNCOMPRESS
UNCOMPRESSED_LENGTH
UNHEX
UPPER
Date and Time Functions
ADDDATE
ADDTIME
CONVERT_TZ
CURDATE
CURRENT_DATE
CURRENT_TIME
CURRENT_TIMESTAMP
CURTIME
DATE
DATE_ADD
DATE_FORMAT
DATE_SUB
DATEDIFF
DAY
DAYNAME
DAYOFMONTH
DAYOFWEEK
DAYOFYEAR
EXTRACT
FROM_DAYS
FROM_UNIXTIME
GET_FORMAT
HOUR
LAST_DAY
LOCALTIME
LOCALTIMESTAMP
MAKEDATE
MAKETIME
MICROSECOND
MINUTE
MONTH
MONTHNAME
NOW
PERIOD_ADD
PERIOD_DIFF
QUARTER
SEC_TO_TIME
SECOND
STR_TO_DATE
SUBDATE
SUBTIME
SYSDATE
TIME
TIMEDIFF
TIMESTAMP
TIMESTAMPDIFF
TIMESTAMPADD
TIME_FORMAT
TIME_TO_SEC
TO_DAYS
UNIX_TIMESTAMP
UTC_DATE
UTC_TIME
UTC_TIMESTAMP
WEEK
WEEKDAY
WEEKOFYEAR
YEAR
YEARWEEK
Mathematical and Aggregate Functions
ABS
ACOS
ASIN
ATAN
ATAN2
AVG
BIT_AND
BIT_OR
BIT_XOR
CEIL
CEILING
COS
COT
COUNT
CRC32
DEGREES
EXP
FLOOR
FORMAT
GREATEST
GROUP_CONCAT
LEAST
LN
LOG
LOG2
LOG10
MAX
MIN
MOD
PI
POW
POWER
RADIANS
RAND
ROUND
SIGN
SIN
SQRT
STD
STDDEV
SUM
TAN
TRUNCATE
VARIANCE
Flow Control Functions
CASE
IF
IFNULL
NULLIF
Command-Line Utilities
comp_err
isamchk
make_binary_distribution
msql2mysql
my_print_defaults
myisamchk
myisamlog
myisampack
mysqlaccess
mysqladmin
mysqlbinlog
mysqlbug
mysqlcheck
mysqldump
mysqldumpslow
mysqlhotcopy
mysqlimport
mysqlshow
perror
Perl API - using functions and methods built into the Perl DBI with MySQL
available_drivers
begin_work
bind_col
bind_columns
bind_param
bind_param_array
bind_param_inout
can
clone
column_info
commit
connect
connect_cached
data_sources
disconnect
do
dump_results
err
errstr
execute
execute_array
execute_for_fetch
fetch
fetchall_arrayref
fetchall_hashref
fetchrow_array
fetchrow_arrayref
fetchrow_hashref
finish
foreign_key_info
func
get_info
installed_versions
last_insert_id
looks_like_number
neat
neat_list
parse_dsn
parse_trace_flag
parse_trace_flags
ping
prepare
prepare_cached
primary_key
primary_key_info
quote
quote_identifier
rollback
rows
selectall_arrayref
selectall_hashref
selectcol_arrayref
selectrow_array
selectrow_arrayref
selectrow_hashref
set_err
state
table_info
table_info_all
tables
trace
trace_msg
type_info
type_info_all
Attributes for Handles
PHP API - using functions built into PHP with MySQL
mysql_affected_rows
mysql_change_user
mysql_client_encoding
mysql_close
mysql_connect
mysql_create_db
mysql_data_seek
mysql_db_name
mysql_db_query
mysql_drop_db
mysql_errno
mysql_error
mysql_escape_string
mysql_fetch_array
mysql_fetch_assoc
mysql_fetch_field
mysql_fetch_lengths
mysql_fetch_object
mysql_fetch_row
mysql_field_flags
mysql_field_len
mysql_field_name
mysql_field_seek
mysql_field_table
mysql_field_type
mysql_free_result
mysql_get_client_info
mysql_get_host_info
mysql_get_proto_info
mysql_get_server_info
mysql_info
mysql_insert_id
mysql_list_dbs
mysql_list_fields
mysql_list_processes
mysql_list_tables
mysql_num_fields
mysql_num_rows
mysql_pconnect
mysql_ping
mysql_query
mysql_real_escape_string
mysql_result
mysql_select_db
mysql_stat
mysql_tablename
mysql_thread_id
mysql_unbuffered_query
Thursday, July 1, 2010
Flex White Papers
Adobe Flex White Papers
"Creating Next Generation SAP Analytics Apps..."
http://www.adobe.com/products/flex/whitepapers/pdfs/sap_flex.pdf
White paper: "Creating Next Generation SAP Analytics Applications with SAP NetWeaver and Macromedia Flex," by Christophe Coenaets, Vincent Mendicino, Natalia Shmoilova, and Dirk Wodtke. Discusses the problem, overviews the solution, SAP NetWeaver, the SAP NetWeaver Visual Composer, Visual Composer architecture, Visual Composer modeling concepts, Visual Composer backend connectivity, Visual Composer UI generation, Macromedia Flex; standards-based, highly productive programming model, class library, runtime services, code highlights, architecture, creating a SAP analytics application, and running the SAP analytics application.
Flex Application Performance: Tips and Techniques
http://www.adobe.com/devnet/flex/articles/client_perf/client_server_performance.pdf
White Paper: "Flex Application Performance: Tips and Techniques for Improving Client Application and Server Performance," by Brandon Purcell and Deepa Subramanian. Discusses requirements, feedback and support, architecting Flex applications that perform well, Flash Player; using layouts, hierarchy, and containment properly, nesting containers, absolute positioning and sizing, grid containers, redundancies to avoid, using deferred instantiation to improve perceived performance, progressive layout, handling large data sets, playing complex effects smoothly, achieving great performance with runtime styles, using dynamically repeating controls, HorizontalList and TileList controls, improving performance of charting components, performance tuning and profiling your own Flex application, using runtime shared libraries (RSLs), the ActionScript profiler, calculating application initialization time, caching in the Flex presentation server, using the JSP tag library, deployment options, load testing, load-testing tools, and load testing examples.
"Capacity Planning for Adobe's Flex™ 1.5"
http://www.adobe.com/products/flex/whitepapers/pdfs/flex_capacity_planning.pdf
White paper: "Capacity Planning for Adobe's Macromedia Flex™ 1.5," by Alex Glosband and Bob Tierney. Discusses a capacity planning overview, Flex architectural overview, application server tuning, Flex scalability, MXML compilation, proxy performance tuning, load testing, baseline application, server configurations (Solaris and Windows), database configuration, client configuration, network configuration, vertical scalability, and horizontal scalability.
Adobe Flash Security and Enterprise Solutions"
http://www.adobe.com/products/flex/whitepapers/pdfs/flashsecurity.pdf
White paper: "Adobe Flash Security and Adobe Enterprise Solutions," from Adobe. Discusses the Flash security model, authentication, Adobe® Breeze™, access control, server-side access controls, client-side access controls, FlashCast, unauthorized access to host system resources, unauthorized access to data, unauthorized access to private user information, malicious code, protection against malicious and activity, minimized SQL injection and cross-scripting vulnerabilities, data transport, standards compliance, wireless security, SSL accelerators and load balancers, and encrypted tunneling.
Abobe® Flex™ Data Structures 2
http://www.adobe.com/products/flex/whitepapers/pdfs/flex2wp_fdscapacityplanning.pdf
White paper: "Abobe® Flex™ Data Structures 2: Capacity Planning," from Adobe. Discusses a capacity planning overview, Flex architecture overview, HTTP service, web service (SOAP/HTTP), remote objects (action message format (AMF)), messaging, application server tuning, Flex scalability, MXML compilation, proxy performance tuning, scalability test methodology description, test system configurations, baseline application performance results, data service scalability, and sizing an application.
Adobe® Flex™ 2: Technical White Paper
http://www.adobe.com/products/flex/whitepapers/pdfs/flex2wp_technicaloverview.pdf
White paper: "Adobe® Flex™ 2: Technical White Paper," from Adobe. Discusses the revolution of rich Internet applications (RIAs), the need for a service-oriented client, high-performance, cross-platform runtime; integrated support for text, graphics, animation and audio/video, enterprise data integration, support for disconnected computing, security and reliability, the RIA development model, an introduction to Adobe Flex, Flex and the Adobe engagement platform, a Flex product line overview, Flash player, Flex runtime architecture, Flex development model and application framework, MXML (the Flex markup language), ActionScript 3.0, the Flex class library, visual components, service components, Flex behaviors, developer tools, Flex Data Services, Flex Message Services, RPC Services, Data Management Services, the Flex Builder, code editing, visual layout and skinning, interactive debugging, extensibility, Flex target applications, product configuration and selection, process integration, guided self-service, Flex and other technologies (Ajax, portals, Microsoft .NET platform), developer resources, security, and sample applications
"Creating Next Generation SAP Analytics Apps..."
http://www.adobe.com/products/flex/whitepapers/pdfs/sap_flex.pdf
White paper: "Creating Next Generation SAP Analytics Applications with SAP NetWeaver and Macromedia Flex," by Christophe Coenaets, Vincent Mendicino, Natalia Shmoilova, and Dirk Wodtke. Discusses the problem, overviews the solution, SAP NetWeaver, the SAP NetWeaver Visual Composer, Visual Composer architecture, Visual Composer modeling concepts, Visual Composer backend connectivity, Visual Composer UI generation, Macromedia Flex; standards-based, highly productive programming model, class library, runtime services, code highlights, architecture, creating a SAP analytics application, and running the SAP analytics application.
Flex Application Performance: Tips and Techniques
http://www.adobe.com/devnet/flex/articles/client_perf/client_server_performance.pdf
White Paper: "Flex Application Performance: Tips and Techniques for Improving Client Application and Server Performance," by Brandon Purcell and Deepa Subramanian. Discusses requirements, feedback and support, architecting Flex applications that perform well, Flash Player; using layouts, hierarchy, and containment properly, nesting containers, absolute positioning and sizing, grid containers, redundancies to avoid, using deferred instantiation to improve perceived performance, progressive layout, handling large data sets, playing complex effects smoothly, achieving great performance with runtime styles, using dynamically repeating controls, HorizontalList and TileList controls, improving performance of charting components, performance tuning and profiling your own Flex application, using runtime shared libraries (RSLs), the ActionScript profiler, calculating application initialization time, caching in the Flex presentation server, using the JSP tag library, deployment options, load testing, load-testing tools, and load testing examples.
"Capacity Planning for Adobe's Flex™ 1.5"
http://www.adobe.com/products/flex/whitepapers/pdfs/flex_capacity_planning.pdf
White paper: "Capacity Planning for Adobe's Macromedia Flex™ 1.5," by Alex Glosband and Bob Tierney. Discusses a capacity planning overview, Flex architectural overview, application server tuning, Flex scalability, MXML compilation, proxy performance tuning, load testing, baseline application, server configurations (Solaris and Windows), database configuration, client configuration, network configuration, vertical scalability, and horizontal scalability.
Adobe Flash Security and Enterprise Solutions"
http://www.adobe.com/products/flex/whitepapers/pdfs/flashsecurity.pdf
White paper: "Adobe Flash Security and Adobe Enterprise Solutions," from Adobe. Discusses the Flash security model, authentication, Adobe® Breeze™, access control, server-side access controls, client-side access controls, FlashCast, unauthorized access to host system resources, unauthorized access to data, unauthorized access to private user information, malicious code, protection against malicious and activity, minimized SQL injection and cross-scripting vulnerabilities, data transport, standards compliance, wireless security, SSL accelerators and load balancers, and encrypted tunneling.
Abobe® Flex™ Data Structures 2
http://www.adobe.com/products/flex/whitepapers/pdfs/flex2wp_fdscapacityplanning.pdf
White paper: "Abobe® Flex™ Data Structures 2: Capacity Planning," from Adobe. Discusses a capacity planning overview, Flex architecture overview, HTTP service, web service (SOAP/HTTP), remote objects (action message format (AMF)), messaging, application server tuning, Flex scalability, MXML compilation, proxy performance tuning, scalability test methodology description, test system configurations, baseline application performance results, data service scalability, and sizing an application.
Adobe® Flex™ 2: Technical White Paper
http://www.adobe.com/products/flex/whitepapers/pdfs/flex2wp_technicaloverview.pdf
White paper: "Adobe® Flex™ 2: Technical White Paper," from Adobe. Discusses the revolution of rich Internet applications (RIAs), the need for a service-oriented client, high-performance, cross-platform runtime; integrated support for text, graphics, animation and audio/video, enterprise data integration, support for disconnected computing, security and reliability, the RIA development model, an introduction to Adobe Flex, Flex and the Adobe engagement platform, a Flex product line overview, Flash player, Flex runtime architecture, Flex development model and application framework, MXML (the Flex markup language), ActionScript 3.0, the Flex class library, visual components, service components, Flex behaviors, developer tools, Flex Data Services, Flex Message Services, RPC Services, Data Management Services, the Flex Builder, code editing, visual layout and skinning, interactive debugging, extensibility, Flex target applications, product configuration and selection, process integration, guided self-service, Flex and other technologies (Ajax, portals, Microsoft .NET platform), developer resources, security, and sample applications
Flex Associative Arrays
In this example I will be showing the use of associative array to change the content of a DataGrid control. Associative arrays work just like regular arrays except they use an Object (normally a string) as their index. For example, inventory['price'] = 12.99. I will be creating an associative array of ArrayCollections. Each of these ArrayCollections will be used to populate a DataGrid.
First let's create the ComboBox and the DataGrid controls:
dataProvider="{categories}" change="changeCBHandler()"> dataProvider="{searchList}">
Now let's look at the code used in these examples. Comments are provided throughout the code.
import mx.collections.ArrayCollection;//Array for the ComboBox control
[Bindable]
private var categories:ArrayCollection =new ArrayCollection(["Search", "News"]);
//Array collections to be placed in the Associative Array[Bindable]private var searchList:ArrayCollection = new ArrayCollection([{name:'Yahoo',url:'http://yahoo.com'},{name:'Google',url:'http://google.com'},{name:'Ask', url:'http://ask.com'}]);[Bindable]private var newsList:ArrayCollection = new ArrayCollection([{name:'CNN', url:'http://cnn.com'},{name:'Yahoo News', url:'http://news.yahoo.com'},{name:'CNet', url:'http://cnet.com'}]);//Associative Array[Bindable]private var allLists:Array = new Array();//Intialization of the Associative array//to be called on applicationComplete eventprivate function loadAllLists():void { allLists['Search'] = searchList;allLists['News'] = newsList;}//Event handler for the change eventprivate function changeCBHandler():void {var category:String = cbCategory.selectedLabel;dgSites.dataProvider = allLists[category]; }]]>Here is the complete application. Right click to see the complete source code.
First let's create the ComboBox and the DataGrid controls:
dataProvider="{categories}" change="changeCBHandler()"> dataProvider="{searchList}">
Now let's look at the code used in these examples. Comments are provided throughout the code.
import mx.collections.ArrayCollection;//Array for the ComboBox control
[Bindable]
private var categories:ArrayCollection =new ArrayCollection(["Search", "News"]);
//Array collections to be placed in the Associative Array[Bindable]private var searchList:ArrayCollection = new ArrayCollection([{name:'Yahoo',url:'http://yahoo.com'},{name:'Google',url:'http://google.com'},{name:'Ask', url:'http://ask.com'}]);[Bindable]private var newsList:ArrayCollection = new ArrayCollection([{name:'CNN', url:'http://cnn.com'},{name:'Yahoo News', url:'http://news.yahoo.com'},{name:'CNet', url:'http://cnet.com'}]);//Associative Array[Bindable]private var allLists:Array = new Array();//Intialization of the Associative array//to be called on applicationComplete eventprivate function loadAllLists():void { allLists['Search'] = searchList;allLists['News'] = newsList;}//Event handler for the change eventprivate function changeCBHandler():void {var category:String = cbCategory.selectedLabel;dgSites.dataProvider = allLists[category]; }]]>Here is the complete application. Right click to see the complete source code.
Friday, May 14, 2010
CSS round Corners -2
====
div.box { overflow:hidden} /* IE font-size fix */
/* MIDDLE */
div.box.body div.box.right {
background-image:url(m_r.png); background-position: right; background-repeat: repeat-y;
}
div.box.body div.box.left {
background-image:url(m_l.png); background-position: left; background-repeat: repeat-y;
}
div.box.body div.box.center {
background-image:url(m_c.png); margin-left: 12px; margin-right: 12px;
}
/* TOP */
div.box.head div.box.right {
background-image:url(t_r.png); background-position: top right; background-repeat: no-repeat; height:12px;
}
div.box.head div.box.left {
background-image:url(t_l.png); background-position: top left; background-repeat: no-repeat; height:12px;
}
div.box.head div.box.center {
background-image:url(t_c.png); height:12px; margin-left: 12px; margin-right: 12px;
}
/* BOTTOM */
div.box.foot div.box.right {
background-image:url(b_r.png); background-position: right bottom; background-repeat: no-repeat; height:12px;
}
div.box.foot div.box.left {
background-image:url(b_l.png); background-position: left bottom; background-repeat: no-repeat; height:12px;
}
div.box.foot div.box.center {
background-image:url(b_c.png); margin-left: 12px; margin-right: 12px; height:12px;
}
===================
==============
div.box { overflow:hidden} /* IE font-size fix */
/* MIDDLE */
div.box.body div.box.right {
background-image:url(m_r.png); background-position: right; background-repeat: repeat-y;
}
div.box.body div.box.left {
background-image:url(m_l.png); background-position: left; background-repeat: repeat-y;
}
div.box.body div.box.center {
background-image:url(m_c.png); margin-left: 12px; margin-right: 12px;
}
/* TOP */
div.box.head div.box.right {
background-image:url(t_r.png); background-position: top right; background-repeat: no-repeat; height:12px;
}
div.box.head div.box.left {
background-image:url(t_l.png); background-position: top left; background-repeat: no-repeat; height:12px;
}
div.box.head div.box.center {
background-image:url(t_c.png); height:12px; margin-left: 12px; margin-right: 12px;
}
/* BOTTOM */
div.box.foot div.box.right {
background-image:url(b_r.png); background-position: right bottom; background-repeat: no-repeat; height:12px;
}
div.box.foot div.box.left {
background-image:url(b_l.png); background-position: left bottom; background-repeat: no-repeat; height:12px;
}
div.box.foot div.box.center {
background-image:url(b_c.png); margin-left: 12px; margin-right: 12px; height:12px;
}
===================
TEXT
==============
CSS Round Corners
http://snipplr.com/view/830/css-rounded-corners/
CSS
/* set millions of background images */
.rbroundbox { background: url(nt.gif) repeat; }
.rbtop div { background: url(tl.gif) no-repeat top left; }
.rbtop { background: url(tr.gif) no-repeat top right; }
.rbbot div { background: url(bl.gif) no-repeat bottom left; }
.rbbot { background: url(br.gif) no-repeat bottom right; }
/* height and width stuff, width not really nessisary. */
.rbtop div, .rbtop, .rbbot div, .rbbot {
width: 100%;
height: 7px;
font-size: 1px;
}
.rbcontent { margin: 0 7px; }
.rbroundbox { width: 50%; margin: 1em auto; }
CSS
/* set millions of background images */
.rbroundbox { background: url(nt.gif) repeat; }
.rbtop div { background: url(tl.gif) no-repeat top left; }
.rbtop { background: url(tr.gif) no-repeat top right; }
.rbbot div { background: url(bl.gif) no-repeat bottom left; }
.rbbot { background: url(br.gif) no-repeat bottom right; }
/* height and width stuff, width not really nessisary. */
.rbtop div, .rbtop, .rbbot div, .rbbot {
width: 100%;
height: 7px;
font-size: 1px;
}
.rbcontent { margin: 0 7px; }
.rbroundbox { width: 50%; margin: 1em auto; }
Lorem ipsum dolor sit amet,
consectetuer adipiscing elit. Duis
ornare ultricies libero. Donec
fringilla, eros at dapibus fermentum,
tellus tellus auctor erat, vitae porta
magna libero sed libero. Mauris sed leo.
Aliquam aliquam. Maecenas vestibulum.
php codes
Remove whitespace from a text string using the PHP trim function
Description
If you use a form on your site then you'll know that user input can often have white space before or after the text as the person filling in the form field sometimes accidentally adds spaces. This handy function will remove the whitespace from the beginning or end of the string.
The code
====================================================================
class MySQLDB{ /* Class constructor */ function MySQLDB()
{
$this->connection = mysql_connect(DB_SERVER, DB_USER, DB_PASS) or die(mysql_error()); mysql_select_db(DB_NAME, $this->connection) or die(mysql_error());
}
function query($query)
{
return mysql_query($query, $this->connection);
}
};
$database = new MySQLDB;
$result = $database->query($query);
$num_rows = mysql_num_rows($result);
$post_title = mysql_result($result,0,"title");
================================================================
get defined variables
echo "
========================================
1) Add this to the top of header.php
2) Add this to the functions.php page
(omit tags if they already exist)
global $bp;
if (bp_is_register_page() bp_is_activation_page())
return;
if(!bp_is_blog_page() && !is_user_logged_in())
{
bp_core_redirect( $bp->root_domain .'/'. BP_REGISTER_SLUG );
}
}
add_action( 'walled_garden', 'sh_walled_garden' );
?>
Description
If you use a form on your site then you'll know that user input can often have white space before or after the text as the person filling in the form field sometimes accidentally adds spaces. This handy function will remove the whitespace from the beginning or end of the string.
The code
====================================================================
class MySQLDB{ /* Class constructor */ function MySQLDB()
{
$this->connection = mysql_connect(DB_SERVER, DB_USER, DB_PASS) or die(mysql_error()); mysql_select_db(DB_NAME, $this->connection) or die(mysql_error());
}
function query($query)
{
return mysql_query($query, $this->connection);
}
};
$database = new MySQLDB;
$result = $database->query($query);
$num_rows = mysql_num_rows($result);
$post_title = mysql_result($result,0,"title");
================================================================
get defined variables
echo "
";print_r(get_defined_vars());echo "";
========================================
1) Add this to the top of header.php
2) Add this to the functions.php page
(omit tags if they already exist)
global $bp;
if (bp_is_register_page() bp_is_activation_page())
return;
if(!bp_is_blog_page() && !is_user_logged_in())
{
bp_core_redirect( $bp->root_domain .'/'. BP_REGISTER_SLUG );
}
}
add_action( 'walled_garden', 'sh_walled_garden' );
?>
Subscribe to:
Posts (Atom)