LAN Net Work!

LAN Net Work!

LAN Tait is Net Working!

Friends Flags…

Free counters!

Sessions

No Sessions

GitHub, Google Code and a Git GUI on Linux Mint Mate

Recently I was talking with fellow CodoDojo Sensei, Marie. She is having a problem with the Atahualpa Theme for WordPress. The author / team at Bytes For All have a different idea of what this theme should be than many of the people who post on their website.

Sensei Marie said she would like to take over the stalled TuKod project and focus on the TuKod Theme – a fork of the Atahualpa Theme. I told her to set up a ToKod Theme project on GitHub as this would help her. She asked my help and with my brand new Linux Mint Mate computer, I set out to find a Git GUI that would help her…
Continue reading Using GitHub, Google Code and a good Git GUI

WebSite 102 - First Webpage

<!DOCTYPE html>
<html lang="en-US">
<head>
  <meta charset="utf-8" />
  <title>HTML 5 complete</title>
  <!--[if IE]>
    <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  <![endif]-->
  <link rel="stylesheet" src="//normalize-css.googlecode.com/svn/trunk/normalize.css" />
  <link rel="stylesheet" href="style.css" />
</head>
<body>
<header>
  <h1>The most important heading on this page - Page Title?</h1>
  <h2>Important Info - Website Name?</h2>
  <h3>With some supplementary information - Tag Line?</h3>
</header>
<article>
  <header>
    <h1>Title of this article</h1>
    <p>By Richard Clark</p>
    <p>You could have a &lt;footer> or a &lt;header> for a &lt;section> or an a &lt;article>.
  </header>
  <h2>Hello World</h2>
  <p>Hello to everyone!</p>
  <footer>
    Footer information for article.
  </footer>
</article>
<footer>
  <ul>
    <li>copyright</li>
    <li>sitemap</li>
    <li>contact</li>
    <li>to top</li>
  </ul>
</footer>
</body>
</html>

WebSite 101 - HTML5, CSS3, PHP, JavaScript, Database, htaccess and SEO for DIY Coders

Lesson 1

Today I am adding a tutorial category I will call “WebSite 101.”  In WebSite 101 I will teach you how to build a WebSite, from the ground up.  This is really a Do-It-Yourself  (DIY) course that will take you from the very beginning (basic HTML).  Step by step we will build a dynamic, database driven WebSite that covers things like, HTML, CSS, PHP, JavaScript, Database, htaccess, and SEO.  Even if you do not know what any of those mean, you can follow this.
Continue reading WebSite 101

Common MySQL fields and their appropriate data types - Cheat Sheet

I am working on a new database class, and CRUD class, and login class that I plan to make the core of a number of new, dynamic, database driven websites. You see, all database driven websites have a number of things in common. For example some kind of user_name and password.

One thing I have found in my life is that I go back to the MySQL manual, again and again, to look up appropriate data types for my field names. For example, should a field for a users URL, or email address, be using a VARCHAR or TEXT MySQL Data Type and why?

For years I have taught my students Three Rules about MySQL Data Types and Field names. Students who follow these simple ruled hav much less problems designing and using Database Data Types (which next to selecting a field name, is the hardest thing about designing and using a database!).

I have now made a Cheat Sheet that makes all of this very simple!
Continue reading Common MySQL fields and their appropriate MySQL data type – Cheat Sheet

Security by Obscurity vs. the Obscurity Security Layer

I have on my desk about a dozen website projects to develop. Amazingly, they have a few things in common such as:

  • Dynamic user written.
  • Database driven.
  • Member and Admin Login.
  • Security Concerns.

Ever since Sony had their servers cracked open by what the press seems to report was the North Koreans, people have become a lot more aware of Security!  Security by Obscurity (or Security through Obscurity, or Security via Obscurity) has proven to be very little security at all.  This is because if the Obscurity is ever discovered (and usually can be discovered in a number of ways), the security becomes “totally compromised.” But does it really?  Well, yes and no! You may want to strengthen your security, by using the Obscurity Security Layer!

Continue reading Security by Obscurity vs the Obscurity Security Layer

