Do androids dream of electric sheep?

Stop hitting your head against the wall: The ultimate guide to display/hide input value on focus

Today i was just astonished while looking in google for a simple and easy way to hide text value on focus of a form input field. All the solutions i was able to find were involving Javascript and all of them were really tricky, especially considering the goal of the script.

I was not really convinced about these kind of solutions, i love simple and clean code. 
Here you can find a really easy way to achieve that without javascript, without css tricks and keeping your code integrity and beauty!

It's really simple, check out the code:

<input type="text" name="search" size="30" value="Search here..." onfocus="value=''"

This is just an example on an input field called search with default value "Search here...", as soon as the user will focus on it the default text will disappear and the user will be able to type in whatever he prefers. 

Smooth and Easy, isn't it?

Hope you will enjoy this solution, leave a comment if you feel like!

Loading mentions Retweet

Filed under  //  Webdesign  
Comments (0)
Posted 3 months ago

Validating emails with PHP: the correct way

It was not easy to find a guide showing how to validate emails properly going just a big further than a simple regex comparison.

Here i found what i was looking for, a simple function able not only to check if the email syntax is correct but also if the DNS is really existing.
The code:

function validate_email($email)
{
   // Create the syntactical validation regular expression
   $regexp = "^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$";

   // Presume that the email is invalid
   $valid = 0;

   // Validate the syntax
   if (eregi($regexp, $email))
   {
      list($username,$domaintld) = split("@",$email);
      // Validate the domain
      if (getmxrr($domaintld,$mxrecords))
         $valid = 1;
   } else {
      $valid = 0;
   }
   return $valid;
}

Just few comments: 
First step we just compare with the regular expression the field we have in input, than we split the username with the host and using getmxrr we send a request checking if the DNS is on and working. If these 2 steps work properly we than just return true.
Simple, smooth, painless and effective.

Loading mentions Retweet

Filed under  //  Webdesign  
Comments (0)
Posted 3 months ago

iPad, Hp Slate, JooJoo. How manifacturer just missed a great opportunity.

I'm not really sure about why everybody is going so crazy about iPad, HP slate, JooJoo or any similar device announced in the last 6 months. I mean, they are not going to change our lives nor the way we work. In despite of any marketing campaign this kind of devices with their capacitive-useless screens and no e-ink capabilities are not going to change anything, actually they are just useless devices that will let you do usual activities with your dirty fingers instead of a normal track-pad.

Work: Come on be serious, it won't improve your workflow nor the quality of your output.

All these devices are just missing all the key-features that can really contribute in improving the quality of the work. What is the point of a touchscreen if you can't use it to take notes, underline, wrote on documents & pdfs? I mean, this is just ridiculous.

I don't care of a new version of iWork or iCal optimized for the iPad. I'm a student, do i really need to pay 500$ to get more distraction such as facebook or a tap-tap game? NO! 

At the moment all the "tablet" devices are just super-agendas with no point. 

What do i need?

super-easy: I need to be able to take notes, i need to underline and work on documents & pdfs, i need to write things with a pen and i need a hell long life-battery. I need a full-support for office documents and ebooks. This is the kind of device that would change my life, my work and would let me really improve the way i work.

 

Just don't mix right features with bullshits.

Movies, Music and super-agenda features are welcome but they can't be the only things considered during the design and engineering process of a new device, especially if than you claim it to be "revolutionary". They are just bullshits.

I'm really scared by the fact that i the last 3-5 years manifacturers moved only in one direction: Multimedia and games. I'm enough.

Loading mentions Retweet

Filed under  //  Thoughts  
Comments (0)
Posted 4 months ago

Wordpress How-to: Add an Author Box into your posts

In the last days i've been playing with wordpress. I was working on my new project lascienza.net and i decided to add a small square in the end of each article in which were supposed to be shown author's details, including twitter and facebook.

The process wasn't too painful and i've chosen to share it with you, i'm pretty sure it will be somehow useful to others in future.

Let's start.

The final result
well, this is just to show you what we are going to get as result of this tutorial.

In the end of the article you will see something like this:


Ok, so we will have:
  • Title
  • Name + Personal Author link
  • Author Photo
  • Author Description
  • Author contacts

Note that this design was made on my website, you can fully remake it, assembling, styling the box or adding more informations as you wish. Obviously you will require a basic knowledge of XHTML and CSS to do that. This tutorial is just to give you an idea, to introduce some tricks in order to get the job done, once you have understood each step you can simply do whatever you want, no limits but creativity!

