Posts Tagged ‘web’

Serve a Static HTML File with NodeJS

So, I posed a question onto StackOverflow today and got some really good advice. My question was this: how do I server a simple static HTML file from Node.js. I’m not a fan of doing this:

response.write("...<p>blahblahblah</p>...");

From most, the answer was “use
Express.js“. That’s good advice if you just want to get the job done. However, I think the point was lost.

In this particular instance, I wanted to have at least a superficial understanding of the mechanics of what’s going on underneath the pretty interfaces of the framework.

Anywho, here’s one way of doing it given a file ‘index.html’ in the same directory:

var sys = require('sys'),
    http = require('http'),
    fs = require('fs'),
    index;

fs.readFile('./index.html', function (err, data) {
    if (err) {
        throw err;
    }
    index = data;
});

http.createServer(function(request, response) {
    response.writeHeader(200, {"Content-Type": "text/html"});
    response.write(index);
    response.close();
}).listen(8000);

Nothing fancy. Just open the file, store the contents, and puke it back up on every request.

If there is a more elegant way of handing this extremely simple use-case utilizing only core libraries, feel free to share it on the StackOverflow post.

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Google Buzz

Google Chrome Frame to Fix Microsoft’s Internet Explorer Issues

Two weeks ago, Microsoft announced it’s intent to continue to support the 8 year old Internet Explorer (IE) 6 until the year 2014 (IE Blog). The response from the web was difficult to distinguish from the sound of nooses tightening around scrawny necks and bullets plowing through HTML and Javascript packed minds. But, alas, the day has been saved. Well…for those who have yet to commit hara kari, that is. Google is steping up to the plate to accomplish what the big “M” is unwilling (or incapable) of doing.

It’s a bird! It’s a plane! No, it’s…Google??

Google announced the IE plugin called Google Frame. On pages that require advanced features that IE simply does not support, rather than dumb down the page or simply turn IE users away, web developers may now require users to install Chrome Frame. For pages that support this plugin, any version of IE will be able to tap into the power of one of the most advanced web browsers available today. For all other pages, IE will retain its normal (albeit, irritating) operation.

Here’s a better summary of Chrome Frame and it’s purpose straight from Google…

So Microsoft is thankful for the help…right?

Wrong. But their nay-saying is quite understandable. Googles move undermines Microsoft’s authority and strangle hold on the web in the worst way imaginable.

The official word from Microsoft is that Chrome Frame will make IE “less secure”. This is the argument from the company whose product was revealed to contain a Kanye-West’s-head sized security hole just this December. Every expert in the public eye took the opportunity to warn everyone away from the browser (Tech Flash, BBC amongst many others).

In an effort to recover from the IE security scare, Microsoft performed…er…I’m sorry “NSS Labs” peformed security tests (with Microsoft sponsorship). Guess which browser was found to be the most secure: IE…by a lot. A whole lot. A whole hey-why-does-this-ballot-chad-look-funny lot.

Now that Microsoft has established that its browser is the, *ahem*, leader in security, it is free to use this “boogyman” tactic to scare users from installing the Google product. But why, OH WHY, would they not want Google’s help in fixing their browser issues?

Once you go black…

Microsoft has a very real concern. IE is regarded by the majority of the web world to be a technologically inferior product. However, despite this and the fact that there are far superior and free alternatives (Google Chrome and Mozilla Firefox, to name two), IE retains the overwhelming market share.

The reason is simple: IE comes preinstalled with Windows and people have been “eating” this product for as long as they have had ‘net access. After all, what’s the difference? A browser’s a browser. All I wanna do is read the latest Matlock blog and take my Geritol! Aside: Does anyone actually know what Geritol is???

How is one to know the joy of biting into a thick n’ juicy marinated steak when they’ve been on an Ethiopian diet consisting largely of meal worms and whatever was inside the crate marked “UN”?  And once you’ve tasted quality, it’s difficult to go back to freeze dried fruit.  Microsoft stands to potentially have the blindfold removed from their users eyes that they’ve worked tirelessly to staple into place.

Bottom line: provided the plugin reaches the popularity of other plugins, such as Adobe’s Flash player, web developers around the world will sing Ewok-ian songs of praise to the search giant for freeing us to use the moder-day advancements that Microsoft has repeatedly failed to employ.

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Google Buzz

6 Tips for the Transition From Destkop Programming to Web Development

When I was learning web development, I had already been programming desktop applications for a quite some time. However, it did not come to me quite as easily as simply picking up a new programming language.

The largest roadblock was attempting to fit the web programming paradigm into my existing picture of application development. If you’re new to programming, this should not be an issue since you are basically a blank slate. But if you’re already a programmer, hopefully you find this helpful.

