Friday, June 19, 2009

Full Django support on the GAE, 1.2.3?

Gosh... It looks like I have a lot of porting to do.

Google just released the 1.2.3 version of the App Engine which includes full support for Django 1.0.2. What this means is that I can now ditch the Google App Engine Patch (a collection of hacks to get Django running on the G.A.E) for one of my current sites, www.aboutaplace.com.

I am extremely excited to test this out.

Btw, the Google Maps version 3 is completely amazing. I've recently developed tools for it on www.signonsandiego.com and www.aboutaplace.com.

Thursday, May 28, 2009

Naked Domains for Google App Engine, (WWW)ahoo!

After several months of frustration, I can finally assign a Google App Engine project a www domain easily.  No more URL Frames *shudders* or Redirects!  Cheers!

In the past, when trying to add an AppEngine project to the www domain, I would be prompted with a conflict:  Sorry, the www sub-domain is taken.  Please choose a different sub-domain for your project.  Actually, the error message was a bit more USELESS than that but if you ever saw it, you'd know what I mean.

Well, guess what?  It was taken.  By google-sites!
To free your domain of the www hi-jacking, follow these 3 easy steps:

(1)
First, log into your google apps account by going to http://www.google.com/a/.  You'll need to click on the Returning user, sign in here on the right hand side to enter your credentials. 



(2)
Click on the Service Settings tab on the far right of the tool bar.  And then click on Sites.



(3)
Here you'll find a little bugger of a tab named Web address mapping.  Click on it!  That's where the evil pirates are hiding...  After doing so, you'll see that www.mywebdomain.com was pwn3d by google-sites!



Delete!  delete!  delete!!!+shift1!!

Wednesday, April 15, 2009

The Bear Minimum - Decision Making, The If Statement

What would you do if somebody asked you the question:
Are you ready for some football?!

If you like football, I'm sure you would say something like "I can't wait, I looOOove the {{insert Team Name here}}!". Otherwise you'd say "Nope" to some degree.

An expression like this can easily be represented in code. A super simple program may be represented as:
Prompt a message "Are you ready for some football?"
If the user types in "Yes" the display "I can't wait!"
otherwise display "No way!"
The general form of making a decision in a programming language is with the if-statement. A single if-statement performs a task similarly to if something is true then do this. Additionally, the if-statement has a best friend -- the else keyword. In most languages you can follow the if-statement with an else to do if something is true then do this else do that.

Java Examples:
boolean cond = true;
if (cond) System.out.println("The condition is true!");

boolean conditionTwo = false;
if (conditionTwo) System.out.println("The second condition is true!");
else System.out.println("The second condition is false!");
The above will print out "The condition is true!" and "The second condition is false!" When you've mastered the art of using if-else, you can also pick up another trick -- the else-if-statement. This allows you to chain together multiple if statements where only one of the statements will ever be executed.

Java
Here's a simple program named DecisionMaker.java. This program attempts to compare an integer with various conditions.
class DecisionMaker {
public static void main(String args[]) {
int i = 0;
if (i == 1) System.out.println("one!");
else if (i == 2) System.out.println("two!");
else if (i == 3) System.out.println("three!");
else System.out.println("The variable i is not one, two, or three!");
}
}
The output will be "The variable i is not one, two, or three!"

JavaScript
In a file named DecisionMaker.html
<script type="text/javascript">
i = 0
if (i == 1) document.write("one!")
else if (i == 2) document.write("two!")
else if (i == 3) document.write("three!")
else document.write("The variable i is not one, two, or three!")
</script>
The output will be "The variable i is not one, two, or three!"

Python
In a file named DecisionMaker.py
i = 0
if i == 1: print "one!"
elif i == 2: print "two!"
elif i == 3: print "three!"
else: print "The variable i is not one, two, or three!"
The output will be "The variable i is not one, two, or three!"

Thursday, April 9, 2009

The Bear Minimum - Variables and Simple Arithmetic