Mint Mate 17 - Sharing 2nd Hard Drive

As I already reported, I am Leaving Ubuntu for Mint Mate 17. You may want to read that post before this one.

The only problem I had when I loaded Mint Mate was that my boot drive was 500gb and I added a second drive of 1TB to store movies on. But when I tried to share folders the same as I did with the boot drive, From the Client computer I could see them, but I could not open them, and I got this error…

Error: Unable to mount location – Failed to mount Windows share.

This Document explains how I solved this error.
Continue reading Mint Mate 17 – Sharing 2nd Hard Drive

Leaving Ubuntu for Mint Mate 17

My partner has a young daughter who likes to watch movies like Tinker Bell and Barbie’s Dream House. The problem is that she is a work at home mom and plays these movies on her computer. She is a work at home mom and uses this same computer for her work. Obviously the needs of one conflict with the needs of the other. She cannot work and play movies for her daughter at the same time!

The Old Computer

Earlier this year I bought a new computer, and kept my old computer to make into a development server. It only has 2 gig of ram and a Atom 2 core processor, plus a gigabit Ethernet controller. For a “house server” to serve I figured that was enough. Mostly just to serve movies to the 2 computers on our network. A few weeks ago I retired my 24′ screen for a 28 inch. Since then my partner has been eying the unused computer for her daughter to play movies on. So I decided to make a “mouse only” computer for playing movies, a samba server to serve the same movies to the other computers on the network, and to add SSH to build a LAMP (or LNMP) server in the background, later on.
Continue reading Leaving Ubuntu for Mint Mate 17

UTF-8 Character Encodings in HTML and CSS via htaccess - Easy!

Years ago I fell in love with UTF-8.  More recently I have developed a love for HTML5 and CSS3.  I have found that as I am teaching these, my students have been confused about how to set Character Encodings (and Content-Language).  So I decided to make an easy to follow tutorial on how to set both of these in your htaccess file.

Continue reading UTF-8 Character Encodings in HTML and CSS via htaccess – Easy!

PHP Tutor #4 - Fixing a String Case, trim, ucwords, strtolower

In this tutorial we will explore manipulating the case of a string, and how to clean up strings like names. in PHP Tutor #4 we learned how to put a literal string into a variable like this:

<?php
  $name = 'marie estebanie pelin';
?>

However, the problem with this is, it is all lower case! And what if the person entering it had added a space at the front or end of the string? That could mess up alphabetizing a list! Or what if we wanted to extract the initials, or what if we wanted just the first two letters of each name to make some kind of username? Let’s look at how we can manipulate the case as well as extract a few things from a Crazy Bird string. Assume someone entered the following. Notice the extra space at the ends!

<?php
  $crazy_bird_name = ' mArIe eStEbANIe pELIN ';
?>

Trim White Spaces

You can trim white spaces (or any character) from the left, right or both ends of a string!

Let’s use trim or rtrim to get rid of the white spaces at the right.

<?php
 $crazy_bird_name = ' mArIe eStEbANIe pELIN ';
 $crazy_bird_name = trim($crazy_bird_name);
// now it's = 'mArIe eStEbANIe pELIN'
?>

So now there is no space!

More Ideas:

  • ltrim() – Strip whitespace (or other characters) from the beginning of a string
  • rtrim() – Strip whitespace (or other characters) from the end of a string
  • str_replace() – Replace all occurrences of the search string with the replacement string

 

Start a Word with a Capitol Letter

<?php   $crazy_bird_name = ' mArIe eStEbANIe pELIN ';
  $crazy_bird_name = trim($crazy_bird_name);
// now it's = 'mArIe eStEbANIe pELIN'
  $crazy_bird_name = ucwords($crazy_bird_name); 
// now it's = 'MArIe EStEbANIe PELIN'
?>

Two Lines Only

This could have been written with only two lines of code by combining the last two lines like this:

<?php
  $crazy_bird_name = ' mArIe eStEbANIe pELIN ';
  $crazy_bird_name = ucwords( trim( $crazy_bird_name ) ); 