Here are six things that would have helped me out while learning web development. Oh…and I’m bringing back the count DOWN.

6) Learn the basics of relational databases

Most useful websites are really nothing more than easy and intuitive interfaces for databases and files. Some popular options are Microsoft SQL Server, PostgreSQL, and MySQL. All of these are what can be considered different “flavors” of SQL. They all have the same basic functionality and each brings it’s own set of bells and whistles.

I’d recommend PostgreSQL and MySQL because they have the advantage of being completely free.

Some very basic things that you will need to do in a database include:

Creating a schema
Creating a table
Dropping a table
Modifying a table
Creating a primary key
Creating a foreign key
Inserting data
Updating data
Deleting rows of data
Retrieving rows of data
Retrieving columns of data
Retrieving cells of data

This is by no means an exhaustive list of database topics, but you can definitely get the ball rolling with these concepts.

5) Forget what you’ve learned about data persistence and control flow

In the desktop app world, the state of the application data and objects are maintained in memory for as long as needed. This isn’t quite how it works in the web world. A web application is very decentralized.

As you know, browsers request information from a remote server and receive a text response in the form of HTML, javascript code, etc. This response is the output of a server side script being executed. But there is not a “running program” per se. Aside from what is stored in the database, the application maintains no state. Once the application script is executed, the application instance is terminated. A new instance is created on each request to the server.

Information such as a user’s logged in status is carried between these instances in a storage space called the session.

Crazy picture, right? And we haven’t even started talking about client side code yet! For the purposes of starting web development, it’s a good idea to start off by learning how old-fashioned Web 1.0 pages work. Fancy Web 2.0 pages simply build upon these principals by shifting more work to the browser and minimizing server submissions.

4) The languages themselves are simple. The hard part is the system

I’ve occasionally heard desktop application programmers scoff at web programming as “simple”. In a sense, this is correct. The languages of web development are considerably less complicated than a language such as C++. But the complexity comes from the fact that many different programming languages are interconnecting.

As a web programmer, you are tracing control through a bare minimum of two languages: HTML and your server side scripting language. But if you wanted to do anything even half way interesting, you will be using no less than five: HTML, a scripting language, CSS, SQL, and javascript.

If any one of these languages had the same level of complexity as C++, then software engineer suicide rates would certainly rise to a level rivaling poets and dentists!

3) Learn about SSH and FTP

If you’ve lived your whole life in a Windows world or have not had much network experience, then you may not be familiar with secure shell (SSH) or file transfer protocol (FTP).

Often times, you will have to modify a configuration file on the server or maybe upload some files. If you run linux, then you’ve got this compatibility right out of the box. However, in Windows, you have to download some tools in order to accomplish this.

Similar to Telnet, SSH is a way for two computers to exchange data. More specifically, they allow you command line access to a server. The difference between the two is that SSH is, as the name suggests, secure. That means that in addition to the web or IP address, you will also need a username and password. The best free option for SSH on Windows is a tool called PuTTY.

Download PuTTY here.

FTP, again, as the name suggests, is a way to transfer whole files to the server. There are several FTP options for Windows. However, I use the tool called WinSCP because it plugs in quite seamlessly to PuTTY as well as another of my favorite tools, Notepad++.

Download WinSCP here.

2) Start without a framework (ESPECIALLY Microsoft .NET)

Frameworks are great. They allow programmers to focus more on getting the job done as opposed to reinventing the wheel. However, if you plan on making full use of that wheel, but don’t fully understand how it works, then you’re likely to end up using it as a coffee table when you really wanted to ride west.

When you use a framework, so much of the work is done for you that much of the underpinnings of web programming will pass you by. That is why I strongly recommend steering clear of all frameworks. Especially Microsoft’s Visual Studio products for the beginner. Sure, you will be able to do some cool things pretty quickly. However, you would have only a superficial understanding of how it works. And debugging can be a nightmare if you don’t know what’s going on under the hood.

Just think about it this way. When you were in school, do you think you would have been able to learn your multiplication table very well if they handed you a calculator from day 1? As an adult, we use them freely because we fully understand the concept of multiplication. Learning is not our goal. Being productive is.

And the number 1 tip is…(drum roll please).

1) Bookmark W3Schools.com

This website is one of the single greatest resources of information on the topic. Nearly any and all web development technologies are represented in its hundreds of short and simple tutorials.

It’s not only great for learning. The short and snappy coverage of topics makes it a great reference source as well.

