- Permanently erase all files with a disk sanitizer such as WipeDrive.
- Insert the Windows installation CD into the CD drive. Make sure that there are no other disks in the computer, and restart.
- At the "Welcome to Setup" screen, press the Enter key to set up Windows.
- Press the C key to continue setup.
- Press the F8 key to agree to the license.
- Press the C key to create a partition.
- Enter the size of the partition, or just press the Enter key to use maximum size.
- Select the "New (Unformatted)" option, and press the Enter key.
- Select NTFS or FAT file system (select NTFS if you are unsure).
- Simply follow the prompts format the hard drive in Windows XP continue the Windows installation.
Monday, December 31, 2007
How to Format a Hard Drive in Windows XP
Perl language gets a revamp
According to the foundation, this is the first new version in five years, and it has an emphasis on rough-and-ready practicality over syntactical formality.
Perl 5.0 has some features designed to make programming a little easier, according to the Perl Foundation. Among them is a "say" command that could ease some text-output chores, a "switch" operator to send a program in various directions depending on different situations, and improvements to the all-important "regular expression" methods for handling text. The Perl interpreter, which runs Perl programs, is also faster and requires less memory, the foundation said.
Perl programmers have been working already on two other future versions, 5.12 and Perl 6, but neither has a launch date yet, according to foundation spokesman Andy Lester. "Perl 5 and Perl 6 will stay in dual development. Perl 5 has such a huge installed base, it won't be going away any time soon after Perl," he said.
Perl founder Larry Wall initially announced Perl 6 in 2000, and development is still under way. Perl 6 attempts, among other things, to clean up some of the problems caused by the informality of Perl 5.
Closely related to Perl but separate is Parrot, an attempt to create a virtual machine that can execute programs written not just in Perl 6 but also in Ruby, Lua, Javascript, Python and PHP. (Virtual machine software provides an insulating layer that shields programs from the particulars of the computer and operating system they're running on.) Programmers released Parrot version 0.5.1 on 18 December.
Perl Offers Incremental Update; Version 6.0 Still Awaited
Release 5.10 contains additions and enhancements to the language rather than the total revamp represented by a new version, Perl 6.0, announced by Perl's original author, Larry Wall, in 2000.
Perl -- like Tcl, Python, JavaScript, and PHP -- is a "dynamic" language that is interpreted, or run through an interpreter for each use of the program, instead of compiled once in advance. For that reason, changes to a phrase or line of Perl get picked up immediately in the next use of a Perl program in a runtime environment. Perl is often used to tie together dissimilar elements of a Web site, such as pieces of Java and Visual Basic code and other site resources.
But Perl has developed spontaneously, adding features and function before an overall design was in place. Wall, on the Perl.org Web site, said, "Perl 5 was my rewrite of Perl. I want version 6 to be the community's rewrite of Perl."
On the same site, the internals of the version 5 interpreter are described as "so tangled that they hinder maintenance, thwart some new feature efforts, and scare off potential internals hackers. The language as of version 5 has some mis-features that are a hassle to ongoing maintenance of the interpreter and of programs written in Perl."
Release 5.10 of Perl is meant to incorporate some additions to the language in lieu of the emergence of version 6.0. The interpreter has been sped up and given a smaller footprint in memory. "State variables" allow variables in a program to persist between calls to subroutines, so they don't have to be named again at a later point in the program.
A "say" command has been added to govern text output tasks. A "switch" operator sends a program's logic in various directions, depending on the conditions encountered. Changes have been made to how text is handled by the "regular expression" approach, according to information posted on the Perl.org Web site.
Release 5.10 was produced by Rafael Garcia-Suarez, a French software engineer who lives in Paris and is employed by Booking.com. He is a longtime contributor to Perl.
Version 6.0 seeks to establish a neutral mode of operation for the interpreter, allowing it to deal with different scripting languages. Interpreters often run pre-compiled code or byte code that has been moved beyond source code into a language that is more readily interpreted to the hardware. The version 6.0 interpreter may be able to run the byte code of other scripting languages, such as Python or Ruby, as well as Perl.
Fully compiled code, such as C or C++, runs faster but interpreted code is constantly picking up small changes to a program and incorporating them into its operation at runtime. Web site developers often resort to scripting languages for that purpose and for their ability to adapt to different languages and data types.
Thursday, December 20, 2007
submit forms to a new window, with window.open() features
target=_blank action=whatever.asp> |
However, some would like to submit their forms to a new window that they have a little more control over.
This is not really an ASP issue, as the solution could be used in any web-based technology (including plain HTML). However, here is a way to submit a form to a new window, and have control over parameters like width, height, toolbar, etc.:
// // method=post
// action=whatever.asp
//target=myNewWin>
/
//
/
// // value=' Submit '
// onClick='sendme();'>
//
CREATE VIEW in postgresql
CREATE VIEW -- define a new view
Synopsis
CREATE [ OR REPLACE ] [ TEMP | TEMPORARY ] VIEW name [ ( column_name [, ...] ) ]
AS query
Description
CREATE VIEW defines a view of a query. The view is not physically materialized. Instead, the query is run every time the view is referenced in a query.
CREATE OR REPLACE VIEW is similar, but if a view of the same name already exists, it is replaced. You can only replace a view with a new query that generates the identical set of columns (i.e., same column names and data types).
If a schema name is given (for example, CREATE VIEW myschema.myview ...) then the view is created in the specified schema. Otherwise it is created in the current schema. Temporary views exist in a special schema, so a schema name cannot be given when creating a temporary view. The name of the view must be distinct from the name of any other view, table, sequence, or index in the same schema.
Parameters
TEMPORARY or TEMP
If specified, the view is created as a temporary view. Temporary views are automatically dropped at the end of the current session. Existing permanent relations with the same name are not visible to the current session while the temporary view exists, unless they are referenced with schema-qualified names.
If any of the tables referenced by the view are temporary, the view is created as a temporary view (whether TEMPORARY is specified or not).
name
The name (optionally schema-qualified) of a view to be created.
column_name
An optional list of names to be used for columns of the view. If not given, the column names are deduced from the query.
query
A SELECT or VALUES command which will provide the columns and rows of the view.
Notes
Currently, views are read only: the system will not allow an insert, update, or delete on a view. You can get the effect of an updatable view by creating rules that rewrite inserts, etc. on the view into appropriate actions on other tables. For more information see CREATE RULE.
Use the DROP VIEW statement to drop views.
Be careful that the names and types of the view's columns will be assigned the way you want. For example:
CREATE VIEW vista AS SELECT 'Hello World';
is bad form in two ways: the column name defaults to ?column?, and the column data type defaults to unknown. If you want a string literal in a view's result, use something like:
CREATE VIEW vista AS SELECT text 'Hello World' AS hello;
Access to tables referenced in the view is determined by permissions of the view owner. However, functions called in the view are treated the same as if they had been called directly from the query using the view. Therefore the user of a view must have permissions to call all functions used by the view.
Examples
Create a view consisting of all comedy films:
CREATE VIEW comedies AS
SELECT *
FROM films
WHERE kind = 'Comedy';
Compatibility
The SQL standard specifies some additional capabilities for the CREATE VIEW statement:
CREATE VIEW name [ ( column_name [, ...] ) ]
AS query
[ WITH [ CASCADED | LOCAL ] CHECK OPTION ]
The optional clauses for the full SQL command are:
CHECK OPTION
This option has to do with updatable views. All INSERT and UPDATE commands on the view will be checked to ensure data satisfy the view-defining condition (that is, the new data would be visible through the view). If they do not, the update will be rejected.
LOCAL
Check for integrity on this view.
CASCADED
Check for integrity on this view and on any dependent view. CASCADED is assumed if neither CASCADED nor LOCAL is specified.
CREATE OR REPLACE VIEW is a PostgreSQL language extension. So is the concept of a temporary view.
Why use stored procedures?
Advantage 1: Stored procedures are modular. This is a good thing from a maintenance standpoint. When query trouble arises in your application, you would likely agree that it is much easier to troubleshoot a stored procedure than an embedded query buried within many lines of GUI code.
Advantage 2: Stored procedures are tunable. By having procedures that handle the database work for your interface, you eliminate the need to modify the GUI source code to improve a query's performance. Changes can be made to the stored procedures--in terms of join methods, differing tables, etc.--that are transparent to the front-end interface.
Advantage 3: Stored procedures abstract or separate server-side functions from the client-side. It is much easier to code a GUI application to call a procedure than to build a query through the GUI code.
Advantage 4: Stored procedures are usually written by database developers/administrators. Persons holding these roles are usually more experienced in writing efficient queries and SQL statements. This frees the GUI application developers to utilize their skills on the functional and graphical presentation pieces of the application. If you have your people performing the tasks to which they are best suited, then you will ultimately produce a better overall application.
In short, queries are best handled via stored procedures. While the initial development overhead is greater, you will more than make up for the investment down the line.
Friday, December 7, 2007
PHP Vs Perl
1. The Language
If you are coming from a C, C++, Perl, Java or JavaScript background, learning PHP would probably be a piece of cake. In fact, you probably can get started writing your scripts almost immediately.
It uses typeless variables the way Perl does, prefixed with a "$" sign and holding any data type you wish. For example, $whatever can be a variable that you can use to contain strings, numbers, whatever. If $whatever contained a number, you can increment its value using
or
or
Doesn't it remind you of Perl, C, C++, Java, JavaScript? See what I mean?
2. Built-in Facilities
Unlike Perl, which is a general purpose scripting language that you can use for a wide variety of purposes (and not just generating web pages), PHP was designed from the ground up to be used for scripting web pages. As a result, it has lots of facilities built into that you may have to write yourself or use some pre-written module if you were using Perl.
For example, do you want to send email to yourself from a form on the web page? In Perl, one common way to do this is to use code like the following:
print MAIL "To: myself\@mydomain.com\n" ;
print MAIL "From: visitor\@hisdomain.com\n" ;
print MAIL "Subject: Comments from Web Form\n\n" ;
print MAIL $mainmessage ;
close ( MAIL ) ;
In PHP, the same thing would be coded as follows:
$mainmessage, "From: visitor@hisdomain.com" );
Nifty, huh? The same goes for other facilities like sending or retrieving a document via HTTP or FTP, etc. Since PHP was specially designed for a website, the facilities that web designers typically want in a scripting language are built into it.
Another convenience is its handling of form input. Take for example a form with a field like:
The data submitted for that field is made available to your script in the array variable $_REQUEST['dateofbirth']. You can assign its contents to any variable you like, or use it directly. There's no need to parse form inputs or the like. All fields in the form are automatically converted to variables that you can access.
Accessing databases is just as easy. There are built-in facilities in PHP to access MySQL, MSQL, Dbase, Oracle, InterBase, and so on (the list is very long). Need to MIME encode your message? There's a function to do it for you too.
There're many more features. I obviously can't run through the entire list - it would take a whole book to be exhaustive. This is just to whet your appetite.
3. Generating web pages
By default anything you type in your PHP document is given verbatim to the web browser. So a simple PHP script might look like the following:
My First PHP Script
Welcome, Internet user from IP address
. Hope you like my first
PHP page.
Notice that it looks exactly like a web page, except for the bit, which encloses the PHP script. In this case, all we want is for the script to output the visitor's IP address to the page, hence we use the "echo" function. The web server's environment variable REMOTE_ADDR is automatically made available to the PHP script via an array variable $_SERVER['REMOTE_ADDR']. In fact, all server environment variables are available to the PHP script in the $_SERVER array variable. So, for example, the name of your visitor's browser is available in $_SERVER['HTTP_USER_AGENT'].
There are many ways to embed your PHP script into your page, or to design your page itself. But you've probably already got the general idea. As I said, PHP was designed for web pages, so the idea of output to the server is built into its design. It makes writing such scripts a very pleasant task.
How to convert date to unixtime in perl (or vice versa)
time
return number of seconds since 0 in your computer (1 jan 1970) on unix localtime
converts unixtime to normal dates To convert a specific date to its corresponding unixtime, you use Time::Local, the function looks like this:
$time = timelocal($sec,$min,$hours,$mday,$mon,$year);
use Time::Local;
$time = timelocal(0,0,0,'3','08','2000');
Site Replication and Mirroring
Mirroring Single Pages
% ./MirrorOne.pl
cats.html: Not Modified
dogs.html: OK
gillie_fish.html: Not Modified
----------------------Script I.3.1 mirrorOne.pl--------------------
#!/usr/local/bin/perl
# mirrorOne.pl
use LWP::Simple;
use HTTP::Status;
use constant DIRECTORY => '/local/web/price_lists';
%DOCUMENTS = (
'dogs.html' => 'http://www.pets.com/dogs/price_list.html',
'cats.html' => 'http://www.pets.com/cats/price_list.html',
'gillie_fish.html' => 'http://aquaria.com/prices.html'
);
chdir DIRECTORY;
foreach (sort keys %DOCUMENTS) {
my $status = mirror($DOCUMENTS{$_},$_);
warn "$_: ",status_message($status),"\n";
}
-------------------------------------------------------------------
Mirroring a Document Tree
With a little more work, you can recursively mirror an entire set of linked pages. Script I.3.2 mirrors the requested document and all subdocuments, using the LWP HTML::LinkExtor module to extract all the HTML links.----------------------Script I.3.2 mirrorTree.pl--------------------
#!/usr/local/bin/perl
# File: mirrorTree.pl
use LWP::UserAgent;
use HTML::LinkExtor;
use URI::URL;
use File::Path;
use File::Basename;
%DONE = ();
my $URL = shift;
$UA = new LWP::UserAgent;
$PARSER = HTML::LinkExtor->new();
$TOP = $UA->request(HTTP::Request->new(HEAD => $URL));
$BASE = $TOP->base;
mirror(URI::URL->new($TOP->request->url));
sub mirror {
my $url = shift;
# get rid of query string "?" and fragments "#"
my $path = $url->path;
my $fixed_url = URI::URL->new ($url->scheme . '://' . $url->netloc . $path);
# make the URL relative
my $rel = $fixed_url->rel($BASE);
$rel .= 'index.html' if $rel=~m!/$! || length($rel) == 0;
# skip it if we've already done it
return if $DONE{$rel}++;
# create the directory if it doesn't exist already
my $dir = dirname($rel);
mkpath([$dir]) unless -d $dir;
# mirror the document
my $doc = $UA->mirror($fixed_url,$rel);
print STDERR "$rel: ",$doc->message,"\n";
return if $doc->is_error;
# Follow HTML documents
return unless $rel=~/\.html?$/i;
my $base = $doc->base;
# pull out the links and call us recursively
my @links = $PARSER->parse_file("$rel")->links;
my @hrefs = map { url($_->[2],$base)->abs } @links;
foreach (@hrefs) {
next unless is_child($BASE,$_);
mirror($_);
}
}
sub is_child {
my ($base,$url) = @_;
my $rel = $url->rel($base);
return ($rel ne $url) && ($rel !~ m!^[/.]!);
}
Checking for Bad Links
% find_bad_links http://prego/apache-1.2/
checking http://prego/apache-1.2/...
checking http://prego/apache-1.2/manual/...
checking http://prego/apache-1.2/manual/misc/footer.html...
checking http://prego/apache-1.2/manual/misc/header.html...
checking http://prego/apache-1.2/manual/misc/nopgp.html...
checking http://www.yahoo.com/Science/Mathematics/Security_and_Encryption/...
checking http://www.eff.org/pub/EFF/Policy/Crypto/...
checking http://www.quadralay.com/www/Crypt/Crypt.html...
checking http://www.law.indiana.edu/law/iclu.html...
checking http://bong.com/~brian...
checking http://prego/apache-1.2/manual/cgi_path.html...
checking http://www.ics.uci.edu/pub/ietf/http/...
.
.
.
BAD LINKS:
manual/misc/known_bugs.html : http://www.apache.org/dist/patches/apply_to_1.2b6/
manual/misc/fin_wait_2.html : http://www.freebsd.org/
manual/misc/fin_wait_2.html : http://www.ncr.com/
manual/misc/compat_notes.html : http://www.eit.com/
manual/misc/howto.html : http://www.zyzzyva.com/robots/alert/
manual/misc/perf.html : http://www.software.hp.com/internet/perf/tuning.html
manual/misc/perf.html : http://www.qosina.com/~awm/apache/linux-tcp.html
manual/misc/perf.html : http://www.sun.com/sun-on-net/Sun.Internet.Solutions/performance/
manual/misc/perf.html : http://www.sun.com/solaris/products/siss/
manual/misc/nopgp.html : http://www.yahoo.com/Science/Mathematics/Security_and_Encryption/
152 documents checked
11 bad links
----------------------Script I.3.2 mirrorTree.pl--------------------
#!/usr/local/bin/perl
# File: find_bad_links.pl
use LWP::UserAgent;
use HTML::LinkExtor;
use URI::URL;
%CAN_HANDLE = ('http'=>1,
'gopher'=>1,
# 'ftp'=>1, # timeout problems?
);
%OUTCOME = ();
$CHECKED = $BAD = 0;
@BAD = ();
my $URL = shift;
$UA = new LWP::UserAgent;
$PARSER = HTML::LinkExtor->new();
$TOP = $UA->request(HTTP::Request->new(HEAD => $URL));
$BASE = $TOP->base;
check_links(URI::URL->new($TOP->request->url));
if (@BAD) {
print "\nBAD LINKS:\n";
print join("\n",@BAD),"\n\n";
}
print "$CHECKED documents checked\n",scalar(@BAD)," bad links\n";
sub check_links {
my $url = shift;
my $fixed_url = $url;
$fixed_url =~ s/\#.+$//;
return 1 unless $CAN_HANDLE{$url->scheme};
# check cached outcomes
return $OUTCOME{$fixed_url} if exists $OUTCOME{$fixed_url};
print STDERR "checking $fixed_url...\n";
$CHECKED++;
my $rel = $url->rel($BASE) || 'index.html';
my $child = is_child($BASE,$url);
$UA->timeout(5);
my $doc = $d = $UA->request(HTTP::Request->new(($child ? 'GET' : 'HEAD' )=>$url));
$OUTCOME{$fixed_url} = $doc->is_success;
return $OUTCOME{$fixed_url}
unless $child && $doc->header('Content-type') eq 'text/html';
# Follow HTML documents
my $base = $doc->base;
# pull out the links and call us recursively
my @links = $PARSER->parse($doc->content)->links;
my @hrefs = map { url($_->[2],$base)->abs } @links;
foreach (@hrefs) {
next if check_links($_);
push (@BAD,"$rel : $_");
}
1;
}
sub is_child {
my ($base,$url) = @_;
my $rel = $url->rel($base);
return ($rel ne $url) && ($rel !~ m!^[/.]!);
}
Ten Neat Tricks With Perl
Here are ten one liners in perl, illustrating the kinds of task one would use a script for under linux. All the scripts take some kind of argument after the final ' quote that signals the end of the program.
1. perl -p -i -e 's/this/that/g' filename
Search and replace the string 'this' with the string 'that' in the file filename. You can also say * or *.html or any valid wildcard expression instead of filename. The s/// command uses regular expressions. If you want to alter the 'this' and 'that', it's best to avoid .*?[]{}$^ and other odd characters which act as metacharacters in regular expressions. Or better still look at the perlre documentation page. You can do this by saying perldoc perlre
. Perl has extensive online documentation, try perldoc perltoc
for a list.
2. perl -e 'for (@ARGV) { rename $_, lc($_) unless -e lc($_); }' *
Rename all the files in the current directory to lower case. The $_ is a sort of 'default' variable which is widely used in Perl.
3. perl -e 'for (@ARGV) { rename $_,$_.'l' unless -e lc($_); }' *
Add an 'l' on the end of every filename in the current directory. That is: .htm => .html. The 'unless -e' statement means 'unless the filename exists'.
4. perl -MLWP::Simple -e 'mirror("http://www.perl.com/" , "perl.html")'
Copy a file across the Web if it is newer than the local copy. You will need to install the "libnet" and "libwww" bundles to make this work. The LWP package comes with a great documentation page'lwpcook' which has lots of examples of other ways to transfer data across the WWW with Perl.
5. perl -p -i -e 's/'
Convert Unix files to DOS files. Unix files have a different end of line character sequence from DOS.
6. perl -e 'if (!fork) {sleep $ARGV[0]*60; print "aaa" ; exit;} exit;' 1
Wait for the number of minutes specified and then beep. Note the use of the fork() to run in the background. Use the linux commnd 'ps' if you want to watch the command running.
7.perl -e 'use Socket; $name =gethostbyaddr(inet_aton($ARGV[0] ),AF_INET); print $name;' 207.153.253.38
Convert the given domain name or dotted IP number to a hostname. It will convert whatever you throw at it to a sensible and consistent hostname.
8. perl -MTime::Local -e '$y2k=timelocal(0,0,0,1,0,2000); $until=$y2k-time; print "seconds $until to y2k ";'
This finds the number of seconds until the year 2000 is upon us.
9. perl -e '$n=utime ((stat($ARGV[0]))[8,9], @ARGV) ;print $n' aaa t*
Make all files beginning with the letter t have the same time stamp as the file 'aaa'
10. perl -l -e 'open(F,"/usr/dict/english"); $w=join("",sort split(//,$ARGV[0])); print grep {chop;join("",sort split(//,$_)) eq $w}
Tuesday, December 4, 2007
Creating a HTML back button.
Creating a HTML back button.
Issue:
Creating a HTML back button.
Reason:
You may find it more helpful to provide a back button for your users to allow them to go back where they originally came from. This will also make it easier to program your HTML pages.
Solution:
Copy and paste the below source code.
In the above code the -1 tells the browser to go back one page.
What is SQL*Plus and where does it come from?
If you are familiar with other databases, sqlplus is equivalent to "sql" in Ingres, "isql" in Sybase and SQLServer, "db2" in IBM DB2, "psql" in PostgresQL, and "mysql" in MySQL.
SQL*Plus's predecessor was called UFI (User Friendly Interface). UFI was included in the first Oracle releases up to Oracle v4. The UFI interface was extremely primitive and, in today's terms, anything but user friendly. If a statement was entered incorrectly, UFI issued an error and rolled back the entire transaction (ugggh).
How does one use the SQL*Plus utility?
userid/password@db -- Connection detailsLook at this example session:
/nolog -- Do not login to Oracle. You will need to do it yourself.
-s or -silent -- start sqlplus in silent mode. Not recommended for beginners!
@myscript -- Start executing script called "myscript.sql"
sqlplus /nologPlease note that one must prepare the environment before starting sqlplus. Linux/ Unix example:
SQL> connect scott/tiger
SQL> select * from tab;
SQL> disconnect
SQL> exit
$ . oraenvWindows Example:
ORACLE_SID = [orcl] ? orcl
$ sqlplus scott/tiger
Click on "Start" -> "Run" and enter "cmd"
C:> set ORACLE_SID=orcl
C:> sqlplus scott/tiger
or
C:> sqlplus scott/tiger@orcl
What is AFIEDT.BUF?
In the prehistoric days when SQL*Plus was called UFI (User Friendly Interface) this file was named "ufiedt.buf", short for UFI editing buffer. When new features were added to UFI, it was the initially named Advanced UFI and the filename was changed to "aufiedt.buf" and then to "afiedt.buf". They presumably needed to keep the name short for compatibility with some of the odd operating systems that Oracle supported in those days. The name "Advanced UFI" was never used officially, as the name was changed to SQL*Plus before this version was released.
You can overwrite the default edit save file's name like this:
SET EDITFILE "afiedt.buf"
What are the basic SQL*Plus commands?
ACCEPT | Get input from the user | |
DEFINE | Declare a variable (short: DEF) | |
DESCRIBE | Lists the attributes of tables and other objects (short: DESC) | |
EDIT | Places you in an editor so you can edit a SQL command (short: ED) | |
EXIT or QUIT | Disconnect from the database and terminate SQL*Plus | |
GET | Retrieves a SQL file and places it into the SQL buffer | |
HOST | Issue an operating system command (short: !) | |
LIST | Displays the last command executed/ command in the SQL buffer (short: L) | |
PROMPT | Display a text string on the screen. Eg prompt Hello World!!! | |
RUN | List and Run the command stored in the SQL buffer (short: /) | |
SAVE | Saves command in the SQL buffer to a file. Eg "save x" will create a script file called x.sql | |
SET | Modify the SQL*Plus environment eg. SET PAGESIZE 23 | |
SHOW | Show environment settings (short: SHO). Eg SHOW ALL, SHO PAGESIZE etc. | |
SPOOL | Send output to a file. Eg "spool x" will save STDOUT to a file called x.lst | |
START | Run a SQL script file (short: @) |
Popups in Javascript
Sometimes it's useful to add a popup to your pages. When the user clicks on a link, a new window opens and displays a page.
There are two ways to do this. You can add a TARGET="_blank" to the -tag, but this simply opens a new browser window that completely obscures the old one.
First the basic syntax of how to create a popup, then an explanation of the script, including a table of the most common arguments you can give to a popup and the problem of focusing.
Then a new way of adding popup behaviour to a link. This site uses the new system because it's much cleaner than the old one.
Finally some notes about writing content directly into the popup. This gives several problems, most importantly the confusion over exactly what the URL of the popup is.
This page only treats the opening of popups. For communication between the opening window and the popup, see the Cross-window scripting page.
Creating a popup
To create a popup you'll need the following script:
Then, you link to it by:
Link to popup
See below for a far cleaner way of adding popup behaviour to a link.
Explanation
First, you open the new window. The page to be opened is passed on by the argument url
. Note that, if you want to open a page on another server, Explorer will frequently give errors. This is a feature, not a bug, so there's little you can do about it.
You have to give a name to the window (in this case, name
). However, this name is completely useless.
In addition, you have to load the window into a JavaScript variable. The reasons for this are complex and have mostly to do with preventing errors in various browsers, especially when you want more links to lead to the same popup.
function popitup(url) {
newwindow=window.open(url,'name','height=200,width=150');
Arguments
So first we define the url to be loaded in the popup and then the useless name.
As third argument, you can assign all kinds of variables. Most common are height
and width
, which define the height and width of the new window.
'height=200,width=150'
As soon as you define anything, all yes | no arguments that you have not defined are set to no
.
Warning: Spaces or hard returns are not allowed within the quote-marks.
Open popup, and set the arguments through the checkboxes below.
Selecting and deleting duplicate rows postgresql
-- unique values
insert into test values ( 'x', 'y');
insert into test values ( 'x', 'x');
insert into test values ( 'y', 'y' );
insert into test values ( 'y', 'x' );
-- duplicate values
insert into test values ( 'x', 'y');
insert into test values ( 'x', 'x');
insert into test values ( 'y', 'y' );
insert into test values ( 'y', 'x' );
-- one more double duplicate
insert into test values ( 'x', 'y');
--
select oid, a, b from test;
--
-- select duplicate rows
--
select o.oid, o.a, o.b from test o
where exists ( select 'x'
from test i
where i.a = o.a
and i.b = o.b
and i.oid < o.oid
);
--
-- delete duplicate rows
--
-- Note: PostgreSQL dosn't support aliases on
-- the table mentioned in the from clause
-- of a delete.
--
delete from test
where exists ( select 'x'
from test i
where i.a = test.a
and i.b = test.b
and i.oid < test.oid
);
--
-- Let's see if it worked.
--
select oid, a, b from test;
--
-- Delete duplicates with respect to a only, ignoring
-- the value in b. Note, the first deletion leaves the
-- first oid with the unique values and removes subsequent
-- ones, in this delete we reverse the direction of the <
-- to save the last oid, and remove the previous ones.
--
delete from test
where exists ( select 'x'
from test i
where i.a = test.a
and i.oid > test.oid
);
--
-- Let's see if it worked.
--
select oid, a, b from test;
Moving, renaming, and copying files in UNIX
cp file1 file2 copy a file
mv file1 newname move or rename a file
mv file1 ~/AAA/ move file1 into sub-directory AAA in your home directory.
rm file1 [file2 ...] remove or delete a file
rm -r dir1 [dir2...] recursivly remove a directory and its contents BE CAREFUL!
mkdir dir1 [dir2...] create directories
mkdir -p dirpath create the directory dirpath, including all implied directories in the path.
rmdir dir1 [dir2...] remove an empty directory
Changing file permissions and attributes in UNIX
chmod 755 file Changes the permissions of file to be rwx for the owner, and rx for
the group and the world. (7 = rwx = 111 binary. 5 = r-x = 101 binary)
chgrp user file Makes file belong to the group user.
chown cliff file Makes cliff the owner of file.
chown -R cliff dir Makes cliff the owner of dir and everything in its directory tree.
You must be the owner of the file/directory or be root before you can do any of these things.
Listing directory contents in UNIX
ls list a directory
ls -l list a directory in long ( detailed ) format
for example:
$ ls -l
drwxr-xr-x 4 cliff user 1024 Jun 18 09:40 WAITRON_EARNINGS
-rw-r--r-- 1 cliff user 767392 Jun 6 14:28 scanlib.tar.gz
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
| | | | | | | | | | |
| | | | | owner group size date time name
| | | | number of links to file or directory contents
| | | permissions for world
| | permissions for members of group
| permissions for owner of file: r = read, w = write, x = execute -=no permission
type of file: - = normal file, d=directory, l = symbolic link, and others...
ls -a List the current directory including hidden files. Hidden files start
with "."
ls -ld * List all the file and directory names in the current directory using
long format. Without the "d" option, ls would list the contents
of any sub-directory of the current. With the "d" option, ls
just lists them like regular files.
Basics of the vi editor
Opening a file
vi filename
Creating text
Edit modes: These keys enter editing modes and type in the text
of your document.
i Insert before current cursor position
I Insert at beginning of current line
a Insert (append) after current cursor position
A Append to end of line
r Replace 1 character
R Replace modeTerminate insertion or overwrite mode
Deletion of text
x Delete single character
dd Delete current line and put in buffer
ndd Delete n lines (n is a number) and put them in buffer
J Attaches the next line to the end of the current line (deletes carriage return).
Oops
u Undo last command
cut and paste
yy Yank current line into buffer
nyy Yank n lines into buffer
p Put the contents of the buffer after the current line
P Put the contents of the buffer before the current line
cursor positioning
^d Page down
^u Page up
:n Position cursor at line n
:$ Position cursor at end of file
^g Display current line number
h,j,k,l Left,Down,Up, and Right respectivly. Your arrow keys should also work if
if your keyboard mappings are anywhere near sane.
string substitution
:n1,n2:s/string1/string2/[g] Substitute string2 for string1 on lines
n1 to n2. If g is included (meaning global),
all instances of string1 on each line
are substituted. If g is not included,
only the first instance per matching line is
substituted.
^ matches start of line
. matches any single character
$ matches end of line
These and other "special characters" (like the forward slash) can be "escaped" with \
i.e to match the string "/usr/STRIM100/SOFT" say "\/usr\/STRIM100\/SOFT"
Examples:
:1,$:s/dog/cat/g Substitute 'cat' for 'dog', every instance
for the entire file - lines 1 to $ (end of file)
:23,25:/frog/bird/ Substitute 'bird' for 'frog' on lines
23 through 25. Only the first instance
on each line is substituted.
Saving and quitting and other "ex" commands
These commands are all prefixed by pressing colon (:) and then entered in the lower
left corner of the window. They are called "ex" commands because they are commands
of the ex text editor - the precursor line editor to the screen editor
vi. You cannot enter an "ex" command when you are in an edit mode (typing text onto the screen)
Pressto exit from an editing mode.
:w Write the current file.
:w new.file Write the file to the name 'new.file'.
:w! existing.file Overwrite an existing file with the file currently being edited.
:wq Write the file and quit.
:q Quit.
:q! Quit with no changes.
:e filename Open the file 'filename' for editing.
:set number Turns on line numbering
:set nonumber Turns off line numbering