Category Archives: web development

Few Thoughts on Web Video

On Air


It’s really full of video sharing websites out there, but in fact almost all of them use Flash player to display their video files. This is the reality now, but with the coming of HTML5, perhaps the things are changing a bit!

First of all if you start dealing with video sharing platforms the first thing to do maybe is to find a good Flash (.flv) player and to convert all your video content in FLV.

Few things to know with Flash video players:

  1. The user can play those videos only after installing the Flash Plugin to his browser;
  2. The video must be encoded either in FLV (or FLash Video) or in MPEG-4 with h.264 codec. Only than the Flash player can play it;

The HTML5, which can be described as variety of new “things” in the HTML comes with a native <video> tag. Something like the <img> tag where you can just point the source of the image in the src attribute. Continue reading Few Thoughts on Web Video

Google Analytics for Nokia … and Mobiles

Is There an Analytics Interface for Mobile?

The last few months I was searching about some kind of mobile interface of Google Analytics for my Nokia e71. However I did not find one?! Please correct me if I’m wrong.

In the same time I knew there is a GA API, which is free to use, so finally I wrote a tiny web app allowing the reading of basic information about your Google Analytics accounts.

Note that your username and password are NOT SAVED! However it’s up to you to try.

An important note is that the API has a limitation in requests so yet again, it’s possible to be unavailable in case of too many requests.

Visit with Your Mobile Browser

this link:

http://www.stoimen.com/ga/

Note that I made it primary about my Nokia, so any screenshots will be welcomed as well.

It is still beta so be careful. In fact any suggestions are welcome. Either for improving the security and error handling as well as new data exports.

There are lots of things to be done, but this is really basic.

Download Images with PHP

As it seems one possible solution while trying to download images with PHP is to write a “client” to do so. Will it be with cURL, Zend Framework or some other tool – it doesn’t matter.

However one of the most used approaches is simply with file_get_contents and file_put_contents. I’m not sure whether I wrote already about this or not, but this solution simply looks something like this.

 
file_put_contents('/path/to/file', 
                  file_get_contents('http://www.example.com/source.image');

In fact a client will give you more control over the process, to handle errors, etc. So maybe this is a better solution.

JavaScript Objects Coding Style Reviewed

JS Objects

Once I posted about JavaScript object coding style. Back than I made the analogy with PHP array coding style. In breve it’s useful to format the arrays in PHP simply like that:

$data = array(
	'key1' => 'value1',
	'key2' => 'value2',
	'key3' => 'value3',
	'key4' => 'value4',
	'key5' => 'value5',
);

Note that there is a trailing comma after the last key/value pair. This is not a syntax error and helps you add new elements to the array with no fear to forget the comma. This coding standard is quite well known in the PHP community, but in fact writing JavaScript objects can be “translated” to something very similar. The only problem is that the trailing comma in JavaScript will result to an error, especially in Internet Explorer, so it is important to remove it.

var obj = {
	key1 : 'value1',
	key2 : 'value2',
	key3 : 'value3',
	key4 : 'value4',
	key5 : 'value5'
};

The problem is that when you’ve to add one key/value pair, you’ve to add the comma after the last pair. This actually makes it useless.

Better Solution

There is another way, much better I think, that may help you more when adding new pairs to the object.

var obj = 
	{ key1 : 'value1'
	, key2 : 'value2'
	, key3 : 'value3'
	, key4 : 'value4'
	, key5 : 'value5'
	};

In this example you can simply copy/paste the last pair and change the key and value, or you can simply can continue writing the way the object is constructed.

Thus you don’t have the problem with the last comma and syntax errors.

Diving into Node.js – A Long Polling Example

Node.js vs. The World

What is typical for most of the web servers is that they listen for requests and respond as quickly as possible on every one of them. In fact the speed of the response is one of the main targets of optimization for developers. Fast servers are what everyone needs. From web developers to website visitors!

In the field of the that battle different web servers have different “weapons” to gain time. While this is useful in most of the cases, when it comes to a chat-like applications and Node.js approaches, the response is not always immediately returned. As I described in my posts until now about Node.js, a simple web server may wait for an event to be emitted, and than return the response. Continue reading Diving into Node.js – A Long Polling Example