Styling the Box
Ok, we are going to work on the file called single.php, you can find it in wp-content/themes/yourtheme/ folder.
This file, according to wordpress codex:

The single post template. Used when a single post is queried. For this and all other query templates, index.php is used if the query template is not present.

Now, once opened the file you have to find where you prefer to place your box. If you wish to place it in the end of the article (as i did) you just have to find in the code where comments start, right before those lines is where you will have to place your divs. As i said before, nothing bad if you will place it somewhere else in the page.

here some XHTML code:
<div id="author-square"><h3>Title</h3> // Box + Title
<div id="main-data"></div>  //Author's Name, Home Page and photo
<div id="description"></div>  //Description
<div id="auth-contact-data"></div>  //Other data
<div class="clear-float"></div>    //This div is to clear floats effects
</div>

As you can see there's a main square in which are placed 3 columns. First column for Name, Home page and Photo, Second for Description and third for additional data.

And here CSS:

#author-square{
border: 1px dotted #DDDDDD; 
padding: 10px 10px 10px 20px;
height: 200px;
background-color: #F0F0F0;
width: 618px;
}

#author-square img{
margin-top: 10px;
}

#main-data{
width: 180px;
float: left;
}

#description{
width: 270px;
float: left;
margin-top: 25px;
margin-right: 15px;
}

#auth-contact-data{
width: 150px;
float: left;
margin-top: 25px;
}

.clear-float{
clear: both;
}

I'm not going to comment line per line, i assume you can read CSS and you know what that means. Just worth to notice that:
  • My square is large 618px
  • These 3 squares have float:left, they are aligned on the left.
As you could see nothing special in the code. We have just styled a little bit our box, the interesting part is starting now.

Adding Author Name and Home Page Link
This is easy. We are going to use wordpress functions called: the_author() and get_the_author_meta()
  • the_author() function will just print author name as defined in the profile wordpress admin area.
  • get_the_author_meta() is a very useful function that let you work with data defined in the author profile page. Basically you can use it to assign any data defined in the author profile to your own variables.
Add the following code to your main-data layer:

<?php echo "<b>"; 
the_author(); 
echo "</b> "; 
$url=get_the_author_meta('user_url'); 
echo "<b>Home Page</b>"; ?>   // Posterous is displaying wrong this code, check out the link and add <a href> tag

First three lines to display the_author(), that's name/surname/nickname of the author as defined in the profile.
With $url=get_the_author_meta('user_url') we get (as the name suggest) the user url defined in the profile page, with last line we display the XHTML code.

Adding Author Photo to the box

There are several plugins for this, as we are all a bit geeky we all love making things by ourselves, that's why we are going to code instead of using any add-on.

Here you will find my reference tutorial, there you will find nothing more than what i'm going to write here, just worth to mention.

The General idea is pretty simple. We are going to name each author pic with the author ID and we will use wordpress functions to display it. Follow these steps.

First Step: Create a folder under /images/ called authors in your wordpress theme folder. The final path should be something like /wp-content/themes/yourtheme/images/authors, obviously you can choose any other path on your preference.

Second Step: Find the Author ID. How? well, go to admin panel in wordpress. Click on Users and than click on the name of the author you want to upload the photo. The profile page of the user will now open and in the url bar you will see something similar to this:


That small voice in the url called user_id is exactly the number you will need.

Third Step: Rename the Author pic as the author ID. In our example you should name it as 2.jpg
Fourth Step: Upload the picture in the /authors/ folder you've created previously.

Now the coding part.

Step Five: add following code to the XHTML we have defined before.

<br /><img src="<?php bloginfo('template_directory') ?>/images/authors/<?php the_author_ID()?>.jpg" alt="<?php the_author(); ?>" title="<?php the_author(); ?>" />

Let's write some comments. We are adding an image to the box,

src="<?php bloginfo('template_directory') ?>/images/authors/<?php the_author_ID()?>.jpg"
With this line we are saying to the browser to connect to the authors folder placed in our template directory and look for an image called exactly as our author ID. 

alt="<?php the_author(); ?>" title="<?php the_author(); ?>" 
here we define Alt and Title Attributes using the_author() function.

Now our code should looks like this:

