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

The following snippet will create a .htaccess file with display_errors on and hide .git and .svn folder contents in the current directory if it doesn't exist, otherwise it will display the contents of the file.

Code
# create .htaccess with display_errors on
alias ht="if [ ! -f .htaccess ]; then echo \"writing to .htaccess\";
echo -e \"php_flag display_errors on\nRedirectMatch 404
/\\\\\\\\\.git(/.*|$)\nRedirectMatch 404 /\\\\\\\\\.svn(/.*|$)\" >
./.htaccess; echo \"done. contents:\"; fi; cat .htaccess;"
 

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), ']'))