// now it's = 'MArIe EStEbANIe PELIN'
?> 

 

More Ideas:

Not Quite Right!

The above did make each word start with a uppercase letter, but it did not make them look like we wanted, human names! What we really wanted was for the first letter of each word to be uppercase and the rest of each word to be lowercase. So here is how we can do that…

<?php
 $crazy_bird_name = ' mArIe eStEbANIe pELIN ';
 $crazy_bird_name = trim($crazy_bird_name);
// now it's = 'mArIe eStEbANIe pELIN'
$crazy_bird_name = strtolower($crazy_bird_name);
// now it's = 'marie estebanie pelin'
$crazy_bird_name = ucwords($crazy_bird_name);
// now it's = 'Marie Estebanie Pelin'
?> 

We can also write this shorter like this…

<?php
 $crazy_bird_name = ' mArIe eStEbANIe pELIN ';
 $crazy_bird_name = ucwords( strtolower( trim( $crazy_bird_name ) ) );

// now it's = 'Marie Estebanie Pelin'
?> 

 

 

PHP Tutor #3 Operators and Assigning Variables

One of the very first things you are going to want to do is learn where are the php operators! Learn this well, Google

PHP operators

In the Google Results Page, look for the website:

www.php.net

And click there!

You should find yourself On the Operators page of the PHP Manual.

http://www.php.net/manual/en/language.operators.php

You will be looking at a list of links to the various PHP Operators.

In the Beginning…

As you start to learn php, you will use this page a lot. Operators are used in most lines of code. I tell you this so you will take note of how to get back to the Operators page, because you will be coming back here (after a decade and a half of coding php, I still come back here some days!).

Assigning a Simple Variable

There is a basic assignment operator, it is “=” (the “equal sign” without the quote marks!). It can be modified a number of ways with other operators, but we will leave that for another lesson.

You may be tempted to think of = as being “equals”, but that is very dangerous in conditions! What you should do is think of this assignment operator as “gets set to” instead of “equals”. When you get to conditional operators you will see that == means “equals”, so better get used to “=” meaning “gets set to” from the start!

Marie’s $name

My apprentice name is Marie Estebanie Pelin, so lets set her name in a variable name $name.

<?php
  $name = 'marie estebanie pelin';
?>

Remember to read this as:

$name gets set to 'marie estebanie pelin';

Always Use Single Quotes…

A good rule I live by is, “Always use single quotes, unless you MUST use double quotes!” It will save you in debugging time! If you do not know what to use, it is a safe bet you likely need single quotes.

Normal HTML5

For this I am using The real HTML5 boilerplate, so the HTML5 looks like this…

<!DOCTYPE html>
  <html lang="en">
  <head>
    <meta charset="utf-8">
    <title>HTML5 boilerplate – all you really need…</title>
    <link rel="stylesheet" href="css/style.css"> 
      <!--[if IE]>
        <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
      <![endif]-->
  </head>
  <body id="home">
    <h1>HTML5 boilerplate</h1>
</body>
</html>

Inserting PHP into HTML

Now let’s add the PHP so that both the title and the body <h1>tag display Marie’s name.

<?php // marie_name.php
  $name = 'marie estebanie pelin';
?>
<!DOCTYPE html>
  <html lang="en">
  <head>
    <meta charset="utf-8">
    <title><?=$name;?></title>
    <link rel="stylesheet" href="css/style.css"> 
      <!--[if IE]>
        <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
      <![endif]-->
  </head>
  <body id="home">
    <h1><?php echo $name; ?></h1>
</body>
</html>

Less Typing

After PHP v5.4 the following two commands are identical. This is because the echo shorthand has many uses. Before v5.4 you should make sure short-tags are turned on in PHP.  If you are not sure, the one with the word echo in it is likely safer at this time.  But as servers get updated to v5.4 the shorter one will see more and more usage.  They both work fine on most systems now.

<?=$name;?>
<?php echo $name; ?>

Either one echos (outputs) the data within the Variable.

Wrap-Up

In this lesson you learned how to put a literal string into a Variable and how to late echo it back to the browser screen.