<div id="author-square"><h3>Note sull'autore</h3> 
<div id="main-data"><?php echo "<b>";the_author(); echo "</b> "; 
$url=get_the_author_meta('user_url');
echo "<b>Home Page</b>";?> 
<br /><img src="<?php bloginfo('template_directory') ?>/images/authors/<?php the_author_ID()?>.jpg" alt="<?php the_author(); ?>" title="<?php the_author(); ?>" /></div> 
<div id="description"></div><div id="auth-contact-data"></div><div class="clear-float"></div></div>

Now it's time to add decription and contact links.

Description

Adding the description is easy, northing different from what we have done till now.

We are still using the the_author_meta(); function, this time with an attribute called 'user_description', this is going to display the description for the profile.

this is how code will look like:
<div id="description"><?php the_author_meta('user_description'); ?></div>

Adding Custom Information into an author profile 
This is maybe the most interesting point in the whole tutorial, we are going to add some information in the profile of each author. Than, if those fields are defined we will use them into the box we have been working on till now.

I found this trick on wpbeginner.com, here.

You have to open functions.php file in the folder of your theme.
add following lines:

<?php
function my_new_contactmethods( $contactmethods ) {
// Add Twitter
$contactmethods['twitter'] = 'Twitter';

//add Facebook
$contactmethods['facebook'] = 'Facebook';

return $contactmethods;
}
add_filter('user_contactmethods','my_new_contactmethods',10,1);
?>

In this code example we are adding 2 fields called twitter and facebook, same method can be used to add any information you like.
Now the profile admin panel will look like this:

as you can see our custom fields are now visible.

Ok, how can we manage these data? pretty simple, exactly in the same way we have been working till now.

Open you single.php file again and add following code in the auth-contact-data div:

<?php
//disaplaying Twitter & Facebook, check if they are defined and display 
$twitter=get_the_author_meta('twitter');
if($twitter!=""){
echo "<b>Twitter</b>: @$twitter<br />";
}
   $facebook=get_the_author_meta('facebook');
if($facebook!=""){
echo "<br /><b>Facebook</b>:<br /> <a href="http://facebook.com/$facebook" >";
the_author();
echo "</a>";
}
 ?>

Calling the get_the_author_meta('twitter') and get_the_author_meta('facebook') we will assign to our variables $twitter and $facebook fields values.
Using two simple if cicles we are checking these variables were defined in the profile, if so we display them.

The Final Result

This is the final complete code for the single.php page:

<div id="author-square"><h3>Note sull'autore</h3><div id="main-data"><?php echo "<b>";the_author(); echo "</b> "; 
$url=get_the_author_meta('user_url');
echo "<b>Home Page</b>"; //the_author_meta('display_name'); the_author_meta('user_url');  ?><br /><img src="<?php bloginfo('template_directory') ?>/images/authors/<?php the_author_ID()?>.jpg" alt="<?php the_author(); ?>" title="<?php the_author(); ?>" /></div><div id="description"><?php the_author_meta('user_description'); ?></div><div id="auth-contact-data">
<?php
//disaplaying Twitter & Facebook, check if they are defined and display 
$twitter=get_the_author_meta('twitter');
if($twitter!=""){
echo "<b>Twitter</b>: @$twitter<br />";
}
   $facebook=get_the_author_meta('facebook');
if($facebook!=""){
echo "<br /><b>Facebook</b>:<br /> <a href="http://facebook.com/$facebook" >";
the_author();
echo "</a>";
}
 ?>
</div><div class="clear-float"></div></div>

I really hope you enjoyed the article, any question or correction please use comments!

Consider that there are many ways to achieve same result shown in this article, probably some are even better, and i'm sure my code can be improved in many ways. This is just a path, any improvement is really welcome!

Loading mentions Retweet

Filed under  //  Blogging   Webdesign  
Comments (2)
Posted 6 months ago

Entrepreneur: Do you need an Elevator Pitch? Yes, you do.

2254123309_62f9bef920.jpg
Original Image from Laurenmanning on flickr.

What is an elevator pitch?

According to wikipedia:

An elevator pitch is an overview of an idea for a product, service, or project. The name reflects the fact that an elevator pitch should be possible to deliver in the time span of an elevator ride, meaning in a maximum of 30 seconds and in 130 words or fewer.

There's nothing more to say about, It's a short text in which you describe your idea/project.

Do you need it?

If you're an entrepreneur, a freelancer, a marketeer, a project manager, a web geeky guy or a sales-man the answer is one: YES!

The Elevator Pitch is one of the most effective ways to show why your idea or product is great, what you have achieved and what you want from your audience. One of the main "weapons" you have on your side to convince them you are worth their trust.
This is why you definitely need to work that out.

