Monday, March 10, 2008

Regular Expression Validator

This is a simple application of the Javascript Regular Expression matcher.
Digg it!


RegExp
String



Try some regular expressions:

Here you find the code. If you need an explanation, comment below!

<script language="javascript">
function regexMatch()
{
var isIE = (window.ActiveXObject)?true:false;
var attributeClass = (isIE)?"className":"class";

var t1 = document.getElementById("regexField");
var t2 = document.getElementById("string");
var strPattern = "^"+t1.value+"$";
var oTest = t2.value;

var oREGEXP = new RegExp(strPattern);
if (oREGEXP.test(oTest))
{
t2.setAttribute(attributeClass,"right");
}
else
{
t2.setAttribute(attributeClass,"wrong");
}
}
</script>

<style>
.right{background-color:#33FF33;}
.wrong{background-color:#FF5555;}
</style>


<form name="formRegEx" onSubmit="javascript:regexMatch(); return false;">
<input type="text" id="regexField"/>
<input type="text" id="string" />
<input type="button" onClick="javascript:regexMatch();" value="check"/>
</form>


Friday, March 7, 2008

Why SEO is not a job

Let's face it: SEO is a joke, not a job.

Anybody today can achieve excellent search engine ranking for his own blog or website in his sparetime, working on the strength of contents or services offered. A little bit of social bookmarking, alittle bit of fuss on major social or professional networks, a little bit of impression exchange, a little bit of back-links here and there: it doesn't seem to me as a big deal.

Wether you're using white or black hats or not I don't really care: the point is getting noticed on the web is extremely easy, just with a little reading and even less intelligence. I'd rather throw money out of the window than hire a SEO consultant, or I'd rather pay someone who doesn't call himself Search Engine Optimizer. Why? Because SEO is not a job, and will never be.

I see SEO people as prodigal sons of the new economy trying to make a living out of big and small companies ignorance.

Let's look at a Search Engine Optimizer profile: they're usually wannabe-techies who don't have a clue about what's behind what they're optimizing. We're talking about people who like the thrill of a tech-chat based on total vacuum. The most sophisticated SEO strategy I've ever heard about is "remember to provide a back link whenever you put a link on you website". What's this, if not a joke.

People who claim to be SEOs are most likely to fall in one of the categories below:
  1. Web Designers gone BAD
  2. Web Designers who overrate themselves
  3. Web Designers who were dancers
  4. Web Designers with a tiny backpack
  5. Web Designers who suck at web design
Before closing I'd like to point out this link: SEO is bullshit, it's quite hilarious (and there's no backlink).

And that's about it, at least for today.

Thursday, March 6, 2008

Silverlight vs. Flash and .NET integration


Two words about this new Technology by Microsoft.
I saw it for the first time near the end of 2007, but I gave it no importance: yeah, cool graphics but, as I'm not a graphic designer and having so little taste in graphics :), I had no interest in learning the fundamentals.
This is the same thing in Flash: in fact in the field I develop, Flash could help me only in the presentation step of my applications, because in the development step server techologies with javascript are enough.

Some weeks ago I came across the 1.1 alpha version of SilverLight, a complete version of the plugin, that can run on all main platforms (Win, MacOS, and a developing version for Linux) and on all main browsers (with only one plugin!!).

The main problem using FLASH with other technologies, such as .NET, is that you need a completely different environment to develop your applet (Flex) and have to use another language for your script (Action Script): moreover it's pretty difficult to generate both ASP.NET code and Flash code server-side, as they are in complete different domains. This can be done using third party solutions (such as SWFSource.NET, from this link) that allow you to generate SWF files server side, but at a too low level and of course without a complete intergration with the .NET technology.

At Microsoft Labs they wrote a scaled down version of the .NET platform to make Silverlight working: this allow you to write your client application in the same way you write your server pages, thus using the same data structures, objects and languages (C#, VB.NET, managed C++, ...), coming in help to the poor butcher programmer.

The framework, fully included in Visual Studio with few operations, comes with a completetly 2D rich model for drawing and responding to events (mouse click and this kind of stuff), some interesting streaming object for the mainly used video/audio standards (and Microsoft offers a 4Giga service of media storage and streaming server functionality in this link for free) fully customizable, a complete animation model and really interesting a full support for web services: this is what you will find in the 1.1 version, as the 1.0 is still something mostly related to graphical and animation manipolations.

No doubt that beeing an alpha release, I bet, there are still a lot of bugs and all the framework is missing some usefull objects not yet implemented, anyway this alpha is paving the way for a great new and useful technology.

Stay tuned for further readings, from your preferred butcher's shop!

Wednesday, March 5, 2008

[.NET] VB - C# Type Conversion Differences

There are some basic differences between VB.NET and C# when it comes to type conversion.

In both VB and C# widening conversions are implicit. Widening means that the destination type can represent all the possible values of the source type:


' VB sample
Dim myInteger As Integer = 1
Dim d As
myDouble = 1.007
myDouble = myInteger

'Helluva Implicit conversion allowed

// C# sample
int myInteger = 1;
double myDouble = 1.0001;
myDouble = myInteger;

//Implicit Conversion
//allowed


For narrowing conversion - let's say assigning a double to an int, when the destination type cannot represent all possible values of the source type - things change: you need to explicitly cast in C# while in VB the conversion keeps being implicit (don't come asking for an example plz... ).
If you want VB to behave as C# in case of narrowing conversions you have two options: either write at the very top of the code Option Strict On to enable the option at page level, or set the same Options Strict from the project properties to enable it at project level.

This difference reflects VB's wannabe-user-friendly attitude that often ends up messing-up things for people who's learning; but since every .NET developer is called once in a while to do some quick and dirty job using VB (there's a whole lot of frightening VB code out there) we certainly gotta deal with it.

That's all - Kick ass.

Monday, March 3, 2008

[Flash] Flow Player and video random access


Problem: handle random access to a FLV (Flash Video) file using FlowPlayer flash player.

Solution: this article is a sort of How To about how to make random access working using this particular flash palyer (that is open source and well working).

What is random access?
Essentially random access can be seen in most of YouTube videos: you don't have to buffer the entire video, because it's possible to select a specific instant to play that has not been buffered yet!

Simply, but of course it didn't mean to work...

I had to work with already coded FLV files, using ffmpeg (if I'm not wrong they came from a MPEG4 video and MP3 audio). Anyway I haven't never worked with FLV files, but I found them very very interesting; in fact it's possibile to write MetaData just inside the file.
Anyway FlowPlayer, from its site, grants the possibility of random access, so it was not a player's fault if my videos didn't work with random access.

After a full day of searching, finally a flash of knwoledge: there is a free tool, called FLVTool2 that puts inside the file constant metadata to mark up each instant (I suppose it is done each half second or more or less), so random access depends on those markups (and so it is not continous).
To make it possibile this is one of the possibile usage of the tool (inserts meta data in an output file and after the process visualizes metadata content of the file):
flvtool2 -UP inputVideo.flv outputVIdeo.flv

Of course output file is not needed.

This is not all: random access wasn't still working!

After some reading (one inside the FlowPlayer site I haven't seen at first sight) I found the problem: if you want random access you must use a streaming server.
Just this?? What's the problem, sure you can find billions of free streaming server...

Well , yes, there are a lot of them but all in beta or even alpha release, so in my opinion they were not worth for business applications.

Fortunately a google (I love you) result came to save me: Flash Streaming to FlowPlayer using only PHP!!
In few words, using a script linked in that page, you set up a PHP Streaming Server (it simply sends via HTTP the video from the point selected with FlowPlayer) that works very well: I don't know how it is scalable, but in my tests the streaming was fluid and in time.

So if you have my same problem and don't want to spend hundreds of euros to buy a professional streaming server, this is your solution!

And remember, you are never alone: google is always next to you with a confortable word!