While you are working on honing your web development skills, there will be several times that you will ask yourself things such as “what were the order of the parameters for this method again?” or “what was the HTML attribute that allows me to center the content?” W3Schools will have your answer.

In fact, if I have a question on a topic, I’ll often enter the topic into Google followed by “w3schools”.

W3Schools.com

Check this resource out, and I promise you will love it!

Hmm….I suddenly have the urge to grow a beard and start selling OxyClean. Odd…

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Google Buzz

Xbox 360 Wireless Internet Without Spending $100

So, you’ve got an Xbox 360 and you’re ready to jump onto Xbox Live and get your butt handed to you by a foul-mouthed 12 year old. Only one problem: your 360 is 123,413 ft away from your internet connection. Unfortunately, this is the problem I have.

If it were up to Microsoft, you would have to buy a $99 wireless network adapter. Unfortunately, many people do this even though they may have one on which they’ve already spent good money: their laptop.

So what’s the big idea, yo?

If your lap top was made anytime after the Carter administration, it should be equipped with the ability to go online both wirelessly and wired…um…ly. If we are using the wireless, then the wired port is going unused. We are going to be connecting our Xbox 360 to the laptop through the wired port as if it were an internet source and then piggy back off of it’s wireless internet connection. Note: This is only one application of internet sharing. There are a number of additional ways in which this ability may be used.

Dividing the wallet rape by 10

Besides a laptop, there is one additional cheap item you will need: a crossover cable. Basically, its just a special type network cable, but looks exactly like any other. You can get this for about $10 over at radio shack. It’s a cost, yes, but I’m pretty certain that you’d much rather part with Mr Hamilton than Mr Franklin.

Now lets get this bad boy set up. First I’ll show you how to do this in Windows Vista, then we’ll cover Windows XP. Note: If after following these steps, you are unable to get a connection, either “repair” your connection or restart your computer. Either of these will allow the change to be set.

Windows Vista
Windows XP

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Google Buzz

Pages: 1 2 3

Microsoft Internet Explorer: The Cancer of the Web

Originally posted December 17, 2008

My mission today is simple. As a web programmer, I am here to beg you all to please, please, PLEASE stop using Microsoft Internet Explorer (IE)! It is a web programmer and developer’s worst nightmare of a browser!

We are the nice people who give you things like YouTube and internet porn. All we as in return is that you stop using IE.

What prompted this sudden geek spasm, you ask? This article from Yahoo! explains it all. There is yet ANOTHER ginormous security hole the size of Kanye West’s ego in IE that is being exploited.

Going down with the ship

Unfortunately, since Windows comes with IE preinstalled, many people do not even know that they’ve been using is a crap (to put it nicely). Do bug eating people from the jungles of Idaho know what prime rib taste like? Hell no.

If you want to give your computer a health boost , start by cutting its junk food intake. There is an unthinkable about of custom code written out there just to work around IE’s bugs and deviations from standards. This particular security hole is just the latest in a long history of such happenings. Sure enough, Microsoft will patch this hole and sit back waiting for the next leak to spring. Hell, everyone chained to IE is practically riding in a quilt boat.

Yes... I'd rather web browse with poo than IE.

Let me put it this way: if IE were to disappear forever, the internet as a whole would fast forward about 5 years in technology and security. It’s kinda hard to explain the reasons why unless you’re a programmer as well, but here are two other browsers that if you try, I PROMISE you’ll love. They are faster, more stable, less of a security risk, and will extend the good health of web developers everywhere by 10 years.

Real quality browsing for zero cost

Take a look at these two browsers: Mozilla Firefox and my personal favorite Google Chrome.

Firefox has been around for quite a while. It was what popularize the whole tabbed browsing thing WAY before IE 7 (the one that you are probably using if you are an IE user). This one has a crap load of freakin’ sweet plug-ins that let you do neat things like download videos from sites like YouTube and god only knows what else. Developers love it for the Firebug plug in. This is the swiss army knife of browsers.

If you don’t care too much about extras, the Chrome is definitely the one for you. Chrome just came out of beta recently. It is to IE what a Ferrari is to a shopping cart. The performance of this thing is amazing and it has an awesome, low profile interface.

A final plea

Please everyone…do the WORLD a favor, and use any browser but IE. If you like either of the ones above (and I KNOW you will), use it at work. If your computer is locked down, pester the hell out of your office network admins until you can bitch-slap some sense into them. Then, start a chain and get everyone else you know to drop IE….PLEEEEASE!!!!

Ok….i’m done. Back to work using Chrome and Firefox!

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Google Buzz

Return top

HEY YOU!!

Interested in how much my breakfast sucks or my bowl movement schedule? Then be sure to follow my twitter here.