Usually simple things hide behind them a huge work. Not that simple to write down in few words complex concepts, right? 
you have to be careful especially if you're searching for new investors. So, here you will find few essential advices, follow them and be sure you'll be able to write a great elevator pitch.

Fundamentals: writing down your elevator pitch

It's short: Yeah, i know it's difficult but you should care a lot about length. If you're writing it now and you see that it's over 2 paragraphs probably you already went too far. Keep in mind, within 130 words, 30 secs.

It's strictly connected to your brand: Everybody know how important a logo is, right? Exactly as a logo, your elevator pitch is part of your brand and sometimes it's even more important than the visual identity itself. It's connected to your identity and should be used as often as possible. People will recognize you because they will recognize your elevator pitch.

Not a closed Box: If you're going to use it in a discussion or a public speech you should be ready to defend it, discuss and challenge. You should be conscious about what you're talking about. I'd add that it's not an empty box as well. Avoid empty wide-used expressions, be effective. Each term should have a meaning.

Clear and Easily Understandable: Key feature. If you've to learn anything from this post let this be the thing. It must be easy to understand, clear. Avoid ambiguities, errors or difficult specific words.

Few Questions to find your answers

The truth is that there's no perfect recipe for this. Best thing you can do to write down an effective text is just to find right answers for following questions:

- Who am i talking with?
- Who/what is my target?
- Do i have a short-term strategy?
- Have i achieved any result yet?
- Strength and Weaknesses of my project?

References:

This post was written on the italian post from Francesco Gavello. I must admit this guy keeps writing amazing articles and he knows his way in the world of blogging and new media. I've learnt so many things form him, a thanks wouldn't be enough. 

I hope that this post was anyhow useful.

Loading mentions Retweet

Comments (0)
Posted 6 months ago

Steve Jobs Stanford speech, Inspirational words.

I found this video extraordinary both under professional and personal point of view.

Loading mentions Retweet

Filed under  //  Corporate   Inspiration  
Comments (0)
Posted 7 months ago

Merry Christmas!

Ok, time has come. 2009 is ending, new year is coming. I wish to you all guys a good time, merry christmas!

Loading mentions Retweet

Comments (0)
Posted 7 months ago

15 Corporate Site Templates and Designs you should consider for your business

Whether you are a freelancer looking for some inspiration or an entrepreneur looking for a ready-to-use template for your business this is the post for you.
Here you will find a nice collection of 15 templates for your corporate site. These designs are clean, effective, optimized, creative and beautiful and i definitely recommend them. They will boost your brand and image keeping costs little as you can buy them for less than 15$.


Trefoil Business





?ui=2&view=att&th=125b0ea6a24d596f&attid=0.1&disp=attd&realattid=ii_125b0ea6a24d596f&zw








You can find more on Themeforest, feel free to suggest more templates

Loading mentions Retweet

Filed under  //  Corporate   Webdesign  
Comments (0)
Posted 7 months ago

Why you shouldn't connect your facebook account with twitter.

Since i started using twitter i integrated it with my facebook account. Right now, after several months, i understand that was a wrong choice (at least in my case)





What's wrong with that? 


Well, to be honest i'm still convinced integration between facebook and twitter is a good thing. Updating your status on facebook with twitter messages can be a great opportunity, still you should evaluate carefully the situation and understand whether that can improve or not your social image and brand.



My Situation

I started using facebook almost 2 years ago and recently i've used it to keep in touch with all my friends, with my family and also with collegues or people met randomly at parties, dinners and so on.

I've about 400 friends right now in my list and 80% of them have nothing to do with Web 2.0 or work.

I'm not anyhow using Twitter for "personal" purposes, unlike Facebook. I love this social network that has shown its power as a real-time news reader used by almost every blogger or social media guy to spread valuable contents, texts and resources. That's the main usage i'm doing as well: promoting articles, RTs valuable content and so on. Nothing to do with my private life.



The Issue

Well, I've chosen to disconnect twitter from facebook only because of this: The Audience. Few of my contacts in facebook were interested in my working links, most of them took hundreds of messages 'Ive sent in the last year just as spam (or sort of).

The lesson is: Web 2.0 services are improving more and more, they are moving in the direction of integrating content and driving larger amount of information, but still common sense is the king


Before linking different services and accounts you should ask yourself: Who is going to read my messages? How the audience will approach them?



Twitter and Facebook, Different audiences mean different strategies of promotion.