In order to program, you need to be familiar with some basic algebra concepts even though you don't need to be any decent at math. The following should make sense to you and you should be able to tell me the answer in every situation:
a = 1
b = 2
c = a + b + 1
What is the value of c?

m = 3
n = m - c
What is the value of n?

x = 5
y = x * 2 (where the asterisk is the multiplication symbol)
What is the value of y?


With algebra we are introduced to the concept of variables. A variable, as daunting as it may sound, is simply some 'thing' that contains 'something' else. Above we have several variables: a, b, c, m, n, x, and y and they will store a number. In these examples, these numbers are whole numbers -- oh that's just an observation for now.

Going through this from the top to the bottom we can conclude that:
c = 4
n = -1
and y = 10


But that took brain power to solve. Let's get the computer to perform the calculations.

Java
In order to create a variable in Java we need to specify what type of 'thing' it is going to contain. One of the types you can use is an Integer or int. An int represents a smaller whole number. You should use it for a variable that you know will never be greater than a trillion. To declare what type a variable is going to be write it before the variable name. If you want the variable "a" to be an "int" you can write it as "int a".

Here's the code and make sure that you save it as SimpleArithmetic.java:
class SimpleArithmetic {
public static void main(String[] args) {
int a = 1;
int b = 2;
int c = a + b + 1;
System.out.println("What is the value of c? " + c);
int m = 3;
int n = m - c;
System.out.println("What is the value of n? " + n);
int x = 5;
int y = x * 2;
System.out.println("What is the value of y? " + y);
}
}



Compile and run the java file and you'll get he desired results.


JavaScript
JavaScript and Python is a little more 'loose' than Java where you don't need to specify the type of your variables. The same code in JavaScript should look very similar to the algebraic expressions. Also, in this example and printing out three "break" tags in order to print the messages on separate lines so I hope that doesn't confuse anyone.
<script type="text/javascript">
a = 1
b = 2
c = a + b + 1
document.write("What is the value of c? " + c)
document.write("<br />");
m = 3
n = m - c
document.write("What is the value of n? " + n)
document.write("<br />");
x = 5
y = x * 2
document.write("What is the value of y? " + y)
document.write("<br />");
</script>



Open up the file in your favorite browser and you'll be greeted with the following:


Python
Like JavaScript, this is a loosly-typed language. You don't have to specify what the type of your variables. In this file, named SimpleArithmetic.py -- BTW unlike Java, Python files aren't coupled to the name of the class -- we can write code that look eerily easy to understand.
a = 1
b = 2
c = a + b + 1
print "What is the value of c? %s" % c
m = 3
n = m - c
print "What is the value of n? %s" % n
x = 5
y = x * 2
print "What is the value of y? %s" % y



Doesn't python look beautiful? Executing the code is easy as pie as well.

The Bear Minimum - Simple programs using "Hello World!"

Whenever you try learning a new program language, I guarantee that you'll run into the phrase "Hello World," among others like "Foo Bar." HelloWorld is a simple application that prints out a phrase to the user and provides an experienced programmer the syntax and grammar on how to use this language. In some ways, its referred to the simplest application you can write for a programming language.

Below we'll create three different HelloWorld programs.

Java
In order to create this program in Java we'll have to create a file named HelloWorld.java. Please use a text-editor such as NotePad or Vi to do so. Within this file, we'll write out some java code that will allow us to print the message to the user.

Here are the contents:
class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}



Before you can run this file, you will have to compile it first. Compiling takes the code that you've written and converts it into a language that the machine (Java Virtual Machine) can understand. Before you compile, go to the directory that contains the file with your command-line tool. If you saved the file under "c:/myprograms" you can type "cd c:/myprograms". Make sure that the file exists and has the ".java" extension. You can do this with the "dir" command.

To compile type:
javac HelloWorld.java


If your code is valid, it will create a file named HelloWorld.class and not prompt you with any errors.

To run the program type:
java HelloWorld


Notice that when compiling you must pass it the filename and when you try to run the program you only use the name of the class.



