Crimson Editor With PHP

I searched the web and couldn’t find anywhere that gave instructions on how to use the output windows in Crimson Editor to display PHP output. So that’s what I’m going to do in this post.This is going to be really simple so I hope you’re not expecting anything really hard.

I’m assuming you already have PHP and Crimson Editor installed on your local computer. The first thing you need to do is open Crimson and then open Tools > Conf. User Tools… from the menu at the top. Once you click Conf. User Tools… you will see the following Window.

Crimson Editor With PHP

All need to do is select an Empty slot from the list at the top center and fill in the fields below. I have a list of the fields you need to fill in and an explanation of what you need to put in each one.

  • Menu Text - This is the name of the tool that will appear in the menu for you to select. Choose any name you want.
  • Command - This is where you put the full directory path to the PHP interpreter or php.exe. On my machine it’s at c:\wamp\php\php.exe.
  • Argument - This field is for the argument you want to pass to the program. Because we want the PHP program or interpreter to execute the file we’re working on we will send it the full path to the current file. For this we use $(FilePath) which happens to be a variable that inserts whatever file you’re currently working on.
  • Finally make sure you check the box that says Capture output because this is what allows you to see the output in the output window. Crimson runs your code from the command line and captures everything in the window and pastes it in it’s own window.

It’s important to keep in mind that this will only parse the PHP code and not HTML. In other words you will see all the HTML without PHP code. You will see exactly the same thing as if you clicked view source on a web page.

PHP VARIABLES

In any language, a variable is essential to working with data and PHP is no different. If you have never done any programming you may be wondering what is a variable. Well, I’m going to explain that thoroughly here. If you’ve only worked with languages like PHP then this may still contain good information.

A variable is a name created for humans to work with and represent data stored in memory. When you want to work with data such as a name, it has to be stored somewhere and that happens to be the computer’s memory. Each memory address represents 1 byte but different data types such as an integer can take up more than 1 byte and therefore more than one address. For example, an integer usually takes up 4 bytes. It could get complicated and messy trying to keep track of what addresses are connected with something like a persons name or age. Variables were created for humans to allow them to assign a value to a name and then after you assign something to a variable the programming language automatically stores that data in memory and keeps track of what addresses correspond to each variable name. So, if I say $name = zach; I’ve assigned the name zach to the variable name $name and in PHP it automatically knows what addresses each letter in zach is stored at, you only need to remember $name.

Take a look at this picture to see an illustration of what I’m talking about. Each letter in the name is stored at a memory address which is represented by M1, M2, M3, etc.. (Click for larger image)

. String-Variable

In this example we have a variable called $name and it has a value of zach. All we have to do when working with this value is use $name and it’s the same as saying grab the data stored at memory addresses M1, M2, M3, and M4 which returns zach. So we can use $name in functions like strtoupper() to make them all capitals letters like this strtoupper($name) and it’s the same as if we said strtoupper(”zach”).

If you’re completely new to programming you may be wondering why we just don’t type zach instead of using a variable. The reason is because we don’t always know what the value will be ahead of time. An example of this might be a form where you ask your visitors to register for an account. The username would get sent in a variable from the form to your script in a variable like this $_POST[’username’] and then you would instruct the script to see if $_POST[’username’] is in the database of usernames

The Linux Command Line

I recently began to really take advantage of using the command line to manage my websites. I’m actually quite surprised as how much easier some tasks are to perform through a command line rather than through a GUI. The SSH client I’ve been using is Putty and it’s very simple, fast, and powerful.

A great example of how some tasks are easier via the command line is the ability to be able to specify a wild-card or Regex command on functions like copy, delete, move, etc.. I wanted to move all my PDF files into their own folder instead of being mixed in with all my html/php files. I could have used my FTP client and manually selected all 34 files and then copy them over but it was much easier to just type mv *.pdf /downloads/pdf/

Block Porn Sites With Host File

Note: Since the creation of this list better solutions are now available. When I created this hostfile list there weren’t any good free solutions to blocking adult sites…but now you can get a free and more comprehensive solution by using Opendns.org for your dns server and it allows you to create a free account and then block adult sites. It works very well and it’s free so you should use that instead and leave your hostfile for blocking adware/spyware sites.

About 1 year ago I began working on a host file that would contain porn sites for the purpose of blocking them. This has been done for years now to block things like ads and spyware but no one has been willing to work on one for adult/porn sites.