Twitter and Facebook has developed different "styles" in order to deliver effective information, you can't mix them up. RT is a direct way to spread content on Twitter, just imagine it on Facebook. Its effectiveness will drop, people simply won't understand the update of your status and even in the case they do, probably they will be annoyed by the "twitter style" short message as Facebook standard updates are made of: longer text and images.


Tweet seen on facebook: awful




Standards facebook update




Obviously, if you're using both twitter and facebook for personal purposes as you're not anyhow working in the 2.0 sphere the connection between these social networks can still make sense.

Loading mentions Retweet

Filed under  //  Blogging   Social Networks  
Comments (0)
Posted 7 months ago

Pages Architecture and Contents Hierarchy: What Bloggers and Online Editors should know

It doesn't matter if you're a blogger, a web editor or an Entrepeneur. What you should keep in mind is: Content Hierarchy and Organization matters. 

You don't need to be a Web Marketeer or a User Interface designer to understand why it's fundamental to organize carefully each page of your website in order to make it Accessible and Clean. It's not so obvious how to achieve that and it usually takes lot of time (and experience) before you are able to create a SEO-friendly, clean pages architecture. 

This is exactly what we are going to discuss in this article: Basic and Advanced principles to create effective pages that your users and Search Engines will like.

I'M NOT TALKING ABOUT DESIGN
I want to underline that i'm not going to talk about how to Design a webpage; instead, i'm going to explain what principles should rule the programming and design process. Good stuff for Web designers and Web developers.

BASIC RULES
My experience has shown me LOT of people wasting great ideas due to lack of common sense. You should never forget that a website is a one-goal bridge: let information be delivered to readers. Users are lazy, first they scan the page and then, if during the "scanning" process they are able to grab information they were looking for, they start reading.

BAD TITLE, GOOD TITLE
Users start scanning the page by titles, you should organize your content in a way that allows readers understand immediately what next lines are about
Receipt for an effective title is: Make it BIG and don't make it tight.
Let's see come examples of good and bad titles:

This is a Good Title

e867f41379494f49007e52736e188808.png

This is a Bad Title
717a6881013ab165b2f286648f43a5f6.png

Remember that through titles you can organize your content hierarchically, i will get deeper on this later. For now you should keep in mind that Title size should be proportional to its importance. Main title will be the biggest in the page, sub-paragraphs titles will be a bit smaller and nested paragraphs will decrease size proportionally to their position in the tree.

Let's check this out to clear any doubt:

LINKS
Links are part of the core of your blog/website, you can use them to drive your user experience and to literally connect different pages on the same subject.  We can define two kinds of Links: Static Menu Links and Inline Links. Static links are used in the menu, the footer or in the sidebar and as you can imagine they have a primary role in the page. 

Inline Links
Wikipedia launched first a massive usage of inline links. Basically i'm talking about those links within the content mainly used to define words or to call external sources.
Well, Inline links have a strategic role in the page, you can use them to define words the reader may not know or to connect external pages to your article. Keep it in mind: users are lazy that's why they will not look for links, you should take care to make them visible in the text. 

IMAGES
Images are optional, use them in your pages according to page lenght. One image from time to time makes the text brighter for the reader. Personally I agree with this point of view but still you can easily find an example of successful sites that do not use images by default in their content pages.

Easy, right? Simple rules to organize your content, missing any of these tips would have only one result: Chaos. Before php functions, jquery effects or photoshop design you must define what the page will be with its typo, titles, texts and links.

CONTENT HIERARCHY: Titles, how to implement them
SEO matters
I already said why titles are important from the user's experience point of view, but that's not all. Titles are useful also for Search Engines. Why? because they help crawlers and engines to recognize what your page is about and rank it into SERPS.
Seomoz has recently decreased importance for titles in the ranking process, although I think this is a primary feature you should work on. Search Engines, google first of all, work in the direction of presenting to users quality pages and the content in higher ranks. As Titles and a correct Hierarchy of contents is so important for users I bet it has some kind of meaning for ranking in search engines as well.

Importance of Headers Tag. H1, H2, H3 are your friends.
Both if you're using an HTML editor (such as wordpress) or if you're editing directly the page you should remember the importance of h1,h2 and h3 header tags. Use them to represent the hierarchy of your document. Main Title will require h1 tag, subtitles h2 and so on.
In particular search engines use those tags to identify titles in the page, that's why using just a CSS style on a usual text is something you should avoid.

Loading mentions Retweet

Filed under  //  Blogging   Webdesign  
Comments (0)
Posted 7 months ago