JavaScript
To create a HelloWorld app in JavaScript, let's create a new file named HelloWorld.html. Within this file use the following:
<script type="text/javascript">
document.write("Hello World!");
</script>



Make sure that the editor that you're using saves the html file without adding any extra markup. Some will manipulate the characters above in order to make it "readable" to humans rather than executing it as code.

To run this code, open HelloWorld.html in any web browser such as Internet Explorer or FireFox.



Python
In a file named "HelloWorld.py" type:

print "HelloWorld!"



Then on the command-line, within the same directory as HelloWorld.py, run the code with the following command:

python HelloWorld.py



Easy ain't it?!

Wednesday, April 1, 2009

The Bear Minimum - Finding your path

Since most people are Windows users, you will probably have to modify your path variable to make programming a little easier for you. If you're using Ubuntu or OSX this should already be set up for your or you'll already know how to do it!

The path variable allows you to access files and programs easily from any directory or folder on your computer. For the most part, you will be compiling and running Java programs from the command-prompt so making sure your path correctly is extremely helpful. Before you modify your path variable, first you'll need to know where the JDK was installed -- it generally installs to c:\Program Files\Java\jdk1.6.0_13 where these numbers at the end specify the version.

Make sure that the jdk directory exists and you may want to look within the bin folder. Within it you should see a file named "javac.exe".

We want to be able to easily access the javac program from anywhere on the command-prompt so we'll want to add that bin directory to our System's path. Based on your flavor of Windows, finding the path variable may be a journey of it's own. You should be able to find it by following:

Start > Control Panel > System > Advanced > Environment > Variables
OR
Start > Control Panel > System > Advanced Settings > Change Settings > Advanced > Environment > Variables

Basically we need to modify the environment variables. Once you find it, there should be two lists: one for user variables and one for system variables. Let's change the system variable as it will make the change for all users and programs. Within the system variables list, find the word "path" under the variable column and then click on edit.

And carefully add the following line to the front (or to the left of the existing text):
c:\Program Files\Java\jdk1.6.0_13\bin;


Remember, if your jdk directory exists at a different location on your computer, please make sure you use it! Your jdk and bin directory may be at c:\Program Files\Java\jdk1.5.0\bin or c:\java\current_jdk\bin so make sure you found it first.

And yes, there was a semi-colon.

JavaScript
You will not have to add anything to your path.

Python
You may need to add the Python folder to your path. Find out where you installed python and make sure that the directory has the python.exe file. It may be at c:\python26 or c:\python.

Follow the same steps from above and add the following to your path variable:
c:\python;


Don't forget the semi-colon.

The Bear Minimum - Finding and Installing the required software

In order to write code all you really need is a keyboard and a text-editor. You don't need anything special at all! You can even write code with a pen and paper, but I doubt a computer would ever make sense of it.

The code is meaningless without the tools you need to compile and run it. For Java, these tools are packaged in the Java Standard Edition (SE) Software Developers Kit (SDK) -- yes I know, it's a long name. Navigating http://java.sun.com is pretty complicated so here are some images to help.

On the right rail, you'll see a list of Popular Downloads, click on Java SE. Try to fight the temptation of clicking on Java EE 5 SDK!



Then on the downloads page, click on the Download button that follows Java SE Development Kit (JDK). And again, avoid the temptation of clicking on the first button, Java SE Runtime Environment (JRE). The JRE allows you to run java programs but not compile or "make" them.



Finally, on the next page fill out the required information to begin the download. After it's completed, install it!

Javascript
JavaScript is a programming language that you probably already have. It's packaged with most modern browsers. Congrats! You don't have anything extra to do here... Except that if you're using Internet Explorer you may want to consider downloading FireFox or Opera.

Python
Python is sometimes considered as a lowly-scripting-language but it's a very powerful and modern language that I highly recommend. In order to install this language go to http://python.org and click on the download link on the left rail. You'll want to download a version of Python 2.6+ because the next version, Python 3+ is not fully adopted yet.