To make this work all you have to do is go to C:\WINNT\system32\drivers and open the hostfile with notepad or any text editor. It’s important to note that this file does not have and extension. You can rename it so it has a .txt to make it easier to open but remember to remove the extension when your done. Currently the list contains over 16,000 porn host names. In other words, zachwingo.info and www.zachwingo.info are considered two different host names so you will see two entries for almost all domains. To see the list follow this link to the Host File

Teaching Math Correctly

I am convinced that math is the most important subject in school but yet almost all math teachers fail to do it justice. What I mean by that statement is that our education system, especially when it comes to math is all about memorizing rules and speed and very little emphasis is placed on actually understanding the material thoroughly.

I believe this is partly why I’ve struggled with math, because I have to fully understand something or I get very stumped on seemingly small details because I’m busy wondering why something works this or that way. Anyone who knows me can testify that memorization is not at all my problem because when I was a teen I literally memorized over 6000 verses and I am still able to memorize things very easily. But when it comes to math memorizing rules and useful acronyms is the easiest part but understanding all the details of why we have those rules is the complicated part. A very basic example of this deals with fractions and squares. Most of us understand that when you multiply both the numerator and denominator by the same number it is essentially multiplying the entire thing by 1 and does not change the fractional value. However when my teachers began explaining how to work with and reduce something like x^m/x^n they would simply tell us to memorize a rule like if (m < n) then 1/x^n-m. I memorized that easily but I didn’t understand initially why that rule worked correctly and so I would become frustrated because they were moving on to other rules while I still didn’t understand why that rule worked. Finally I realized that x^2/x^5 is the same as multiplying the numerator and denominator by of 1/x^3 by x^2. This is when I realized that it was simply reducing a fraction like any other and I understood the rule.

I find it annoying the way math is taught because I actually love math but I rarely get the chance to take my time so that I can fully understand everything. This is precisely why I love taking programming classes from my CS professor because he recognizes how important it is to understand concepts rather than just memorizing and thus he takes his time and goes it to almost every detail you could imagine. I don’t really know what the point of this post is other than to rant about my frustration with the way math is taught because I’m convinced that most people would not hate math so much if it was taught differently.

Free Slide Presentation Backgrounds

Well, I was messing around in Photoshop when I needed a background for something I was working on so I made my own. They aren’t all that special but here are a few below. For the full list see the Backgrounds Gallery

Free Presentation Background Free Presentation Background Free Presentation Background

School Is Over!

Wow, this fall has been crazy, fun and frustrating but Christmas is almost here. For three year I worked around hundreds of kids each week and never became sick, then after I lost my job I have constantly been sick over the past 6 months. This has made studying for any real length of time very hard and even harder to take long tests. The good news is my “Intro to C” programming was fun and challenging but seeing my grades each week was the best part. I finished the class with a perfect score of 100% on every assignment, quiz and test.

Definition Lists

This is a post that will be continually updated with further examples and more detailed content as I have time.

If you have worked with HTML or XHTML for any length of time there is no doubt you are probably familiar with ordered and unordered lists. There is a third list type that is not as familiar to web developers and it’s called a Definition List. The W3C says that the Definition List:

“should consist of a term/definition pairs although definition lists may have other applications”.

The definition list has three parts the <dl>…</dl> which is the equivalent of the <ul>…</ul> in an unordered list. Next we have two tag that together form the equivalent of the <li>…</li>, these are the definition title tags <dt>…</dt> and definition tags <dd>…</dd>.

The definition title can contain inline elements and the definition can contain block level elements such as a paragraphs and blockquotes. This gives us the possibility to add a lot of meaning to our code.

A simply list might look like this:

<dl> <dt id=”absolute-value”>Absolute value: </dt> <dd><blockquote cite=”http://zachwingo.info”><p>A number’s distance from zero on the number line. The absolute value is written between a double line such as |5| or |-5|. Both -5 and +5 are five numbers or units away from zero so we say their absolute value or distance is 5. </p></blockquote> </dd> </dl>

The above code meets all standards and provides some very semantically rich code that is full of meaning and provides a lot of possibilities for styling with CSS.

This type of code is especially well suited for Glossaries, quotes, and anything else where you have a related term/definition. See the links below for some samples

Unit Analysis 6

NOTE:

We are required in this class to write a Unit Analysis that states the objective of the current unit, some key concepts and the implications of those concepts. In other words, we are to define a few of the concepts we talked about and what it means to us as programmers.

Purpose:

