Dark Launch

This is a Dark Launch.

jQuery find first empty form field using the :input selector

Find the first empty form field in JavaScript using jQuery with the example below.

Javascript
var myform = $("form");
var firstEmptyField = myform.find(":input[value='']:visible").not("button").filter(":first")
console.log("the first empty field: ", firstEmptyField);

Apache hide .git and .svn folder contents using .htaccess file

To hide .git and .svn folder contents you need create a .htaccess file with the following:

Code
php_flag display_errors on
RedirectMatch 404 /\\.git(/.*|$)
RedirectMatch 404 /\\.svn(/.*|$)
 

Another useful setting is to turn on error_reporting:

Code
php_flag display_errors on
php_value error_reporting 7
 

normal errors - bit value 1

normal warnings - bit value 2

parser errors - bit value 4

1 + 2 + 4 = 7

Or simply use a whitelist approach:

Code
# 403 Forbidden for all directory indexes
Options -Indexes
 
# Add all files to the list of files to hide when listing a directory
IndexIgnore *
 
# Use whitelist approach.
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !\.css
RewriteCond %{REQUEST_URI} !\.js
RewriteCond %{REQUEST_URI} !\.png
RewriteCond %{REQUEST_URI} !.*\/$
RewriteRule .* /404 [L,R=302]
 

favicon - the most correct & compatible way to add a favorite shortcut icon

The most compatible way to add a favicon is to use a self-closing link element with the rel property containing the words "shortcut" and "icon".

HTML
<link rel="shortcut icon" href="path/to/icon.ico" />

The word "shortcut" is a workaround for Internet Explorer if you have an icon that is not named "favicon.ico" or to share the favicon for subdomains.

Lastly, you can omit specifying the favicon at the top of the page as long as your icon is named "favicon.ico" and is available at the root direction; e. g.: http://www.example.com/favicon.ico ...but using this method is not recommended as the page will load before the icon is displayed.

MySQL Find non-ascii characters using REGEXP

To find non-ascii characters using a SELECT query, run a query similar to the following:
SQL
SELECT
*
FROM
`mytable`
WHERE
`column` REGEXP(CONCAT('[', char(128), '-', char(255), ']'))