* PHP Programming
- Using PHP to parse XML, all tags should be capitalized;
- Handling File Uploading:
- <form name='' enctype="multipart/form-data" action='' method=''>
- $HTTP_POST_FILES['filename']['name']-The original filename on the client machine;
- $HTTP_POST_FILES['filename']['type']-The mime type of the file:image/gif;
- $HTTP_POST_FILES['filename']['size']-The size in bytes of the uploaded file;
- $HTTP_POST_FILES['filename']['tmp_name']-The temporary filename stored on the server.
- Multiple Files Uploading:
-
<form action="file-upload.php" method="post" enctype="multipart/form-data">
<input name="userfile[]" type="file">
<input name="userfile[]" type="file">
<input type="submit" value="Send files">
</form>
-
$HTTP_POST_FILES['filename']['name'][0];
$HTTP_POST_FILES['filename']['name'][1];
$HTTP_POST_FILES['filename']['type'][0];
$HTTP_POST_FILES['filename']['type'][1];
$HTTP_POST_FILES['filename']['size'][0];
$HTTP_POST_FILES['filename']['size'][1];
$HTTP_POST_FILES['filename']['tmp_name'][0];
$HTTP_POST_FILES['filename']['tmp_name'][1];
- Use fopen to check the URL link:
$file = fopen ("http://www.php.net/", "r")
if (!$file)
{
echo "Unable to open remote file.";
exit;
}
- Storing Data on a Remote Server:
$file = fopen ('ftp://user:password@ftp.example.com/path/to/file', "w");
- PHP Class: use arrow instead of dot.
- setcookie("cookiename",variable) to set cookie;
- setcookie("cookiename") to unset cookie;
- use addslashes() before storing data in database;
- use stripslashes() to show content from database;
- use utf8_encode and utf8_decode to store and retrieve Chinese Character from database correctly;
- sort(): string1,string10,string11,string2
- natsort():string1,string2,string10,string11
- PHP mail():Note: Make sure you do not have any newline characters in the to or subject, or the mail may not be sent properly
- If you use JavaScript inside PHP code:
<?php
echo "Script Language='JavaScript1.2'>";
echo "window.alert('Mail was sent successfully.')";
echo "</Script>";
echo "<Script Language='JavaScript1.2'>";
echo "window.location='$WEBHOME'";
echo "</Script>";
?>
-
Install extra module to existing php
- Method #1:
try apt-cache search php5
If you find the package: apt-get install php5-imap
- Method #2:
Use PHPIZE to add extension for PHP
1. install php5-dev, apt-get install php5-dev
2. download the source code for php: apt-get source php5
2. find the module source folder in ext, for example in imap
3. phpize
4. ./configure
5. make
6. make install
7. check your php library folder (/usr/lib/php5/), and edit php.ini to enable imap.so
- apt-cache search php5
- How to install pdflib-lite to php5
1. Download the PDFLIB-Lite at http://www.pdflib.com/download/pdflib-family/pdflib-lite/
2. ./configure
3. ./make
4. ./make install
5. pecl install pdflib
pdflib path: /usr/local
pdf.so should be added to php5 extension folder
6. edit php.ini, add pdf.so extension support
7. restart apache 2
|
* MySQL Administration and Programming
- mysql>load data infile "/tmp/filename" into table tablename fields terminated by ',' (col1,col2,col3);
- mysql>select a,b,a+b into outfile "/tmp/result.txt" fields terminated by ',' optionally enclosed by '"' lines terminated by "\n" from tablename;
- mysql>update tablename set blob_col=load_file ("/tmp/picture") where id=1;
- mysql>insert into tablename (field1,filed2) select * from table where condition;
- mysql>rename table old_tablename1 to new_tablename1, old_table2 to new_table2;
- mysql>create index index_name on tablename (column1(length));
- mysql>alter table tablename drop primary key;
- mysql>alter table tablename change column oldname newname definition
- mysql>alter table tablename modify column colname definition
- mysql>rename table oldname newname;
- drop table if exists tablename;
- Using Variable:
mysql>select @max_num:=max(col1) from table1;
mysql>select * from table1 where col1=@max_num;
- BLOB: store binary data
- TEXT: store large amount of text data
- DATETIME: 'yyyy-mm-dd hh:mm:ss'
- DATE: yyyy-mm-dd
-
timestamp(14):yyyymmddhhmmss; timestamp(12):yymmddhhmmss;
timestamp(8):yyyy-mm-dd;timestamp(6):yymmdd
- TIME: 'hh:mm:ss'
- YEAR: yyyy
- mysql>select now(); output>> yyyy-mm-dd hh:mm:ss
- mysql>select curdate(); output>>yyyy-mm-dd
- mysql>select date_format(now(),'%W %M %Y');
- mysql>select * from tablename limit 1,5: start from row 1, get 5 rows;
- SHELL$mysql < batch_file > output.file
- mysql>source /directory/file.sql
- SHELL$mysql -h host -u username -p -e 'select * from db_name.tbl_name'
- Backup: SHELL$mysqldump -h webserver -p databasename > /dir/dababasename.sql
SHELL$mysqldump -h webserver -p databasename tablename > /dir/dababase_table.sql
- Backup all databases:SHELL$mysqldump --all-databases > /dir/mysql.sql
-
Check Table: Must have the root permission, goto /var/lib/mysql/databasename/
SHELL#myisamchk tbl_name //(normally used for checking)
SHELL#myisamchk -m tbl_name //(checking checksum)
SHELL#myisamchk -e tbl_name //(complete and thorough check)
-
Repair Table:Must have the root permission, goto /var/lib/mysql/databasename/
SHELL#myisamchk -r -q tbl_name //(quick recover)
SHELL#myisamchk --safe-recover tbl_name //(if the above fails,use this)
-
Optimize Table:
mysql>optimize table tbl_name
-
Analyze Table:
mysql>analyze table tbl_name
-
Show Systax
mysql>show databases, show tables [from db_name]
mysql>show columns from tbl_name [from db_name]
mysql>show index from tbl_name [from db_name]
mysql>show table status [from db_name](get all tables' size)
mysql>show status, show variables, show processlist
mysql>show grants for user_name
- show processlist
- show variables
- in my.cnf: add
[mysqld]
set-variable = max_connections=500
set-variable = max_user_connections=500
set-variable = table_cache=1200
-
How to reset root password:
1. /etc/init.d/mysqld stop
2. mysqld_safe --skip-grant-tables
3. go to mysql user table reset the password
|
* PostgreSQL Administration and Programming
- Links:
Redhat Database(pgsql) |
PostgreSQL 7.3.4 Documents |
PostgreSQL Introductions and Concepts
- Make sure that in the file /var/lib/pgsql/data/pg_hba.conf, you have defined the access privilege for your machine.
You have to restart your machine to make this effective.
- PostgreSQL Server user: 'postgres', su to 'root' first, and then su to 'postgres'
Root can shutdown the PostgreSQL Server.
Only 'postgres' can restart the PostgreSQL server.
- Shutdown the PostgreSQL server: $ pg_ctl stop -D $PGDATA
- Start the PostgreSQL server: $ postmaster -i -D $PGDATA (or change postgresql.conf to allow TCPIP connection)
- dbname# \c dbname (connect to another database)
- Some details different from MySQL:
- Use integer instead of int(11); (no '(11)')
- Use smallint instead of tinyint(4); (no '(4)')
- define foreign key inline: department_id smallint references departments(id);
- Use CURRENT_DATE, CURRENT_TIME(with timezone) or CURRENT_TIMESTAMP instead of curdate(),now()
- select * from tablename limit 5 offset 10: start from row 10, get 5 rows;
- Use contrib/dbsize.sql to create function database_size('dbname');
- All large objects are saved inside a system table called pg_largeobject, but it is using bytea data type to save the binary data.
- create sequence customer_id_seq;
create table customer(id int default nextval('customer_id_seq'),name varchar(20),primary key(id));
- CASE: select firstname,CASE WHEN state='KY' THEN 'very close' WHEN state='TN' THEN 'close' else 'far' END as distance from customers;
- INSERT INTO ... SELECT FROM
INSERT INTO customer (name, city, state, country)
SELECT trim(firstname) || ' ' || lastname, city, state, 'USA'
FROM friend;
- Create a table using SELECT INTO
SELECT firstname, lastname, city, state INTO newfriend FROM friend;
CREATE TABLE newfriend AS SELECT firstname, lastname,city, state FROM friend.
- Rules to log table changes
CREATE RULE service_request_update AS -- UPDATE rule
ON UPDATE TO service_request
DO
INSERT INTO service_request_log (customer_id, description, mod_type)
VALUES (old.customer_id, old.description, 'U');
CREATE RULE service_request_delete AS -- DELETE rule
ON DELETE TO service_request
DO
INSERT INTO service_request_log (customer_id, description, mod_type)
VALUES (old.customer_id, old.description, 'D');
- Add plpgsql support:
1. Creata a function handler:
CREATE FUNCTION plpgsql_call_handler() RETURNS language_handler AS
'$libdir/plpgsql' LANGUAGE C;
2. Create the language 'plpgsql'
CREATE TRUSTED LANGUAGE plpgsql
HANDLER "plpgsql_call_handler";
3.grant usage to public:
GRANT USAGE ON LANGUAGE plpgsql TO public;
- Create View, functions(Stored Procedures) and Triggers:
create function get_one_area(integer) returns varchar
as
'select name from areas where id=cast($1 as smallint);' language 'sql';
create view all_stories_for_private
as
select id,title,posted_date,sp_goals,key_indicators,department,area_id from stories;
CREATE FUNCTION show_stories_for_private() RETURNS SETOF all_stories_for_private
as
'select * from all_stories_for_private;'
language 'sql';
select * from show_all_stories();
drop function get_areas(char,varchar);
drop type area_type;
create type area_type as (id int, name varchar);
create function get_areas(char,varchar) returns setof area_type
as
'
declare
r area_type%rowtype;
begin
-- raise notice ''username=%'',$2;
if ($1=\'s\') then
for r in select id,name from areas where status=\'1\' order by name
loop
return next r;
end loop;
else
for r in select people_areas.area_id as id,areas.name as name from areas,people_areas,people where people.email=$2 and people.id=people_areas.people_id and people_areas.area_id=areas.id and areas.status=\'1\' order by name
loop
return next r;
end loop;
end if;
return;
end;
'
language 'plpgsql';
select * from get_areas('s','first.last@eku.edu');
CREATE OR REPLACE FUNCTION public.backup_deleted_stories()
RETURNS trigger AS
'
begin
raise notice ''Backup...'';
insert into deleted_stories (id, title, content, image, image_description, image_name, image_type, image_size, posted_by, posted_date, contact_email, contact_phone, sp_goals, key_indicators, department, area_id, votes, status, last_modified_by, last_modified_date, occured_date) select * from stories where id = old.id;
select into current_oid max(oid) from deleted_stories;
raise notice ''current oid=%'',current_oid;
update deleted_stories set deleted_time=current_date || '' '' || substr(current_time,0,9) where oid=current_oid;
return old;
end;
'
LANGUAGE 'plpgsql' VOLATILE;
CREATE TRIGGER backup_stories
BEFORE DELETE
ON public.stories
FOR EACH ROW
EXECUTE PROCEDURE public.backup_deleted_stories();
- Bulk Load data from the file: dbname=#copy table (colname1,colname2,colname3) from '/dir/filename' using delimiters ',';
Bulk Load data from the database to a file:dbname=#copy table to '/dir/filename' using delimiters ',';
- Bulk Load data from stdin: dbname=#copy table from stdin using delimiters ',';
>>col11,col12,col13
>>col21,col22,col23
>>\.
Notes: COPY writes only entire tables. To COPY only part of a table, use SELECT INTO TEMPORARY
TABLE with an appropriate WHERE clause and then COPY the temporary table to a .le.
- Backup: shell$pg_dump dbname > file.sql
shell$pg_dumpall > file.sql(must be the supersuser)
- Compressed Backup: shell$pg_dump dbname | gzip > file.sql.gz
- Recovery: shell$psql dbname < file.sql
- Load a SQL file: shell$psql -d test -f /home/postgres/addressbook.sql
- Load a SQL file:dbname=#\i file.sql
- Show Databases: \l
- Show Tables: \d
- Describe Table: \d table_name
- alter table deleted_stories drop constraint "$1";
- Create Table Example:
dbname=# CREATE TABLE editions
dbname-# (isbn text,
dbname(# book_id integer,
dbname(# edition integer,
dbname(# publisher_id integer,
dbname(# publication date,
dbname(# type char,
dbname(# CONSTRAINT pkey PRIMARY KEY (isbn),
dbname(# CONSTRAINT integrity CHECK (book_id IS NOT NULL AND edition IS NOT NULL),
dbname(# CONSTRAINT book_exists FOREIGN KEY (book_id) booktown(REFERENCES books (id) ON DELETE CASCADE ON UPDATE CASCADE);
- ALTER TABLE commands:
- Add column: ALTER TABLE table_name ADD column_name column_type
- Add default: ALTER TABLE table_name ALTER column_name SET DEFAULT value
- Remove default: ALTER TABLE table_name ALTER column_name DROP DEFAULT
- Rename column: ALTER TABLE table_name RENAME column_name TO new_name
- Add FK constraint: ALTER TABLE table_name ADD CONSTRAINT constraint_name FOREIGN KEY (column_name) REFERENCES foreign_table (foreign_column_name)
- Add NOT NULL constraint: ALTER TABLE table_name ADD CONSTRAINT constraint_name CHECK (column_name IS NOT NULL)
- Add UNIQUE constraint: ALTER TABLE table_name ADD CONSTRAINT constraint_name UNIQUE (column_name, column_name_2...)
- Drop a CHECK constraint: ALTER TABLE table_name DROP CONSTRAINT constraint_name RESTRICT
- UPDATE to values in another table's field: UPDATE table SET field=other.field FROM other WHERE other.key=table.key
UPDATE salesorder
SET order_date = employee.hire_date
FROM employee
WHERE salesorder.employee_id = employee.employee_id AND
salesorder.order_date < employee.hire_date;
- select cast(substr(current_timestamp,0,20) as timestamp);
can insert or update the timestamp-type(no timezone) data in the table.
- Full Text Searching: /contrib/tsearch2/
Doc Links: Instruction reference Guide
In Fedora, postgresql contrib is installed default under /usr/share/pgsql/, the tsearch2.so is installed already under /usr/lib/pgsql/ when you install posgresql 8.
install and configuration: psql database < tsearch2.sql;
Setup the configuration for en_US locale; follow the instructions in Tsearch2 Introductions;
Get ispell source, and make a new english dictionary, move the files to the right location;
Alter the table to add a column called: idxFTI for the full text searching:
example: alter table facstaff_out add column idxFTI tsvector;
Update the table to fill out the idxFTI column:
update facstaff_out set idxFTI = to_tsvector('default_english',interests);
vacuum analyze;
create index: create index idxFTI_idx on facstaff_out using gist(idxFTI);
vacuumn analyse;
create trigger: create trigger tsvectorupdate before update or insert on facstaff_out for each row execute procedure tsearch2(idxFTI,interests);
grant all on pg_ts_cfg to username;
grant all on pg_ts_cfgmap to username;
grant all on pg_ts_dict to username;
grant all on pg_ts_parser to username;
Use full text searching in PHP for PostgreSQL:
Project web areas-people searching is use PostgreSQL for full text searching.
Setup Locale: select set_curcfg('default_english'); or use 'default' as the first argument in to_tsvector
get the vectors from the string, call function get_vectors()in db.inc;
use query: idxFTI @@ to_tsquery('$vectors') to get results or to_tsquery('default','$vectors');
Increase the performance:
psql#explain analyse select * from urls where name='http://www.eku.edu/web9/';
psql#cluster urls_name_idx on urls;
psql#explain analyse select * from urls where name='http://www.eku.edu/web9/';
You can see the big difference for running time.
- numeric field: null to 0: coalesce(column_name,0)
- Select Case
select
case
when invitation_sent='t' then 'Yes'
else 'No'
end as invitation_sent from visit limit 10;
|
* Oracle Administration and Programming
- Start Oracle, change to user 'oracle', use the following commands:
lsnrctl start svrmgrl connect internal startup quit
- Find some configuration files at: $ORACLE_HOME/network/admin/
- Data Types: varchar2,char,number(number(5),number(5,2)),date,long,raw(indexable),long raw
- Constraints:
- Primary Key: sid number(5) constraint stutent_sid_pk
- Foreign Key: locid number(5) constraint faculty_locid_fk references location(locid)
- Check: ccredit number(2) constraint course_ccredit_cc check ((ccredit>0) and (ccredit<12))
- Not Null: termid number(3) constraint course_section_termid_fk references term(termid) constraint course_termid_nn not null
- Unique: first varchar2(20),last varchar2(20), constraint emp_name_uniq(first,last)
- System Database Tables and Utilities:
- select * from tab;
- desc tablename
- SQL>desc user_tables;
- SQL>desc user_objects;
- SQL>desc all_views;
- SQL>desc all_tables;
- SQL>every table have a column called ROWNUM (select rownum from emp;)
- SQL>show linesize;
- SQL>set linesize 120;
- SQL>set pagesize 1000;/li>
- SQL>set pause on(off);
- SQL>column column_name format a30; (a stands for alphanumeric)
- SQL>column column_name format $9,999.99;
- SQL>select * from user_sequences;
- SQL>select sysdate from dual;
- SQL>select abs(-1) from dual;
- SQL>select power(2,2) from dual;
- SQL>select round(2.345,2) from dual;
- SQL>select trunc(123.456,2) from dual;
- Allowed Modification:
- Add or delete a constraint:
SQL>alter table student add constraint student_sclass_cc check ((ssclass='JR') or (sclass='SO'))
- Add a new column(delete a column is not allowed)
SQL>alter table faculty add (startdate date);
- Change a column definition if the column is empty now
SQL>alter table student modify (spin number(4) constraint student_spin_nn not null);
- SQL>start /dir/file1.sql
- TO_DATE('08/10/2002','format') converting a string to date format in the SQL:
- to_date('08/10/2002','MM/DD/YYYY')
- to_date('10-Aug-2002','DD-MON-YYYY')
- to_date('10:00 AM','HH:MI AM')
-
MM:Number of the month
MON:Three-letter abbreviation of month in all uppercase letter
DD:Number of the day of the month
D:Number of the day of the week(Sunday=1)
DY:Three-letter abbreviation of the day in all uppercase letters SUN
YY:Last two digits of the year
YYYY:Full four-digit year
HH:Hour of the day using a 12-hour clock
HH24:Hour of the day using a 24-hour clock
MI:Minute of the hour
SS:Second of the minute
A.M.,P.M.:Display A.M. or P.M. depending on the time of day
- SQL>insert into table1 values(val1,val2,to_date('08/10/2002','MM/DD/YYYY'))
- SQL>select sfname from student where sdob>to_date('01-Jan-78','DD-MON-YY')
- Sequences:
SQL>create sequence sequence_name
SQL>[increment by number]
SQL>[start with value]
SQL>[maxvalue value][nomaxvalue]
SQL>[minvalue value]
SQL>[cycle][nocycle][cache][nocache][order][noorder];
SQL>create sequence itemid_sequence start with 996 nomaxvalue nocache;
SQL>insert into tablename values(owner.sequence_name.NEXTVAL);
SQL>insert into item values(lhoward.itemid_sequence.NEXTVAL,'val2');
SQL>select lhoward.itemid_sequence.NEXTVAL from dual;
SQL>select lwoward.itemid_sequence.CURRVAL from dual;
SQL>grant select on itemid_sequence to public;
SQL>drop sequence sequence_name
- SQL Transaction:
- Commit,rollover,savepoint order_save,rollback to order_save
- SQL Union: requires that both queries have the same number of display columns in the select statement
SQL>select slname,sfname,sphone from student
union
select flname,ffname,fphone from faculty
- Cursor
- SQL>Create View view_name as
- SQL>Create Procedure procedure_name as (var1 in out,var2 in out) (cann't return value)
- SQL>Create Function function_name as (var1 in,var2 out) (can return value)
- SQL>Create Trigger trigger_name as
- Database Security (DBAs)
- SQL>Create user username identified by password
- SQL>Drop user username
- SQL>Grant select,insert,update,delete on tablename to user;
- SQL>Revoke select,insert,update,delete on tablename from user;
- SQL>Create role role_name not identified
- SQL>Grant rolename to user1,user2;
- SQL>Grant select,insert,update(col1,col2) on table_name to rolename;
- SQL>Revoke insert,update on table_name from rolename
- Backup and Recovery
-
JDBC: command:> set CLASSPATH=.;c:\oracle\ora92\jdbc\lib\classes12.zip;c:\oracle\ora92\jdbc\lib\nls_charset12.zip;
java program
|
* Linux Administration
-
Crontab Scheduleing Tasks:
- Store the shell directly in /etc/daily, /etc/hourly ...
- use crontab command to add, edit or remove task;
- format: minute(0-59) hour(0-23) dayofmonth(1-31) monthofyear(1-12) dayofweek(0-6) /dir/command
- 0 * * * * * /home/me/backup.cron: execute the backup shell every hour;
- 0,30 * * * * * /home/me/backup.cron: execute the backup shell every half an hour;
- 0 0 * * * * /home/me/backup.cron: execute the backup shell every day at 00:00;
- You can only have one crontab file storing all your cron tasks;
- scp -Cp localdir/filename username@remotehost:remotedir/filename
- SHELL#wget http://www.url.edu/savedata.php 1>/dev/null 2/dev/null
- su -l postgres -s /bin/sh -c "/usr/bin/pg_ctl -D $PGDATA -p /usr/bin/postmaster start -o -i > /dev/null 2>&1" > /dev/null
su -l <login name>
su -c <execute the command> "command in the quote";
su -s <define the shell>
-
Vim: inside vim, :new to create another window (split windows)
CTR+W to change the current editing window
:only to make only one left
inside .vimrc file under the user's home directory
:set tabstop=2
:set syntax=on
:set shiftwidth=2
- Setup NCP Client services
ipx_confiure --auto_interface=on --auto_promary=on
slist
ncpmount -S EKUWEB /mnt/novell -U username.xcontext1.eku -P password
- Set up Samba Links
mount -t smbfs -o username=administrator,password=administrator's password //host/sharedfolder /mnt/samba
-
Use Time command to measure the performance of program
Using the time Command to Measure CPU Use
- Use dvips to convert dvi file to ps file: if you have a file named hw1.dvi, use "dvips hw1" it will print the ps file.
- dvipdf hw5.dvi will produce a pdf file.
- Vi: s/replace_from/replace_to/g
Shell:$ sed 's/replace_from/replace_to/g' filename
- sfhsmount
- use xterm and cygwin to have XFree86 on windows machine through putty.
- SSH mount: shfsmount user@host:folder /mount
- telnet windows xp: telnet ip, domain/username, net use, use vim
- About VI:
:syn on -- turn on syntax highlight
:set ai -- set autoindent on
:set number -- turn on line number
- uncompress rar files: unrar e filename.rar
- open ISO file: mkdir/mnt/iso, mount -o loop -t iso9660 .iso /mnt/iso
- AVI to DVD:
1. transcode -i family2006.avi -y ffmpeg --export_prof dvd-dtsc --export_asr 3 --o family2006 -D0 -s2 -m family2006.ac3 -J modfps=clonetype=3 --export_fps 29.97
2. mplex -f8 -o family2006_dvd.mpg family2006.m2v family2006.ac3
3. create dvdauthor.xml
4. create a folder named as 'DVD', dvdauthor -x dvdauthor.xml
5. xine dvd:./DVD/VIDEO_TS/
6. growisofs -Z /dev/dvd -dvd-video DVD/
(Details)
-
Installing Flash Media Server 2 on Ubuntu 6.10
The installation script for Flash Media Server works only on RedHat Enterprise by default. With some modifications it works fine on Ubuntu Edgy:
apt-get install libnspr4 libstdc++5 libstdc++5-3.3-dev
wget http://download.macromedia.com/pub/flashmediaserver/ updates/2_0_3/linux/flashmediaserver2.tar.gz
tar xfz flashmediaserver2.tar.gz
cd FMS*
wget http://www.bluetwanger.de/~mbertheau/fms.patch
patch -p1 < fms.patch
sudo ./installFMS
|
* Windows Administration
- Reconnect as Administrator to Server through RDP: mstsc /v:00.00.00.00 /f -console
- Restart from command: shutdown -r (restart), shutdown(shutdown)
- Reset Remote Desktop Connection: RUN»mstsc -v:0.0.0.0 /f -console
|
* Mac OS X Administration
-
How to setup ffmpegx, flash encode and real media videos
1. install most recent quicktime, realplayer.
2. install ffmpegx from http://homepage.mac.com/major4/ and download mpeg2enc from this web site
3. go to sourceforge.net, and search for mplayerosx;
click Download MPlayer OS X;
select Last Mencoder & Mplayer binary;
select ffmpegXbinaries20060307.zip
unzip the file and save to your computer
4. open ffmpegx, install binaries for mencoder and mplayer, select the binary files from step 3
5. open Library/Application Support/ffmpegx/, create a new folder named "reallib"
6. open RealPlayer-Show Package Contents-Contents-Framworks-HXClientKit.framework-HelixPlugins-Codecs
7. copy all *.bundle files to reallib folder created in step 5
8. convert real media file (.rm) to avi, using MPEG 4 (.avi) (mencoder)
9. convert avi file to mov quicktime format
10. convert mov file to flv file
|
* Flash MX and ActionScript Programming
1.
foo_mc.onPress=function()
{
this.startDrag();
this.onMouseMove=function()
{
dosomething();
}
}
|
* JavaScript Programming
- <body onLoad='document.forms[0].reset();'>
|
* HTML Programming
1. Good Colors:
- #00cc66 --- Light Green
- #ffff00 --- Yellow (EKU Students Color)
- #999900 --- Purple
- #ff9900 --- Orange (EKU Faculty&Staff Color)
- #009900 --- Dark Green
- #cccc33 --- Dark Orange (Employment Opportunity)
2. Working with Table:
- use <td width='100%'> will push the other columns;
- use for space;
- put <form> inside <table> to compress the space;
3. Working with MAP and AREA;
-
<MAP NAME="mapname">
<AREA COORDS="-1,143,166,190" HREF="http://goto.com/">
<AREA COORDS="277,106,363,188" HREF="http://goto.com/">
</MAP>
<IMG SRC="image1.jpg" WIDTH="370" HEIGHT="200" usemap="#mapname" BORDER=0>
|
* ASP.NET Programming
1.Simple Notes:
- Use Dim to declare varaibles;
- No Semicolon; at the end of the sentence;
- <%Option Explicit%> to require all variables to be declared before using;
- Use If then ElseIf Else for the conditional structure;
- Select Case Variable
Case "value1" DoSomething Case "value2","value3" Dosomething Case Else Dosomething
- For i=0 to 10
Dosomething Next
- i=0;
Do While i<10 Dosomething i=i+1 Loop
- Sub subproc
Dosomething End Sub
- Sub subproc(var1)
Dosomething using var1 End Sub
- Function func1(var1) as DataType
Dosomething using var1 End Function
- Differences between Sub Procedure and Functions:
Var1=func1(varr) - correct for Function not for Sub Procedure
- Use & to concatenate the texts: str1=str2 & str3 & "This is ASP"
- Comparison Operator: = Equality; <> Inequality;
- Use Response.Write to reply to the client's request;
- Use Request.Form("name") to get the post variable's value;
- / Division; MOD Modulus;
- Use AND OR NOT as the logical operators;
2.Some General Objects and Functions:
- Useful command: issreset- reset iis service; %windows%/Microsoft.NET/Framework/version/regiis -i to install asp.net 2.0 for iis.
- Date: get the date - 11/06/2002
- Time: get the time - 1:29:65PM
- String Manipulation:UCase(heoo->HEOO),LCase(HEOO->heoo),Left(Left("HEOO",2)->HE),
Right(Right("HEOO",2)->OO),Mid(Mid("HEOO",2,2)->EO),InStr(InStr("HEOO","E")->2),LTrim,RTrim,Trim
- Declaring Array:Dim array1(10), Redim array1(30), Redim Preserve array1(30);
- Set objTelephone=Server.CreateObject("MyTelephone.Telephone");
Set objTelephone=nothing
- Form - Get - Request.QueryString("name") or Request.QueryString("name")(index) - index(1-Request.QueryString("name").Count)
- Form - Post - Request.Form("name")
-
' Build a MailMessage
Dim mailMessage As System.Web.Mail.MailMessage = New System.Web.Mail.MailMessage
mailMessage.From = "web@windows.eku.edu"
mailMessage.To = "qing.cui@eku.edu"
mailMessage.Subject = "try .net"
mailMessage.BodyFormat = System.Web.Mail.MailFormat.Text
' TODO: Set the mailMessage.Body property
mailMessage.Body = "New Registration:" & txtName.Text
Dim oAttch As MailAttachment = New MailAttachment("C:\myattachment.zip")
mailMessage.Attachments.Add(oAttch)
System.Web.Mail.SmtpMail.SmtpServer = "ekumail.eku.edu"
System.Web.Mail.SmtpMail.Send(mailMessage)
- DateTime.Now.ToString("MMM dd, yyyy hh:mm:ss")
-
Standard Format Specifiers for Dates and Times:
The table below shows the standard date and time formatters.
Format Description Example
d Short Date
D Long date
f long date & short time
F long date and long time
g short date and short time
G short date and long time
M or m month and day
Y or y year and month
t short time
T long time
s displays in ISO 8601 format using local time
u displays in ISO 8601 format using universal time
U date and time in unversal time
R or r displays in RFC 1123 format
Custom formatting sequences:
There are also specific character sequences that can be used to achieve custom formatting of dates and times.
Format Description
d day of month (1 or 2 digits as required)
dd day of month (always 2 digits, with a leading 0 if needed)
ddd day of week (3 letter abbreviation)
dddd day of week (full name)
M month number (1 or 2 digits as required)
MM month number (always 2 digits, with a leading 0 if needed)
MMM month name (3 letter abbreviation)
MMMM month name (full name)
y year ( last 1 or 2 digits, no leading 0)
yy year (last 2 digits)
yyyy year (4 digits)
H hour in 24-hour format (1 or 2 digits as required)
HH hour in 24-hour format (always 2 digits, with a leading 0 if needed)
h hour in 12-hour format (1 or 2 digits as required)
hh hour in 12 hour format
m minutes (1 or 2 digits as required)
mm minutes (always 2 digits, with a leading 0 if needed)
s seconds (1 or 2 digits as required)
ss seconds
t first character in the am/pm designator
tt am/pm designator
z time zone offset, hour only (1 or 2 digits as required)
zz time zone offset, hour only (always 2 digits, with a leading 0 if needed)
zzz time zone offset, hour and minute
/ default date separator
: default time separator
\ escape characters
-
File Uploading
Setting up HTML form for file uploading.
The requirements for HTML form to be able to upload files are very simple: you have to use multipart/form-data encryption and you have to use method of post.
-
Using Assembly in C# - similar to dll
- create a key file, run command: sn -k myKeyName.snk
-
in the source .cs file:
using System.Reflection;
using System.Runtime.CompilerServices;
[assembly: AssemblyTitle("ekuweb.ActiveDirectory")]
[assembly: AssemblyVersion("1.0.5000.0")]
[assembly: AssemblyKeyFile("myKeyName.snk")]
- compile as a dll file: csc /t:library /out:ekuweb.ActiveDirectory.dll checklogin.cs
- add to GAC: gacutil /if ekuweb.ActiveDirectory.dll
- find the manifests about this assembly using command gacutil /l
-
in web.config add the assembly:
<assemblies>
<add assembly="System.DirectoryServices, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
<add assembly="ekuweb.ActiveDirectory, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=617fd54ccbccc3b4" />
</assemblies>
- to use this assembly, define: using ekuweb.ActiveDirectory;
-
Include a C# file from aspx web page:
<%@ Page Language="C#" Src="webform.cs" Inherits="ekuweb.webform" %>
Src="cs source file name"
Inherits="namespace.classname"
using protected for all web controls in the web page:
protected txtEmail;
protected txtPassword;
protected System.Web.UI.HtmlControls.HtmlForm content;
- use div or span with id in the c# behind-code
.aspx: <div id='mydiv' runat="server">
.cs:
using System.Web.UI.HtmlControls;
public HtmlGenericControl mydiv = new HtmlGenericControl();
mydiv.InnerHtml="Hello World";
-
Include an assembly: (in ./bin folder or global cache)
<%@ Import Namespace="System.DirectoryServices" %>
<%@ Assembly Name="System.DirectoryServices" %>
- How to define a string in multiple lines:
str=@"<table>
<tr>
<td>
</td></tr></table>";
- can not have two vpn connection in two places.
|