Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

About this user

Tracy Floyd www.cdnm.com

« Newer Snippets
Older Snippets »
Showing 21-32 of 32 total

Disable autocomplete on input fields

// Disable autocomplete on any input field with the "autocomplete" parameter in your input tag

<input name="first_name" type="text" autocomplete="off">

Disable right click

// added to diable the right click.. works on *most* browsers

<body oncontextmenu="return false">

Disable IE image toolbar

// Place in the to get rid of the IE image toolbar

<meta http-equiv="imagetoolbar" content="no">

CSS Alternative to iFrame

// description of your code here

<div style="padding:20px; overflow:auto; border:solid 1px black; width:400px; height:300px;"> 
Content goes here...
<div >

Extract all .tar files in a dir

// Extract all tar files in a dir
for i in *.tar; do echo working on $i; tar xvzf $i ; done

Delete all the .jpg files in all directories below the current

// Delete all the .jpg files in all directories below the current
find /PATH/TO/STARTING/DIRECTORY  -type f -name "*.jpg" -delete

Check Disk Usage on Linux

// Check Disk Usage on Linux
du -sh /PATH/TO/DIRECTORY

Show the last modified date of a page

// Show the last modified date of a page
echo "Last modified: " . date ("F d, Y", getlastmod());

Set the server time zone

// Set the server time zone (Eastern time in this example)
putenv('TZ=EST5EDT');

Validate the format of an email address format

// Validate the format of an email address format
if (!preg_match("(^[-\w\.]+@([-a-z0-9]+\.)+[a-z]{2,4}$)i", $email)) echo "Email address $email is not valid";

Validate format of a domain name

// Validate format of a domain name
if (!preg_match("(^([-a-z0-9]+\.)+[a-z]{2,4}$)i", $domain)) echo "Domain name $domain is not valid";

Force or eliminate the www prefix for a domain

// Always add the www.
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] 


// Always eliminate the www prefix, use this htaccess code.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+)$
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
« Newer Snippets
Older Snippets »
Showing 21-32 of 32 total