Skip navigation

Lost password? | Help

Hello World

Practical programming... and stuff...

Posts tagged with "programming"

AJAX in ASP.NET

, ,

Today I did some research and looked up how you do AJAX in ASP.NET 2.0.

Microsoft has released an AJAX extension for ASP.NET 2.0 which makes doing AJAX enabled pages very very easy. Let's compare the way you'd do AJAX in PHP to the way you use in ASP.NET.

Read more...

Ruby on Rails vs. PHP

,

I saw three intresting videos on YouTube today:

Ruby on Rails vs. PHP
Ruby on Rails vs. PHP - Organization
Ruby on Rails vs. PHP - Changing database

They are Ruby on Rails commercials in a similar style as "PC vs. Mac" videos that you've probably seen.

Read more...

Collecting email addresses from websites

,

Recently I was asked to create a script to gather all email addresses from a certain website.

The script was to traverse all the pages on the site, find email addresses and save them to a file.


Now, you might think that this is a very complex task, as you would need to write a lot of code that would look for links on the pages to find more pages and so on, but with smart use of some common Linux utilities it's a very simple job.

Read more...

The simplest PHP template engine

,

If you have done more PHP programming you've probably used a template engine or two. I personally prefer Smarty as my template engine of choice for most projects.

If you don't know what a template engine is, I'll give a short explanation: Template engine is something that can be used to help separate HTML from PHP - You do all your "business logic" in a PHP file, for example you fetch some things from a database. A template on the other hand is meant to display that data. This is usually achieved by assigning the data to template variables in PHP and then displaying the template file.

But most template engines need setting up and their own code base etc., so for small projects they might add unnecessary complexity and things like that. However, PHP on its own can be a simple template engine! In this post I'll show you how.

Read more...

What to do with a web camera?

,

So, I got a free web camera. What should I do with it?

Well, how about grabbing the video stream from the camera with C# and doing something fun such as motion detecting for example?

I haven't played with it much yet, but I figured out two different ways to grab the stream and I also found a library for C# which could be used for detecting motion...


Read more...

Programming books

I've read many books about programming - C/C++, C#, PHP, DirectX...

The books which focus on a certain language or a technology almost always have the same things to say. For example, I looked at multiple books about DirectX and they all had the same stuff but in a slightly different form.


So I don't really like reading books that concentrate on specific languages because of that, but the matter of fact is that I'm not that great programmer yet. For example, I don't have much experience on bigger projects.


There are two books many people recommend: Code Complete and The Pragmatic Programmer.
I just recently got my hands on these two. They both focus on the more theoretic side of programming and software engineering, and they don't teach many of these things anywhere. I've read some chapters from both, and I highly recommend them!

Code Complete, Second Edition
The Pragmatic Programmer: From Journeyman to Master

An easy way to remove nested elements in HTML

, ,

I've sometimes faced the problem: How to remove nested elements from HTML source.

You have two options:
- If it's well formed HTML, you can use XML parsing functions.
- If not, you're left with traditional string-parsing approaches.


When you think about the second option, you probably think of something that keeps track of how many opening tags we have gone past and how many endings, ie. the depth.

That is, however, very complicated compared to the approach I'm going to show you.
Today it struck me: why not do it in reverse?

Read more...

MVC pattern pros and cons

,

In this post I'll talk about some of the pros and cons of the MVC (model-view-controller) pattern I've come across, concentrating in the Zend Framework implementation of it.

For those who don't know what the MVC pattern is... It basically is a way of structuring PHP code, data storage and HTML code in separate files. "Model" is the data/data access code, "View" is the HTML code or things such as Smarty templates and "Controller" parses the user requests, fetching information from models, assigning that to views and displaying views etc. For a thorough look, I suggest reading the Wikipedia article on MVC.

Read more...

The Zend Framework

,

The Zend Framework is a framework for building PHP powered web sites, made by Zend - the corporation behind PHP.

It's currently in beta 0.92, but it's very stable and useful nevertheless. Also, it has emphasis on using the MVC pattern when developing sites.

Read more...

Comparison of programming language syntaxes

,

There are many intresting syntaxes in programming languages. I don't think there's one "good" syntax, as most developers like the syntax of the language they use the most, be it Visual Basic or C++.

Here are some more intresting syntaxes from languages I've used and from some others too.

Read more...