Tuesday, August 16, 2016

Validate Email Address [JavaScript]

The following is a quick and dirty way to validate form input, using JavaScript, from a user to confirm that they are entering a value, which could be interpreted as an email address. The function below is meant to quickly and simply ensure that the value provided by the user contains the at '@' symbol and a period '.', nothing more!

// Vanilla JavaScript
function validateEmail(emailAddress)
    if (emailAddress.value.indexOf('@') == -1 || emailAddress.value.indexOf('.') == -1) {
        alert("Invalid Email!");
        return false;

The validateEmila function relies on the global method indexOf. That method returns the first position at which the specified string value occurs.

Keep in mind that this is not a complete and exhaustive method of validating an email address. There are better and more comprehensive ways to do so. For example, make sure that the email address doesn't contain any spaces, symbols, HTML characters, or that it starts with a letter, not a digit.

Tuesday, March 31, 2015

Messing with WordPress SPAM Bots

If you have a WordPress based blog, or otherwise use WordPress as a CMS for your website, you are either getting a lot of bad user accounts being created or noticing a lot of knocking on your wp-login.php page. WordPress has a nice feature which allows you to install WordPress in a directory other than the root one. For example, your site is served from http://blog.example.com, but WordPress can be installed in http://blog.example.com/wpcms. In past versions of WordPress, prior to 3.8 or maybe be older than that, unless you knew the exact path to where WordPress was installed you could not get to the dashboard. That has changed! Now even if WordPress is installed in some random directory, if you navigate to http://blog.example.com/wp-login.php you will be redirected to the actual WordPress login page. Convenient, but not helpful when dealing with SPAM bots.

Friday, July 11, 2014

Balloon Flowers of 2014

We have Balloon Flowers (platycodon grandiflorus) in a half barrow pot. They are one of my favorite flowers that we have around the house. Simply because of how the flower forms. It starts as a small ball, which slowly grows into the shape of a hot air balloon, and once it opens it looks like it had exploded.

[gallery type="rectangular" link="file" ids="2611,2612,2622,2615,2613,2614,2616,2617,2618,2619,2610,2620,2621"]

I planted the flowers from the pictures above about seven years, ago.

Wednesday, May 28, 2014

Backyard Garden - May 28th, 2014

The weather is finally "stabilizing" to where the temperature is more consistent and higher, like it should be for this time of the year. Also it is not raining every single day, or hailing, like it has in the last few weeks. So now the flowers are starting to come out and they look really nice.

[gallery type="rectangular" link="file" ids="2585,2584,2583"]

Saturday, November 23, 2013

How to protect wp-login.php using .htaccess and .htpasswd?

If you own or maintain a WordPress based website you might or might not be aware that the wp-login.php page in your root directory and the wp-admin directory are under constant attacks by malicious bots. This tutorial will show you how to password protect the wp-login.php file through the use of .htaccess and .htpasswd.

A quick side note before I continue - to improve your website’s security create a new administrator account, a non-standard username. Once that is done, delete the admin account. WordPress will automatically resign all posts and pages to any other user of your choosing.

For this primer, we will assume that your WordPress installation is in the root directory of your website. With most shared web hosting companies the path to your account’s web directory will be something similar to /home/client_account_id/public_html, where public_html is the web root directory. To view the exact path SSH into your hosted account and executing pwd, short for print working directory.

Friday, November 22, 2013

Task list when setting up a new web server. [LAMP]

This is my to-do list when preparing to deploy a new web server. The majority of the time I use Ubuntu as the operating system, though I have used Fedora and CentOS in the past. I also manage RedHat Enterprise Linux servers at work. These tasks are mainly for a web server. Setting up just a file server is a lot less work; while setting up a proper mail server is significantly more work, since they are a constant pain to configure and maintain. With a mail server you have to think of local vs external user access; logging and connection encryption; how you are going to store files; user interface and its security; MX black lists, SPAM, and open relays.

Sunday, October 06, 2013

How to setup Coda 2 to push to GitHub?

Setting up a new site in Coda 2 and cloning a GitHub remote repository is not that big of a deal. Where you will most likely run into problems is when you try to push your changes to the GitHub remote repository. Below I will show you how to update the Git config file in your local repository so you do not run into one of the following errors:
  1. git push failed remote: Remote anonymous access to repository denied
  2. git push origin master Username: fatal: Could not read password
The GitHub repository address I am going to use is that of Source Code DNA: https://github.com/thetitan/sourcecodedna.git. I will assume that you have already setup your Coda 2 site profile and cloned your repository, you have made some changes, and now you are ready to push those changes to your projects GitHub repo.

Friday, June 28, 2013

Source Code DNA, a repository/library for code snippets in JS, PHP, Perl, C/C++ and Objective-C

I have started a new section on Titan Fusion, specifically for programming. I have named it Source Code DNA. I am going to use it just as library/repository for various snippets of code, e.g. classes, functions, small scripts. At this time I am going to limit the content to the following languages: JavaScript, HTML5, CSS3, PHP 5, Perl 5, Python 2.7, C/C++, Objective-C. Mainly because those are languages I know and most often use.

My goals for Source Code DNA are:

  • Once enough classes and functions have been collected for a particular language to create a framework, a library, or a kit for others to use.

  • Make the code available to all.

I have also started a Source Code DNA newsletter, delivered by MailChimp. The newsletters will be used for announcements, as well as an FAQ and mention of other useful articles.