At the end of Unit 05 we should be able to explain the concept of a struct and how it is used. We should have a solid understanding of how to work with the data stored within a struct. We will discuss and demonstrate how to create and use a typedef. Also, we will begin to look at the string library and how to use some of the more important functions.

Concepts:

  • Binary File - A file that contains machine readable code rather than plain text. These files are intended to be read by a computer system/application and not by humans.
  • Buffer - A file buffer is a place in memory designed to hold a certain amount of data before writing to a file. A buffer is the middle man between the application requesting to read/write data and the file itself.
  • fwrite()- This function is for writing to files and takes 4 parameters. The parameters are: address of data to be written, size of data to be written, number of data elements to be written, and the file where the data should be written.
  • fseek()- This function takes 3 parameters and is used for setting the file pointer at a specific point for reading or writing. The parameters are a pointer to the file, the number of byte offsets from the origin, and the position from where the origin should be.

Implications:

Working with files is a basic but very useful skill needed by almost any programmers. Without the ability to write to files or a database the information gathered and produced by a application would be of little use. We need ways to save this information for use at a later time whether by a human or computer. If the files will be read and used by humans you will want to write a standard text file which is human readable. But if the file will be read and used by computers than it is best to use the binary mode because it is optimized for computers and in a language they understand natively. The C language has a number of very useful functions for working with functions like fwrite() and fseek(). The fwrite() function allows you to write data to a file buffer which then write the data to the file itself after a certain amount of data has fill it. The concept of file buffers are very important because it would be very time consuming and create a lot of overhead if we had to write to the file every time we had 8bits available. The fwrite() function allows us to specify the mode that we want to write whether that be in plain text or binary. The fseek() function is also very useful in saving time and by allowing us to specify how where we want to start writing and how much we want to read or write. You tell it where to start by specifying how many bytes from a given point it should be placed. Again files are very useful and like databases are almost a necessity if you want to write useful applications.

Unit Analysis 5

NOTE:

We are required in this class to write a Unit Analysis that states the objective of the current unit, some key concepts and the implications of those concepts. In other words, we are to define a few of the concepts we talked about and what it means to us as programmers.

Purpose:

At the end of Unit 05 we should be able to explain the concept of a struct and how it is used. We should have a solid understanding of how to work with the data stored within a struct. We will discuss and demonstrate how to create and use a typedef. Also, we will begin to look at the string library and how to use some of the more important functions.

Concepts:

  • Struct - A struct is a way to group related but different data types together to form a structured set of data. These created structs become a new data type that can be created and used just like an int or char.
  • Typedef - A typedef is a way to create and assign a new name to an existing data type. A good use of this is to create simple easy to remember names for structs because the syntax to use them can be very long.
  • Dot Operator- The dot operator is needed to access a data type within a struct. For example if you had a struct called address that contained an int called zip. We would access the variable zip by typing a dot between the address and zip as follows: struct address.zip
  • Strings- A string is created by assigning a set of characters to a variable that has been declared as a string. When a variable is declared as a string is allocates space in memory to hold the characters in sequence and thus it creates a string of characters.

Implications:

As we write programs we will often find that much of our input is related in some way and so we will want to find ways to group that data together. We have many different tools for doing that such as strings, arrays, and structs. Structs are useful because they allow us to create an instance of a data type over and over again with very little effort because we define it once in the beginning. We can create structs that group all the data needed for an address or a persons identity and then create an instance of that structure. Once a struct has been defined we can create an instance of it just like any other variable. For example, we can create an instance of an address by typing struct address one. In this example the struct address is the data type just like int and one would be the variable name. Instead of typing struct address every time we want to create an instance of that struct we can use a typedef to define a new name for the structure or any valid data type. This allows us to create a short easy to remember name. For example, we could type typedef struct address ADD. The ADD now becomes the name for the data type of the structure address and all that is needed to create a “address” like an int is ADD one. Finally, one way we can access the data declared within a struct we use things like the dot operator. Another example, if we wanted to access the variable int zip that is declared inside struct address we would use the dot operator and type one.zip

Now for the implications of strings; A string is literally a string of characters that have been strung together. Strings must be terminated by a NULL 0. Strings are incredibly useful and writing programs would take much longer if we would have find ways to connect a whole group of individual characters to form things like names. In the C language strings are stored within single quotes. There many different functions designed specifically for working with and manipulating strings. We can do thing like copy strings, concatenate several strings together to form one, and we can even select single character from a very long string if we want. Stings are just useful and without them we would not like programming…it would be very tedious.