Click the box titles below to expand:
How to's
XSLT
GOOGLE MAPS API
PHP
- PHP & Web Services — using SOAP to get meteorological data for a location
- PHP and Flickr accessing online photos through the phpFlickr class
Perl
Document Object Model (DOM)
UNIX
- Various snippets that make my life easier
- Create an Antelope Mail Archive
- Adding new projects to the Antelope contrib area using CVS
- Using Subversion to version control web sites
Generic Mapping Tools (GMT)
Miscellaneous
Projects
Courses Taught
Latest Favorites
- Make your pages load faster by combining and compressing javascript and css files
- Creating Liquid Faux Columns
- Setting up SSL under Apache 2 on SuSE
- PHP editing with ViM
- Getting equal-height columns in a three-column layout
- Star html Selector Bug
- Reset MySQL root account permissions
- How to write UNIX man pages
- Son of Suckerfish Dropdowns
- Aidan's PHP Repository
- Adium IM client
- ShapeShifter
- Install wiki on an iBook
- Quirksmode
- PHP
- GD
- JpGraph
- Vim Text Editor
- Generic Mapping Tools (GMT)
Mac OS X
Web Development
Beta
How To :: Snippets of useful UNIX code that make my life easier
Modify permissions on an RCS file
Go into the RCS directory (if there is one) and chmod on the ,v file. For example, you have a file called documents.html that has read-only permissions. You want it to have executable permissions. You need to go into the RCS directory and chmod the documents.html,v file to +x.
Repeat the last part of a UNIX command
Repeat the last argument of the command with a new command.
[user@host]$ mkdir this [user@host]$ cd !$ cd this
Using find and grep together
Search for string using find and grep together:
find ./ -exec grep "searchStr" \{\} \; -print
This prints out all matching results with the file name on the next line.
Getting MySQL query results into a text file in your home directory
This is actually really simple... there are two methods...
Method 1
- In the typical MySQL environment, query results are pushed to STDOUT (ie. the MySQL command line prompt). You need to change this to cat and then point cat to your text file in your home directory.
- Run your query.
- Exit mysql and you will see your result query in the text file you defined with the pager option. To return the output to STDOUT just type nopager at the MySQL prompt.
mysql> pager cat > /path/to/test.sql PAGER set to cat > /path/to/test.sql mysql> SELECT email FROM members WHERE password='' AND email != 'null'; 632 rows in set (0.01 sec) mysql> nopager PAGER set to stdout
Method 2
Make the database do the work, and just add the INTO OUTFILE within your SELECT statement:
mysql> SELECT email FROM members WHERE password='' AND email != 'null' INTO OUTFILE '/tmp/test.sql'; Query OK, 632 rows affected (0.04 sec)
Using cat in fancy ways
To create a file with 'cat', type cat and the redirection character ">" (greater-than) and a file name. Everything from Standard In (STDIN) eg. everything you type (or paste in a copy/paste operation) then gets written to the file until a CTRL-D is typed. The file will be created if it does not already exist or overwritten if it already exists. If you use double greater-than as in "cat >>" and a file-name the file will be appended to rather than overwritten. Some examples: cat > newwork.text (then type whatever you want in the file and finish with a CTRL-D) write everything that is typed following the 'cat > newwork.text' command, up to but not including the CTRL-D, in to the file 'newwork.text' Either create a new file 'newwork.text' or overwrite it if one exists. cat >> addwork.text (then type whatever you want in the file and finish with a CTRL-D) Append everything that is typed following the 'cat > addwork.text' command, up to but not including the CTRL-D, to the end of file 'addwork.text' Append to an existing file 'addwork.text' if it exists. Create it if it does not already exist. cat > screen.text (then highlight a piece of screen text with the left button and write it back with the middle button) CTRL-D copy everything in the highlighted section of screen text to the file screen.text. Either create a new file 'screen.text' or overwrite it if one exists. cat >> screen.text (then highlight a piece of screen text with the left button and write it back with the middle button) CTRL-D copy everything in the highlighted section of screen text and append to the end of the existing file screen.text. If it does not already exist, create it. cat filea fileb filec > combo-file Copy everything from files 'filea', 'fileb', 'filec' in to 'combo-file' Either create a new file 'combo-file' or overwrite it if it already exists. cat filea fileb filec >> combo-file Copy everything from files 'filea', 'fileb', 'filec' and append to the end of the existing file 'combo-file'. If 'combo-file' does not exist, create it. cat /dev/null > empty-file Create an empty file called 'empty-file. If a file by that name already exists, empty it out. (Note: '/dev/null' is a special null device on UNIX systems.)
Source: http://serv1.scnc.k12.mi.us/howto/edit/cat.html
Disclaimer
This information is freely provided as–is. Messing around with the command line and creating files is a serious business, and I accept no liability for errors created, systems corrupted, or hard–disk damage by you following these instructions. They worked for me but may not work for you. Remember to back–up EVERYTHING before you try any of this stuff — it is not simple OR easy!!!
If you have any questions about this please email me at rlnewman@ucsd.edu and I will try my best to help you out.