Professional, affordable and secure web design specializing in Drupal-based sites

Web Development

Copycat Startups: When is it OK to Steal Ideas?

SitePoint - 6 hours 2 min ago

There are differing opinions in our field when it comes to the fine line between using a website or idea as inspiration and blatant copyright infringement.

Some feel that getting inspired by other designs and utilizing elements of them in your own is completely natural, even necessary. Others argue that copying anything, even a fairly generic layout structure, is copyright infringement.

No matter which side you’re on, you can’t help but notice copycats in almost every successful new web service or social network that launches. In many cases, the copycats out-innovate and eventually become market leaders. Facebook wasn’t the first social networking website … there was Friendster (which actually patented social networking), MySpace, and then Facebook.

More recently, Pinterest has come under the spotlight as an innovative way to bookmark, categorize and share ideas, photos, and links. As Pinterest grew in popularity, copycats like Pinspire and Clipix have popped up, with almost exactly the same layout and functionality. Pinspire and OpenPin.org are almost pixel-for-pixel clones of Pinterest — at least Clipix tried to come up with original graphics.

Where is the Line?

Where is the line, and have Pinspire, OpenPin or Clipix crossed it? More importantly, if they have, why are they still up and running? I raise this question because I’m interested in where copying stops and innovation begins. GA_googleFillSlot("InArticle_728x90_1");

You may not think of Apple as a copycat, but they were never the first to market with any of the devices that they now dominate in market share. Smartphones and tables have been around for over a decade, and even the mouse was invented by Xerox PARC. Apple saw the “mouse” on a visit to Xerox and incorporated the idea into the Macintosh, believing it would revolutionize computing (which it did). They even borrowed heavily from the GUI (graphical user interface) concepts developed at Xerox, which Microsoft then famously copied to create Windows.

Copy or Improve?

Twitter has its share of competition as well, but most Twitter competitors that pop up aren’t carbon copies. They take the concept of a microblogging service and improve on, or alter, the idea somewhat. My favorite Twitter competitior was Pounce, which was very similar but allowed you to select different types of content to publish, such as a photo, link, video, or text update. Although Pounce has shut down, you can see its idea in the status update functionality of most social networking sites today, including Facebook and LinkedIn.

Improve on Others’ Ideas

It’s too early to tell whether Pinterest (or its clones) will be successful. But competiton drives innovation, and I expect we’ll see both Pinterest and competitors in the space improving on the original “pin board” concept with new features and interface improvements.

Instead of just copying a website, service offering, or marketing message, think about how you can improve on the original idea. How can you make it your own? What’s missing … or what can be taken away?

GA_googleFillSlot("Edit_300x100_C"); GA_googleFillSlot("Edit_300x100_D");
Categories: Web Development

Google’s Doodle and Why it Hertz my Brain!

SitePoint - 6 hours 43 min ago

How do we love Google Doodles? Let us count the ways.

They’re brilliant. In fact, I even enjoy getting up every day knowing that somewhere in Mountain View there are probably people shouting ‘Woohoo! It’s Robert Heinlein’s Dad’s birthday next week! I wanna make an animated rocket on Google today!

We all have our favorites. I loved the Pacman tribute.  The playable Les Paul guitar. The amazing deep-sea Jules Verne tribute. It’s true, the bar has been set very high.

Google's tribute to Heinrich Hertz - February 22nd 2012

But when Dan Laidler pointed out today’s celebration of the great German physicist Heinrich Hertz, we all did a little doubletake. GA_googleFillSlot("InArticle_728x90_1");

Hertz’s work was centered around waves — from light to radio — so Google paid tribute to his 155th birthday by evolving their famous logo into a gently moving wave that echos the Google letter shapes.

That was a nice enough idea, but it was how they made it wiggle that had us scratching our collective heads.

For here we had (arguably) the most technically-adept web company on the planet choosing to animate the wave as a big-ass animated GIF.

More precisely, a 197kb, 49 frame, kinda jerky animated GIF. Brows were furrowed.

The obvious question is “Why?” Sure, we all know support for animated GIFs is ubiquitous, and often the simple solution is the best solution. However, for a company that so vigorously champions the power of HTML5 in particular, and the web in general, it seems like a strange decision.

So rather than just bleat about it — though we enjoy that too — we had a quick play around with alternatives. Here are the results so far.

The CSS3 Only Method

Easily the quickest method to get something working is CSS3. We start out with the simplest imaginable HTML.

Note: For the sake of clarity, I’m only going to show the W3C standard below, but the example contains all the prefixed CSS required.

<div id="wavelength"></div>

The basic CSS setup isn’t much more complicated. We give the DIV width and height, and embed our wave graphic into the background.

#wavelength{ width:380px; height:223px; margin: 100px auto; border:1px #ddd dashed; background: url(http://sitepointstatic.com/examples/css3/animation/hertz.png); position:relative; }

The keyframe animation code simply slides the background image position from the default (0px 0px) to 380px to the left.

@keyframes hertz { 0% {background-position:0px 0px;} 100% {background-position:-380px 0px;} }​

Then we just attach the animation to the #wavelength DIV.

animation: hertz 4s infinite linear; /* w3c standard */

As a final touch I’m using the :before and :after pseudo elements of the #wavelength DIV to provide the fluffy white edges that you see on the left and right sides of the original GIF.

Here’s the working demo.

Run side-by-side with the GIF, the CSS3 version is certainly much visually smoother and file sizes are slashed drastically. Our wave graphic is now under 3kb, meaning — and even accounting for multiple prefixes — we only need a little over 1400 characters of CSS. That’s a combined weight of just over 4kb or less than 3% of the original.

Of course, we can’t pretend that CSS3 doesn’t have its drawbacks.

Google’s audience is as broad as they come, so a method that doesn’t work on older Internet Explorers (pre IE10) probably isn’t an option. Nevertheless, if you ran the GIF as a fallback using something like Modernizr to taget older browsers, I think you’d have a very viable solution.

The JQuery Method

JQuery is the no-brainer way to target both old and new browsers with a single approach. There’s more than one way to do it, but here’s the simplest method we could think of (cheers Harley).

We’re starting with pretty much the same basic HTML and CSS as the previous example — minus the CSS animation code.

Next we create a simple function (waveloop();) that resets the our background X position to 0px.

function waveloop(){ $('#wavelength').css({'background-position-x': 0}); }); }

Then we need to animate the background position 380px to the left of screen (hence the minus) like this:

function waveloop(){ $('#wavelength').css({'background-position-x': 5}); $('#wavelength').animate({'background-position-x': '-380px'},3700,'linear'; }); }

We found 3700 milliseconds is a fairly close match to the GIF timing, though it varies slightly from computer to computer.

At this point our wave animates nicely to the left, but stops after the first pass. We want it to loop without us having to retrigger it each time. The easiest method is to get the function to trigger itself again when it finishes. This is a callback and we can call like this:

function waveloop(){ $('#wavelength').css({'background-position-x': 5}); $('#wavelength').animate({'background-position-x': '-380px'},3700,'linear', function(){ waveloop(); }); }

Finally we just need to call our function with jQuery’s document ready function.

$(document).ready(function() { waveloop(); });

And that’s it.

Here’s a working demo showing the Google GIF at the top as a comparison. About half a dozen lines of code to a smoother, cross-browser, lower-bandwidth result. Granted, we need to include the minified jQuery library in the download, but even throwing in that 30kb file doesn’t get us anywhere near 40k, or a fifth of the GIF file size.

And jQuery is really overkill here — I just had other work to finish.

So, what do you think?

  • Did Facebook poach the Google Doodlers?
  • Perhaps you’ve got an even better way to do it?
  • Am I under-estimating the power and beauty of the animated GIF?

Or am I just being a little tough on the poor guys?

GA_googleFillSlot("Edit_300x100_C"); GA_googleFillSlot("Edit_300x100_D");
Categories: Web Development

PDO vs. MySQLi: Which Should You Use?

Nettuts - Tue, 02/21/2012 - 12:41
When accessing a database in PHP, we have two choices: MySQLi and PDO. So what should you know before choosing one? The differences, database support, stability, and performance concerns will be outlined in this article. Summary PDO MySQLi Database support 12 different drivers MySQL only API OOP OOP + procedural Connection Easy Easy Named parameters [...]
Categories: Web Development

7 Solutions to the CSS3 Vendor Prefix Crisis

SitePoint - Tue, 02/21/2012 - 12:03

As we reported last week Mozilla, Microsoft and Opera have become frustrated with sites which only target -webkit CSS3 properties. It makes their browser look bad even when it implements identical or better technology. To solve the issue, they propose adding -webkit prefix support to the non-webkit browsers.

While this is largely a marketing decision, it’s a real problem. The solution appalls many web developers but we deserve our share of the blame. In this article we’ll discuss the options, pros and cons.

1. Nothing Changes

Assume nothing is done to solve the browser prefix problem.

PROS

  • Browsers continue to implement their own prefixes which you are free to use or ignore.
  • There’s nothing new to learn or test.
  • It feels right and the decision will please the majority of web developers.

CONS

  • We retain the four prefixed and one standard property. Stylesheets are larger than necessary and difficult to test.
  • Lazier or less experienced developers will continue to target webkit browsers only.
  • Chrome and Safari’s market share could rise to a point which makes other browsers redundant. We return to the days of single browser engine and innovation stagnates. The dark days of IE6-like dominance return.
  • Microsoft, Mozilla and Opera consider this to be a real problem: doing nothing is not an option.
2. Non-Webkit Browsers Support the Webkit Prefix

Assume IE, Firefox and Opera support webkit-prefixed properties. GA_googleFillSlot("InArticle_728x90_1");

Microsoft had already implemented -webkit-text-size-adjust in the mobile version of IE. While it’s a non-standard property for Safari (there’s no text-size-adjust), they listened to community feedback and pulled support. That’s unlikely to happen again if Mozilla or Opera start adding webkit properties to their engines.

PROS

  • It’s a quick and dirty solution which allows non-webkit browsers to render as well as Chrome or Safari.
  • There’s no need for developers to update their websites.
  • -webkit will become the dominant prefix; using -moz, -ms or -o will become unnecessary and CSS file sizes will reduce
  • It prevents webkit, Google and Apple becoming too powerful. If another vendor disagrees with an implementation, they can simply break it or provide an alternative. Developers may not be able to use the property in any browser.

CONS

  • It feels wrong: one browser should not need to masquerade as another.
  • It rewards sloppy development practices.
  • Differing browser implementations will make some properties unusable.
  • If developers retain webkit properties which fail in other browsers, more users will switch to Chrome and Safari. Other vendors will become increasingly irrelevant.
3. All Browsers Use a -beta Prefix

Rather than separate prefixes, assume every browser implemented the same -beta prefix.

PROS

  • Just one prefix to learn and use.
  • Stylesheet file sizes are reduced.
  • The property is obviously experimental; developers will be more cautious about using it.

CONS

  • As a solution, it’s little different to every vendor adopting the -webkit prefix.
  • Differing browser implementations may make some properties unusable.
  • Vendors are unlikely to remove their own prefixes; the situation won’t change.
4. Experimental CSS Properties Only Appear in Beta Browsers

Assume prefixed properties are abolished in all browsers. Newer experimental properties would only be present in nightly and beta releases — and they would not require a prefix.

PROS

  • It becomes impossible for developers to use prefixed code or target specific browsers in production websites.
  • Webkit-only sites are punished accordingly.
  • We all work to final standards — not future ones.

CONS

  • Far fewer developers will use and test experimental properties. It could lead to buggier implementations.
  • New properties may take several years to become standardized. Are we prepared to wait?
  • It’ll never happen. If a single vendor chooses to keep prefixes in their main release, they all will.
5. Vendor Prefixes are Dropped Following Final Implementation

Once a property is stable and implemented without a prefix, all previous prefixed versions are removed from the browser.

PROS

  • It’s a logical solution.
  • It removes unnecessary code. Library bloat is reduced and browsers become leaner and faster.
  • It rewards good development practices and punishes the bad.

CONS

  • It offers no immediate resolution for sites which only target webkit browsers.
  • It will break sites overnight — vendors will be reluctant to implement the policy.
  • Properties can take years to reach standardization and browser implementation schedules differ. Prefixes will break at different times so ongoing site testing and maintenance is required.
6. The W3C Agreement Process Becomes Faster

Assume the W3C adopt quicker methods of standardization and publish schedules detailing when a property is expected to reach maturity.

PROS

  • The existing process is too slow.
  • Developers will know when the final property can be used.
  • There’s less chance for vendor prefixes to gain widespread adoption.

CONS

  • The process is not intentionally slow. There will always be practical and logistical problems to overcome.
  • Vendors work at different speeds and it’s impossible to accurately estimate delivery times.
  • A faster approval process could lead to poorer implementations which negates the point of having a standardization process.
7. Better Evangelism and More Education in the Developer Community

We would not be in this mess if developers wrote cross-browser code and understood best-practice techniques.

PROS

  • It’s a good solution which we can implement today.
  • Anyone demonstrating example code with prefixed properties can provide browser support information with strong disclaimers.
  • Everyone can help. Fix your own code and contact sites which are not cross-browser compatible.

CONS

  • There’s no guarantee evangelists and developers will change their attitude.
  • Is it too late? Best-practice techniques are published but ignored.
  • There’s no definitive central information repository.
  • There will always be new, ignorant and sloppy developers. No one can become an expert overnight.

There’s no single solution to the vendor prefix problem. Personally, I favor a quicker W3C process, dropping prefixes after implementation and better evangelism. But those require a major shift in mindset rather than technical changes.

Ultimately, developers caused this problem: it’s up to us to fix it. There won’t be an issue if we shun prefixed properties or use correct cross-browser fallbacks. If we don’t, there’s a risk the CSS3 properties we rely on today won’t work tomorrow.

GA_googleFillSlot("Edit_300x100_C"); GA_googleFillSlot("Edit_300x100_D");
Categories: Web Development

Express Yourself

SitePoint - Mon, 02/20/2012 - 22:28

Express is a web framework for Node, inspired by the Sinatra framework for Ruby. It boasts loads of features, high performance, and comes with a handy executable for creating applications quickly. In this article we’re going to look at how you can get up and running with express, what you get when you create a new express website, and finish with adding a route and view to display search results from Twitter.

Installing Express

Express can easily be installed via npm (Node Package Manager):

$> npm install express -g

The -g switch on the end makes express available globally. This means we can run the express executable from anywhere to quickly create a new application. The express executable is called, unsuprisingly, express:

$> type express express is hashed (/usr/local/bin/express)

If you type in the command by itself, express will create a new application in the current directory. If the current directory isn’t empty, you’ll be prompted and asked if you want to continue: GA_googleFillSlot("InArticle_728x90_1");

$> express destination is not empty, continue?

Enter ‘y’ if you want to carry on, or ‘n’ to abort. You’re not restricted to creating new apps in the current directory, you just need to pass express the path to where you want your new application created. You can pass it other options as well:

  • -s to enable sessions
  • -t or --template <engine> to specify your template engine (express uses jade by default)
  • -c or --css to add stylus CSS support (the default is plain CSS)
  • -v or --version to output the current version of express you’ve got installed
  • -h or --help to output this help and exit

A list of supported template engines is on the express guide, and also on the express wiki. In this article we’ll use EJS. Let’s create a new site called myapp:

$> express -t ejs myapp create : myapp create : myapp/package.json create : myapp/app.js create : myapp/public create : myapp/routes create : myapp/routes/index.js create : myapp/views create : myapp/views/layout.ejs create : myapp/views/index.ejs create : myapp/public/javascripts create : myapp/public/images create : myapp/public/stylesheets create : myapp/public/stylesheets/style.css dont forget to install dependencies: $> cd myapp && npm install

express creates a new site in the myapp folder for us. We get: a package.json file, an app.js file for application code, a routes directory for routes, a views directory for our view templates, and a public directory for our CSS, images and client-side JavaScript. Express also reminds us to install dependencies and gives us the command to do so. We might as well type that in now before we forget:

$> cd myapp && npm install npm http GET https://registry.npmjs.org/express/2.5.5 npm http GET https://registry.npmjs.org/ejs npm http 304 https://registry.npmjs.org/ejs npm http 304 https://registry.npmjs.org/express/2.5.5 npm http GET https://registry.npmjs.org/mime npm http GET https://registry.npmjs.org/qs npm http GET https://registry.npmjs.org/mkdirp/0.0.7 npm http GET https://registry.npmjs.org/connect npm http 304 https://registry.npmjs.org/mime npm http 304 https://registry.npmjs.org/qs npm http 304 https://registry.npmjs.org/mkdirp/0.0.7 npm http 304 https://registry.npmjs.org/connect npm http GET https://registry.npmjs.org/formidable npm http 304 https://registry.npmjs.org/formidable ejs@0.6.1 ./node_modules/ejs express@2.5.5 ./node_modules/express ├── mkdirp@0.0.7 ├── qs@0.4.2 ├── mime@1.2.5 └── connect@1.8.5

You should see something similar, although the exact output may differ depending on which versions of the dependencies are available via npm, and which you already have installed. If you now type in node app.js and browse to http://localhost:3000 you should see the Welcome to Express page. Let’s have a look at the code express has generated and how it’s used to by the welcome page.

app.js

app.js is where you configure your site, and define your routes. The app variable is our express server, and we call it’s configure function to tell express which view engine to use, where to find static resources, and how to handle errors. Look at the default app.js code you’ll see that app.configure is called three times:

  • the first time it’s called without a name argument – this will apply the settings to every environment
  • the second time it’s called with development as the first argument – these errorHandler settings will only be applied in the development environment
  • the third time it’s called with production as the first argument – the errorHandler in the production environment will have exceptions dumps and stack traces turned off

Now look at the last two lines in app.js:

app.listen(3000); console.log("Express server listening on port %d in %s mode", app.address().port, app.settings.env);

This tells express which port to listen for connections on, then logs a message to the console confirming the port it’s listening on, as well as the current environment.

$ node app.js Express server listening on port 3000 in development mode

By default app.settings.env is set to development. To change this to another environment, e.g. production, insert the following line above the call to console.log:

app.settings.env = 'production';

Restart the app ctrl+c, then type in node app.js again), and mode should have changed to production:

$ node app.js Express server listening on port 3000 in production mode Routing

Express exposes the 6 HTTP verbs as it’s API for defining routes, and lets you capture parameters via named parameters, wildcards, regular expressions, and combinations of all three. Captured values will be accessible via req.params:

// using a named parameter app.get('/foo/:id', function(req, res) { var fooId = req.params.id; ... }); // using regular expressions app.get(/^\/foo\/(\d+)/, function(req, res) { var fooId = req.params[1]; ... }); // using a combination of the two app.get('/foo/:id([0-9]+)', function(req, res) { var fooId = req.params.id; ... })

All three routes above show different ways of getting the fooId from the URL.

In app.js you’ll see the route defined for the welcome page. This handles GET requests to ‘/’: when a request is received for this path the callback function routes.index is fired.

.

The routes.index function is defined in routes/index.js. routes/index.js is a module that exports functions to be used as route handlers. If you open it up you’ll see the code that makes up the routes.index function:

exports.index = function(req, res){ res.render('index', { title: 'Express' }) };

This tells express to render the index view. The object passed as the second argument to render is data that will be made available to the view.

Views

When we created myapp we told express to use the EJS template engine. If you look in the views folder, you’ll see that express created a couple of files for us: a layout.ejs file, and an index.ejs file. layout.ejs is where the bulk of the page layout HTML lives, with index.ejs containing page-specific HTML. If you open up layout.ejs you’ll see something like this:

<!DOCTYPE html> <html> <head> <title><%= title %></title> <link rel="stylesheet" href="/stylesheets/style.css" /> </head> <body> <%- body %> </body> </html>

Aside from the regular HTML, the title from the object we passed to the view gets output in the <title> tag, and content from page-specific templates (such as index.ejs) gets included via the <%- body %> line. Let’s open index.ejs to see what’s in there:

<h1><%= title %></h1> <p>Welcome to <%= title %></p>

Again we’re outputting the title from the object we passed to the view, first in the <h1&t; tag, and then in the <p> tag. If you change the value assigned to title in routes/index.js and restart the app, you should see the value change when you refresh your browser.

Adding a New Route

Let’s add a new route and view that’ll display the ten most recent tweets mentioning Sitepoint. We’ll need to add a route to app.js, a callback function for the route, and a view to display the tweets:

  1. Open app.js and add a route for the tweets page:

    app.get('/twitter', routes.twitter);
  2. Next, open up routes/index.js and add this line at the top to import the http module:

    var http = require('http');
  3. Stay in routes/index.js and add the following function:

    /* * GET twitter search results */ exports.twitter = function(req, res) { var options = { host: 'search.twitter.com', port: 80, path: '/search.json?q=sitepoint&rpp=10' }; http.get(options, function(response) { var tweets = ''; response.on('data', function(data) { tweets += data; }).on('end', function() { var tmp = JSON.parse(tweets), topTen = tmp.results; res.render('twitter', { title: 'Latest from Twitter', tweets: topTen }); }); }).on('error', function(e) { res.writeHead(500); res.write('Error: ' + e); }); }

    Here we’re using http.get to make a HTTP GET request to the Twitter Search API. We pass http.get the options object, which tells it where to get the data from. We then define a couple of callback functions: on('data', ...) appends data to tweets each time some data is received; on('end', ...) is called when all data has been received, and sends the tweets to the twitter view.

  4. Finally, create a twitter.ejs file in your views folder. Open the file and add the following:

    <h1><%= title %></h1> <% if (tweets.length) { %> <ul> <% tweets.forEach(function(t) { %> <li> <h2> <a href="http://twitter.com/<%= t.from_user %>" rel="external"> <%= t.from_user_name %> <span><%= t.from_user %></span> </a> </h2> <blockquote> <p><%= t.text %></p> </blockquote> <a href="http://twitter.com/#!/<%= t.from_user %>/status/<%= t.id %>" rel="external">Open</a> </li> <% }); %> </ul> <% } // endif %>

    After displaying the title, the view checks that we have some tweets to display. If we do, forEach iterates through each tweet, using the callback function to display the tweet’s text, and who the tweet was from.

Restart the app, then browse to http://localhost:3000/twitter and, if all went well, you’ll see a list of the ten most recent tweets mentioning Sitepoint.

So that was a quick introduction to creating a website in Node using the express web framework. We looked at what express gives you when you create a new express site, had a quick look at how it uses routing and views, and added a new route and view to display search results from Twitter. There’s a lot more that express is capable of, and a lot that we haven’t covered. If you’re interested in finding out more then head over to http://expressjs.com/guide.html, and have a look at the express wiki.

GA_googleFillSlot("Edit_300x100_C"); GA_googleFillSlot("Edit_300x100_D");
Categories: Web Development

The Largest jQuery Class in the World

Nettuts - Mon, 02/20/2012 - 17:15
A couple weeks ago, Tuts+ Premium launched a free new real-time course, called “30 Days to Learn jQuery.” After signing up, each member receives an email, linking to a new video lesson for an entire month. I’m pleased to announce that, after only two weeks into the course, we’ve amassed the largest jQuery class in [...]
Categories: Web Development

MySQL Master-Slave Replication: Starting Replication

SitePoint - Sun, 02/19/2012 - 21:11

In my last article, I took you through Phase 1 of setting up the MySQL Master-Slave relationship.

Now, we have the Master SQL Server running and serving our clients, which connect using remote IPs. Also, the Master has a replication server id (e.g. “100”) and waits for the Slave connections with a user that is allowed replication (e.g. ‘repl’).

We also have Slave SQL Node almost ready to start.

What we are going to do now is the following:

  1. On Master,
    1. get the Replication Master Binary Log Coordinates
    2. create a data snapshot using mysqldump
    3. transfer the data on Slave
    4.  

  2. On Slave,
    1. Restore the data snapshot
    2. Set the Slave to start replication.
Detailed ActionsOn Master

During steps 1 and 2 below, your Master database will be set to read-only mode.

  1. Get Master Coordinates

    1. Open a MySQL shell and give:
       
      mysql> FLUSH TABLES WITH READ LOCK;
       
    2. IMPORTANT. Leave this shell open and create another mysql client shell, i.e. another session:
       
    3. Hence, on another session, type in the following mysql command:
       
      mysql> SHOW MASTER STATUS;
       

    Write down the values for the column FILE and POSITION. You will need them later when setting up the Slave to start replication

  2. On a command prompt, get a data snapshot:
     
    os-shell> mysqldump --all-databases --master-data > dbdump.db
     
  3. If you have a big database, this might take quite some time. In our case, for a 25Gb database, it took something like 15 minutes. GA_googleFillSlot("InArticle_728x90_1");

  4. Release lock and allow your Master to play

When your data dump finishes, just close the connection you opened on step 1 and your Master database server will resume serving transactions.

Now, you have a database file you can use on Slave to restore the database. You have to transfer this file to your Slave node.It might be a good idea to tar and gzip this file before transferring it and then untar and unzip it at the Slave node.

On Slave

Assuming that you have transferred your database dump file to Slave, you move on to work on this node as follows:

  1. Start MySQL server with --skip-slave-start option so that replication does not start. Here is the suggested way:

    On your operating system command prompt:
     
    os-shell> mysqld_safe –-skip-slave-start
     

  2. Import the dump file:
     
    On another operating system command prompt:
     
    os-shell> mysql –u root –p < dbdump.db
     
    This will start the import. It will take quite some time if your dump file is big.
     
    Important gotcha:: Before you start the import, make sure that you have enough space both on the datadir of MySQL and on the binary log directory too.
     
  3. Stop MySQL Server
     
    Assuming that import has finished successfully, and assuming that on step 1 above you started the MySQL Server skipping slave start, you need to stop this and make sure that MySQL server is not running.

    Some Problems that you might have now on Slave

    The problem that you have now is that you restored the system databases as well. These are coming from your Master server, which has a different IP. This will mean that ‘root’ user might not have any access to MySQL server now from the local Slave machine.

    Also, ‘root’ might have different password. In Debian machine this is encrypted in the file debian.cnf” in your MySQL installation directory.

    You can bring the debian.cnf file from your Master to your Slave machine. Or you can change/reset the ‘root’ password on your Slave machine.

    Hint: You can change/reset the ‘root’ password on MySQL server as follows:

    • Start MySQL so that it will not ask for password. Also, make sure it does not start replication:
       
      os-shell> mysqld_safe –-skip-slave-start –skip-grant-tables
    • Then connect with mysql –u root and issue a command to update ‘root’ password as follows:
       
      mysql> use mysql;
       
      mysql> update user set password=PASSWORD(‘new-password’) WHERE User = ‘root’;
       
      mysql> flush privileges;
       
    • Stop MySQL Server that you started with skipping slave start and grant tables.
  4.  

  5. Start MySQL Server with skipping Slave Start
     
    os-shell> mysqld_safe –-skip-slave-start
     
  6. Set Master configuration on the Slave
     
    Execute the following command on a MySQL prompt:
     
    mysql > CHANGE MASTER TO MASTER_HOST=’10.100.10.80’, MASTER_USER=’repl’, MASTER_PASSWORD=’slavepassword’, MASTER_LOG_FILE=’mysql-bin.000003’, MASTER_LOG_POS=106;
     
    This is how you tell Slave how to connect to Master in order to replicate. Note the log coordinates. These are the coordinates you got from step 1 above.
     
  7. Stop MySQL that you have started on step 4 above.
     
  8. Start MySQL normally, e.g. on an OS shell:
     
    os-shell> /etc/ini.d/mysql start
Checking out that everything is OK

Having started the slave MySQL node, you can log in and issue some commands to make sure that Slave is running OK.

  1. On mysql prompt, give the following command:
     
    mysql> show processlist;
     
    The output should be something similar to the following:

    +----+-------------+-----------+-------+---------+------+-----------------------------------------------------------------------+------------------+ | Id | User        | Host      | db    | Command | Time | State                                                                 | Info             | +----+-------------+-----------+-------+---------+------+-----------------------------------------------------------------------+------------------+ |  1 | system user |           | NULL  | Connect |  232 | Has read all relay log; waiting for the slave I/O thread to update it | NULL             | |  2 | system user |           | NULL  | Connect |  232 | Waiting for master to send event                                      | NULL             | | 39 | root        | localhost | mysql | Query   |    0 | NULL                                                                  | show processlist | +----+-------------+-----------+-------+---------+------+-----------------------------------------------------------------------+------------------+ 3 rows in set (0.00 sec)

     
    You can see the SQL thread that gets data from Master (in the above output is the thread with Id 2) and the SQL thread that executes the statements on Slave (in the output is the thread with Id 1).

  2. On mysql prompt, give the following command
     
    mysql> show slave status;
     
    This will display the current status on slave. Pay attention to the *_Errno and *_Error columns. Normally, you shouldn’t see anything that indicates existence of errors there.
     
  3. On mysql prompt, give the following command
     
    mysql> show status like ‘Slave%’;
     
    You should see an output like the following:

    +----------------------------+-------+ | Variable_name              | Value | +----------------------------+-------+ | Slave_open_temp_tables     | 0     | | Slave_retried_transactions | 0     | | Slave_running              | ON    | +----------------------------+-------+ 3 rows in set (0.00 sec)

    Pay attention to Slave_running being with value ON.

Important note on binary log time to live

As we have said before, you can have Slave down and resynchronize as soon as you bring it up again. But do not put it out of service for quite long because, then it will be impossible to synchronize its content with Master. This is because the binary logs on Master do not leave forever.

There is the variable with name expire_logs_days that determines the number of days for automatic binary log file removal. Check this out. This should be 10, meaning that if you ever have your Slave down for 10 days or more, it will not be able to do replication as soon as you bring it up, and you will have to  everything from the beginning.

Conclusion

That was our story on how, more or less, we have implemented MySQL replication for our Fraudpointer application. The steps may not apply exactly to your particular case, but they can still give you a kick start and show you the way to implement replication the way it should work on your configuration.

Your comments are more than welcome. We want them. We need to improve this process and your feedback is absolutely valuable to us.

GA_googleFillSlot("Edit_300x100_C"); GA_googleFillSlot("Edit_300x100_D");
Categories: Web Development

What Should You Charge? 4 Methods to Avoid

SitePoint - Sun, 02/19/2012 - 18:00

Selling a product is so much easier. You have a fixed cost at which you buy (called wholesale), so you figure out how much profit you’d like, and mark it up according. There’s even the MSRP (Manufacturer’s Suggested Retail Price) to make your life easier. But everyone who decides to sell their services will agonize over this question: “How much should I charge?”

There are many ways to answer that question. Let’s look at four to avoid.

Formula-Based Pricing

Many of us used a formula to answer that question:

  1. How much do I want to make a year?
  2. How many hours a week do I want to work?

So if it’s your dream to make $60,000 a year, working only 20 hours a week (including a two-week vacation), you do this:

$60,000 / 50 weeks / 20 hours = $60/hour

Next, determine the time it takes you to create a “basic” website (for me, that was a 5-10 page custom-designed static site, no programming). If that takes 35 hours, your pricing would start at $2,100. Or you could simply charge by the hour and the client pays what he pays. GA_googleFillSlot("InArticle_728x90_1");

Sounds great, except for one problem. Clients don’t care about your formulas.

Pricing your product is actually simple, as long as you consider it from the buyer’s point of view. How much it costs you to make something is irrelevant. They don’t care …

- Seth Godin

Your formula has no bearing on what a client is or isn’t willing to pay. How would you justify $60 an hour if the client thinks that’s too expensive? Telling him you’re worth that because you want to make $60k a year working 20 hours a week isn’t going to convince him to hire you. Neither is telling the client “how long” it will take.

Esteem-Based Pricing

The second method to avoid is basing your price structure on what you “deserve” to make. I’ve read books that claim we’re not charging what we’re worth because of low self-esteem. If we improve our self-esteem, we’ll charge what we’re worth, what we deserve—and our clients will gladly pay it. Pardon me if I’m not quite convinced.

Your clients don’t care if you think you “deserve” $60 an hour because you have a computer science degree, 15 years of programming experience, hundreds of hours of formal web training, $10,000 worth of hardware and software, and a $50,000 student loan to repay, or because some self-help guru told you that you do. Clients buy for their own reasons, not yours.

Comparison-Based Pricing

Comparison-based pricing is when you set your prices based on what you think is too expensive. It usually happens after you arrive at some semblance of a price, but then you start thinking, “I don’t know, $1,000 is a lot of money; maybe I should charge $900 …” You might think $1,000 is a lot of money, but what are you comparing that to? Your car payment? Your rent? Your monthly income? I once suffered from this malady, but the first time a client paid three times above what I considered “a lot of money,” I was cured.

Competitive-Based Pricing

Researching the competition is generally considered valuable when starting a business. But I found that to be a tall order in the web industry. First of all, who’s your competition? ABC Interactive Agency, or the teenager with a cracked copy of Dreamweaver? Sure, you can scour the web or post a newbie “How much should I charge?” question on SitePoint’s forum, but most of us keep that pretty close to the vest. And the prices I have found are all over the map. Even fellow web designers can’t agree. Although I did look at others’ prices when I first started out, it wasn’t a determining factor when setting my own.

So what should you base your pricing on? The answer lies in why people buy. Even established companies don’t always know why their customers are their customers. Remember, people buy for their reasons, not yours. If you don’t know what those reasons are, you’ll have a difficult time determining what to charge.

Image credit

GA_googleFillSlot("Edit_300x100_C"); GA_googleFillSlot("Edit_300x100_D");
Categories: Web Development

Microsoft Reveals the New Windows 8 Logo

SitePoint - Sun, 02/19/2012 - 07:40

Microsoft has revealed the new Windows 8 logo. I wouldn’t normally write an article about it but this is the first major redesign in 22 years. And since most of us use Windows every day, that’s a fairly big deal.

Are you ready? Here goes…

While it’s no London 2012 logo, I can’t help feeling a little underwhelmed.

Changing your brand is not something companies (should) do on a whim. Microsoft state the new logo reflects the re-imagination of the Windows operating system with clean lines, simple colors and the new Metro interface. They also admit the old logo was a flag rather than a window. Did it ever confuse you?

I’m not totally convinced. The font is a little simplistic and why is the window icon shown in perspective when Windows 8 looks flat?

It’s a bold move that’s likely to divide user opinion. Much like Windows 8. So let’s take a brief trip through history to see how Microsoft reached this point… GA_googleFillSlot("InArticle_728x90_1");

Windows Vista/7

The semi-transparent full-color Aero theme had a big influence on the Vista/7 logo and start button:

It’s still recognizable as the Windows logo, but the highlights, shadows and gradients made it feel more modern.

Windows XP

XP remains the world’s most-used OS eleven years after its release. Again, the logo matched XP’s default theme and, while it looks a little basic today, it was a fairly radical step forward at the time…

Windows 3+

In the decade leading to XP, all versions of Windows including 3.x, NT, 95, 98, Millennium and 2000 used a variation of the flag with familiar motion trails:

It looked fairly dated in the 1990s, but that’s the period Microsoft became the most dominant OS maker on the planet. The logo is business-like and businesses flocked to Windows.

Windows 1.0

Do you remember the original Windows logo from the 1980s? Me neither. Does it remind you of anything?…

We’ve come full circle. Almost three decades of tweaks and redesigns has resulted in a logo which looks almost identical to the one first used in 1985. I think I prefer the original — although a sans-serif font would improve it.

Whatever your opinion, you better get used to it. The Windows 8 logo will appear everywhere in the lead up to the new OS release!

GA_googleFillSlot("Edit_300x100_C"); GA_googleFillSlot("Edit_300x100_D");
Categories: Web Development

Nettuts+ Quiz #10: Basic CSS3 Techniques

Nettuts - Sat, 02/18/2012 - 09:39
In 2012, we plan to take our quizzes to a whole new level with ones aimed at all languages and catering to all competencies and tastes. This month, we’re covering some basic concepts and techniques in CSS3. The prime focus today is on the easier, more accessible portions of CSS3. If you’re a hardcore CSS3 [...]
Categories: Web Development

SitePoint Podcast #150: The Vendor Prefix Kerfuffle

SitePoint - Sat, 02/18/2012 - 05:12

Episode 150 of The SitePoint Podcast is now available! This week the panel is made up of Louis Simoneau (@rssaddict), Kevin Dees (@kevindees), Stephan Segraves (@ssegraves) and Patrick O’Keefe (@ifroggy).

Listen in Your Browser

Play this episode directly in your browser — just click the orange “play” button below:

Download this Episode

You can download this episode as a standalone MP3 file. Here’s the link:

Subscribe to the Podcast

The SitePoint Podcast is on iTunes! Add the SitePoint Podcast to your iTunes player. Or, if you don’t use iTunes, you can subscribe to the feed directly.

Episode Summary

Here are the main topics covered in this episode:

Browse the full list of links referenced in the show at http://delicious.com/sitepointpodcast/150. GA_googleFillSlot("InArticle_728x90_1");

Host SpotlightsInterview Transcript

Louis: Hello and welcome to another episode of the SitePoint Podcast, I think it’s episode 150, is it not?

Stephan: It is 150, I believe.

Patrick: Everyone believes, no one knows, that’s how all opt-in we are (laughter).

Louis: That’s how organized we are. So we’ve got a panel show this week; Patrick, Kevin and Stephan are all on the line, hi guys.

Kevin: Howdy, howdy.

Patrick: Hello.

Louis: How you guys been?

Stephan: Busy.

Patrick: Pretty good; last show I was down in Orlando to record it with Kevin on his couch, and spend some time in Atlanta, spoke at CNN, and I’m actually drinking a Coke from a glass bottle right now, so, there’s that, I got it from the World of Coke in Atlanta. Which if you know me you know I love soda, and I love the World of Coke where you can drink over 60 different soft drinks from around the world, but also the new Coca-Cola Freestyle machine which dispenses another 100+, so, yes, it’s a great place.

Kevin: I absolutely hate those Coke dispensers because they are not as carbonated as they should be, and it feels like a mixed drink that hasn’t been mixed thoroughly, so, you know, and you don’t want to mix a coke because then you lose all your carbonation, so it’s like you don’t have enough carbonation and then you mix it and they don’t have any carbonation anymore, so now you’re drinking a flat soda. Cool idea, bad implementation.

Louis: (Laughs)

Patrick: And then it turned into the soda show (laughter). No, I love the Freestyle, I love the Coca-Cola Freestyle, but I will say that there are some sodas, and it’s really like one or two that I prefer the standard mix versus the Freestyle, but the Freestyle is actually kind of new and kind of cool technology that our audience might appreciate because it dispenses the syrup and the carbonation and the water in like a precise formula so that the restaurant can’t change that and mess it up, so this is how it’s supposed to actually taste, so, I thought that was interesting.

Louis: Years ago when I was traveling through the U.S. I was in a, um, I think it was a McDonald’s, and they served I think it was a Sprite where it was too much syrup, where they’d messed up the mix, and it was just like — it was just like liquid sugar with a little bit of water and a little bit of carbonation, it was awful.

Patrick: Yeah.

Louis: Anyway, I don’t do soda anymore, not because of that (laughter).

Patrick: You came to America and America totally turned him off to soda because of that McDonald’s, shame on you.

Louis: Yeah, no, that’s not how it happened. Anyway, so we should talk about things other than soda because I’m sure that, you know, that’s not what brings our audience to the SitePoint Podcast, although it may in the future; if you like hearing soda-related tidbits come back next week.

Kevin: Soda-cast!

Patrick: Yes!

Louis: We should make a soda-cast. Anyway, so the major story this week, at least that crossed my radar, has been an ongoing kerfuffle, let’s call it that, at the CSS Working Group and W3C. So this all sort of came to light on Thursday of last week when Daniel Glassman, I hope I’m pronouncing that name correctly, wrote this blog post describing some of the goings on at the latest meetings of the CSS Working Group. And basically the rundown of the situation is that as many of you will know, recently as new CSS features make their way into browsers, a lot of browsers sort of testing the waters with their implementations, and they’re not exactly sure how — or the spec isn’t finalized yet, for example, so they’ve been using vendor prefixes, you’ll be familiar with a -webkit- property name, so like WebKit box shadow or a WebKit border radius, the Mozilla one is Moz, and the Opera one is just an O, so obviously developers have been using these pretty extensively; Kevin and Stephan you guys write some code, have you guys done a lot of work with vendor prefixes?

Kevin: Too much.

Louis: (Laughs)

Kevin: To sum it up.

Louis: Right. So, anyway, the goings on at the Working Group were that the other browser makers, that is to say not Google and Apple, have said, look, everyone’s just implementing the WebKit ones, web developers, that is to say, are writing sort of WebKit-only pages to sort of test these experimental features, even when those features are available in prefixed form, or even in non-prefixed form, you know, the browsers including mostly Firefox and Opera, but also for some properties I guess Internet Explorer. And what happened is that Firefox, or the makers of Firefox just sort of said, look, we are gonna start supporting the WebKit prefixed one, and that’s what everyone’s doing, and people don’t seem to know that in the case of some stable features they can just drop the prefixes, and in the case of other features there is a Mozilla equivalent; people are just writing the WebKit ones because they’re trying to support mainly IOS and Android on mobile, and also Chrome and Safari on the desktop; WebKit has a pretty big market share at the moment. So obviously this caused a bit of uproar, and Glazman wrote this big, I guess, call for action is what he calls it, saying look if we let this happen it’s pretty much the return to the days of proprietary features in IE6, and then everybody came out sort of in support of that. So, I wanted to get your guys’ read on this, maybe Kevin especially because you do a bit more front-end stuff.

Kevin: Yeah, so, I mean prefixes are kind of the cola wars of browsers, in my opinion, you know it’s not as flamboyant as it was back in the IE5, IE6 days where everybody was just kind of up in arms, you know the Firefox one day just, well, just, you know, everything coming to a head, and the invention of Ajax and all that, so all those things were good, though, right, I mean that’s what brought us to the Web where are today. So, like I said, we have Ajax where we can do asynchronous calls to XML files, even JSON, you know, any kind of document we want. Now today it’s the prefix, right, and it’s been a big topic because it’s kind of a valid way of doing this because it’s in the CSS specification where you can — it’s basically set out that you can use vendor prefixes. And so to me that’s what makes it more of a cold war, right, because it’s legal everybody’s just kind of doing it under the table, doing their own thing. And so to other vendors picking up other vendors’ prefixes seems a little scary to me because that’s stepping outside of what the W3C had set out to do with these which was prevent that very thing from happening, like you had with the filter element in Internet Explorer, right. And so, yeah, you know, this doesn’t give me a good feeling, I like the idea of vendor prefixes, I think it’s great for expanding on ideas and trying out new things without effecting the way things can be implemented in the future, but at this point it looks like I think this is really a problem that’s been designer related, right; designers and developers have created this demand for these features, and since the W3C can’t move fast enough to feed the designers what they want, and the developers as well, I’m not trying to make this a one-sided argument or anything, I think that’s kind of what’s causing this issue is the impatience of developers, and that kind of thing. And so the only solution that browser makers can do, because nobody’s going to pitch their browser if they’re behind, right, I mean you can see there are a lot of things in play here, and so, yeah, I think it’s just a big, crazy mess, and the W3C has to figure something out to work with all these browsers, I mean it’s nothing — it’s hard to just make a small comment on because it’s so complex.

Louis: Yeah. So, a couple of things related to some of what you just said, one of them is saying that developers are impatient for these features, and that’s true to some extent, and there are cases that are more similar to filter, in the case of, for example, WebKit Text Size Adjust is a property that was created in WebKit, and it’s used on IOS and Android but was never in the CSS specifications, but a lot of these things are properties that were in the specifications and either, well, first of all the CSS3 spec is still in progress, the browser didn’t want to lock down –

Kevin: Exactly.

Louis: — and create a version of that that might then be not backwards compatible. A good example of that is the original gradients and syntax that existed in WebKit is not the syntax that’s currently used in the W3C spec, and it’s not the syntax that was used by the other browsers. So currently if you do WebKit gradient that does something entirely different from the linear gradient and radial gradient properties, and the fact that it was boxed away into a vendor prefix form sort of protects us because we can now use the standardized form, and it won’t break on those older versions of Chrome and Safari, of which obviously there are a few because the browser upgrade cycles have improved as well. And then putting it back on the W3C, as you said, they have to come up with something; I don’t think it’s necessarily up to the Working Group and up to the browser makers, there’s not a lot they can do, and Eric Meyer wrote a good blog post sort of summing up what he sees as the browser makers positions here, so I’ll just quote briefly from his blog post, “As a vendor it may be the least bad choice available in every competitive marketplace, after all, if there were a few million sites that you could render as intended if only the authors used your prefix instead of just one, which would you rather: A) embark on a protracted massive awareness campaign that would probably be contradicted to death by people with their own axes to grind, or just support the prefix that people are using and move on with life?” So in this case he’s saying if you’re Mozilla, yes, the correct thing to do is to keep pushing the -moz- prefix and supporting a standardized non-prefixed form once the thing is stable and you feel like you’ve got a solid implementation, but if there are a million sites out there on the Web that look broken because they’ve only used WebKit, then for user browser makers your main prerogative is to serve your users and make the sties that they visit not look broken, right. I think it’s largely up to developers to really not be lazy about this, if you want to make a cool demo and you use Chrome and you have an iPhone that’s great, you can make a cool demo, but take the time to find out whether the property that you’re demoing actually exists in Firefox and exists in Opera, and chances are it probably does, and if it does don’t just do the WebKit one, right — right?

Stephan: Right. (Laughter)

Kevin: You know sometimes you have to stop and think about these kinds of things for a second, it’s hard to — because I mean it is a complex situation; you know right when you think web standards has won, you know, something like this comes out and happens and it’s a little scary, and something you have to be watchful of, it’s good that people are talking about it, you know, but at the end of the day web standards are just that, they’re standards, and you’re trying to create a unified language for everyone to use that way when, like you said, a browser gets updated your site doesn’t break. And so the danger that I see in this is, yeah, you’re gonna go and adopt this other prefix, let’s say you’re at Firefox, right, and you adopt the WebKit prefix, you go and do this but it doesn’t change people’s code, you know what I mean, it’s like it doesn’t help standards at all, it only hurts them.

Louis: Absolutely. I’m not saying that this is a good thing for Mozilla to be doing, it’s a terrible, terrible idea, but from the perspective of a browser maker, like what Eric’s article was trying to say, is that it seems like it’s the logical thing for them to do, even though it’s the wrong thing objectively for the Web and for web standards going forward. I mean the last thing we want is for these WebKit properties to wind up in all browsers, and that sort of circumvents the W3C entirely, right, then it’s just whatever WebKit does other browsers decide to support if they like it, if they don’t they don’t, I guess, and then you don’t have a standards process, then you just have one browser maker controlled by a few ginormous companies that — or, to be clear, WebKit is open source but a large percentage of the contributions come from Google and Apple, you know, that’s definitely not the way we want to go.

Kevin: You know because there are so many platforms in place, I mean you have Windows, Linux and Apple, right, right now, and those are kind of the big-time, I mean you have other proprietary operating systems, but those are like server software and that kind of thing, so you don’t really have browsers on them. But, uh, it’s something where I mea I know they’ve been fighting for this for a long time and we’re probably pulling this out, this conversation out a little bit, but it would be nice if everyone could just get together and say here is our one rendering engine, and I know this isn’t gonna happen because there is a certain amount of control that you need on an operating system to please, I mean it’s a business. At the end of the day what I’m trying to say is it’s a business, and whether you’re Firefox, Internet Explorer or Google your business is getting people to see your brand, and since everybody surfs the Web, the browser’s an excellent way to do that, and I think until that goes away we’re always going to have standard problems.

Louis: Okay. So first of all I don’t think that’s a fair call because at least one of the rendering engines out there, which is to say Firefox from Mozilla, is not a business, it’s an open source project put out by a non-profit.

Kevin: This is true.

Louis: And to some extend WebKit also sort of falls in that realm, even though it’s championed by two very large companies, and those two very large companies another valid point is that they’re often at each other’s throats, so saying that they’re trying to push the browser engine WebKit to try and advance through an agenda is valid, but they’re also helping their competitor, right, so it doesn’t — it’s not just business, I don’t think that’s the only reason why the standards process is difficult, and I think it was actually kind of working, I mean these vendor prefixes were effective. One of the suggestions people have made is that the experimental ones shouldn’t still be there after the property is stabilized, so that means if you support box shadow in an un-prefixed form in your browser then there’s no reason to still support WebKit box shadow because you want to push developers towards using the standard form, right; these are only sort of an interim stopgap solution while you’re testing things.

Kevin: Right. That still kind of breaks the Web in a way, though, because you lose future compatibility versus backward compatibility.

Louis: Yeah. Another suggestion that I read that I really liked, I don’t remember who suggested this, but someone had mentioned that a good idea might be to have the vendor prefixed properties only exist in develop versions of the browsers. So if I’m using the nightly builds of WebKit then I can test around with these WebKit ones, but as soon as it goes to a full release where it’s pushed out into Chrome and Safari either you support the property or you don’t.

Kevin: It’s an interesting idea.

Louis: If you do then there’s no prefix, and if you don’t then it’s just out, which I think is probably — it seems on the surface of it like a good idea, I haven’t given it a whole bunch of thought, but it seems like it might sort of solve some of these problems where people are making websites out in the wild using these experimental properties and sort of tying their sites to one browser or one rendering engine.

Kevin: Right. Yeah, I like that idea because at the end of the day what a lot of browser makers need is feedback from implementers, right, and so that would be an excellent way to do that, I think. Now, you wouldn’t get as many implementers because not everybody runs develop builds, but you would still get a good many.

Louis: Yeah, and without necessarily running the risk of people developing production websites with experimental properties. Anyway, I just — it’s good to get a bit of a read on this, it’s been obviously a huge outroar on the Web, there have been blog post far and wide, SitePoint, long time SitePoint friend Rachel Andrew wrote a blog post decrying this action on the part of Mozilla and other — well, basically just saying look we’ve got to fix this, so people have come up with — there’s a petition and a pledge telling browser makers not to implement WebKit vendor prefix and promising to update the sites that you do control, so if you do feel like this is something that matters and you don’t want the other browser vendors to start standardizing around the WebKit form then there’s that option, there’s also a project started by Christian Heilmann, who’s of Mozilla, which is called Prefix The Web, I’ll put a link to that in the show notes, and that is people going around finding open source projects on GitHub and demos of CSS3 functionality that people have put on GitHub, and just patching that code to support other browsers where possible, so there’s a whole list of those of projects people have found and updated to be more cross-browser compliant, so a lot of things that, you know, a lot of people are jumping into this bandwagon and trying to get people up and angry about this, so that’s good, we’ll have to wait and see what happens though.

Kevin: Yeah, it’s the nature of the Web, right, there’s always something crazy going on, it really is.

Louis: Yeah, cool. Well, I guess that wraps that if someone wants to jump in with the next story.

Kevin: So, I have an interesting article to get off the CSS train for a second and talk about the Kickstarter.

Patrick: Yay. (Laughter)

Louis: Yeah, what happened to the train, we haven’t heard the train yet today Kevin?

Kevin: Yeah, yeah,

Patrick: whoo whoo (laughs)

Kevin: I’m sure it’ll be around later, I think it comes at 7:30, but maybe 7:45 today, we’ll see.

Patrick: It’s running late from Albuquerque.

Kevin: So, there’s a blog post up, it was posted on February 10th, about the last 24 hours, of course then, of Kickstarter and how they’ve made some giant leaps and bounds in what they’re doing. And I think Kickstarter is a worthy company and project to talk about because it helps other people work together to finance ideas and projects and that kind of thing. Basically what they have going on is basically a timeline on this blog post of all the things that have happened over 24 hours, it was a big day for Kickstarter and just all the different things between political efforts and some very large projects that they have going on; I believe Elevation Doc saw close to a million dollars for their project. And so I was wondering maybe if you guys had thoughts on a project like this that kind of takes off, like your opinions and stuff on maybe what other people could do to get involved in a project like this. Like how — I think, Patrick, you would probably have some opinions on this, but, you know, I’m sure you’ve heard of Kickstarter, but how would somebody go about getting involved not only in like one of these good projects, but also starting their own project. Like because I think on the cusp of something like this it’s good to kick into the imagination; I know I’m stumbling all over my words here, but, interesting I would say.

Patrick: Kickstarter’s awesome, I mean I think I love the idea of it, it’s not like a complex idea, it’s a pretty simple idea, it’s a simple concept, and they’ve got the community and the traffic to make it a successful venture, and that’s really what it’s about, not necessarily the idea but the execution. And I think it’s great for them to hit this mark and to have projects that go over a million dollars, it really makes me think creatively about what I could do with the platform myself if I have different ideas for different projects that I want to fund, and to be able to get that funding before laying out the investment. Not that it really disrupts venture capital so much, I think that space is still kind of its own sort of country and has it’s own sort of norms and principles, but definitely this is a case where people can go out there and more simply get funding and maybe maintain more control of their idea by delivering it directly to the people who want their product or want to see them release whatever it is they are interested in putting out. So, to me it’s a great idea and it’s great to see them be successful, and it’s great to see so many different content creators and product developers look to Kickstarter to put out something; I notice a lot of web video channels, a lot of successful — YouTube channels especially, putting out Kickstarter campaigns or similar campaigns to fund their next big thing, or maybe they’ll want to do a movie or a longer feature, and so they’re using Kickstarter or something similar to fund it, mentioning people in their videos, having people pick elements of the video; there is a series called Beer and Board Games from Blame Society Films that is a lot of fun, and they have people who you can pick the beer, you can pick the game they play, and so they get the funding but then they make the people a part of the project as well, and I think that’s a lot of fun.

Louis: Yeah, it’s an awesome thing, and it’s great for people who have ideas to be able to just kick it directly to their fans, especially if they’ve already got a following and just want to, like you said, do something a bit bigger and more ambitious. I have to say — I’m just gonna nerd this up a little bit; I was kind of disappointed because when I see these like, oh, we had this crazy 24 hours blog on a startup website I’m hoping for like our servers were getting hammered and here’s what we had to do, and all the nerdy technical details. And just so the listeners aren’t disappointed, there’s none of that, it’s all about successful and just how it blew up on social media, not about how they weathered the storm of all the increased traffic.

Patrick: Right, no, none of that (laughter). It’s a mainstream blog post; we’ll put it that way.

Louis: Yeah, maybe they have a technical blog as well; maybe I’m just not looking at the right place.

Patrick: Yeah, it’s possible.

Kevin: I think I’m a little biased to Kickstarter in a way because it’s such a good site, right, I mean I’ve seen really good things come out of it, there’s projects for like WordPress plugins, and that kind of thing, and I think even some iPad gear came out from this, and these are all just individuals who have an idea and want to get other people who like that idea, or have similar interests, to get involved so you can help create things that aren’t just blah, if you know what I mean, like it’s a quality product, right, because there is some investment, and you can put time behind the things, and I just love it, I think it’s great.

Patrick: Yeah, it is, and have you funded anything, Kevin?

Kevin: Yes, I have. So, one of my friends, he works with a lady and they do music albums, and so I supported them, it’s the Hannah Miller, you can look them up, I love that music, it’s good.

Patrick: Okay, yeah, I haven’t funded anything myself, not yet anyway.

Kevin: Right.

Patrick: I want to, though, I will one day, I’m sure. Put your money where your mouth is, Patrick.

Louis: That’s right. Yeah, let’s do it. Speaking of money, that’s a perfect segue.

Patrick: So, speaking of money, I picked up a story on TechCrunch by Rip Empson, and he reported on the sale of two domain names, not your everyday sale, though, because it was challenge.com and vi.com, and challenge.com was sold for $500,000.00, while vi.com was sold for $325,000.00 to a company named Visalus Sciences, I believe. And that story linked me to bigger lists of the biggest domain name sales of 2011, so last year’s top 100 domain name sales by the actual cost of the domain name. So the number one domain name last year sold, the most expensive one was social.com, which was sold for 2.6 million dollars, then domainname.com, and dudu.com, I assume that means something to someone or in some other language, both sold for a million dollar each, and there’s this long list of names, 3d.com jumps out to me for $500,000.00, and for the kind of web dev technical audience that we have, datacenter.com sold for $352,500.00, and livecloud.com sold for $92,000.00, so, yeah, I’m always curious of what domain names are worth, so this helps to guide me; not that I have any that are worth half a million, of course.

Louis: Yeah, I mean that stuff is kind of crazy, it’s really surprising to me to look at this because — and so what did you say social.com sold for, sorry?

Patrick: 2.6 million. It was the most expensive by far, like the closest one was domainname.com for a million.

Louis: Yeah, but I mean even let’s go with $500,000.00 and up, I find it difficult to imagine other than, you know, if it’s your brand, if it’s like hp.com or apple.com then obviously the value of that to you as a company could reach that kind of number, but I can’t possibly imagine anything that you could do with social.com that would reach anywhere near that level of investment that you couldn’t do with a different domain. Increasingly it seems like the domain name is less and less relevant in web ventures because everyone finds things via Google, or you’ve got a Facebook page or Twitter, I mean it’s easy to find anything. I think even as recent goings on with like, for example, Facebook login being the most commonly searched thing in Google, right, or it was at some point, or it was in the top ten of searches, right; people aren’t even entering Facebook.com to go to Facebook, so it seems like the domain name is kind of irrelevant, and especially something like social.com where it doesn’t have a strong branding, it’s just sort of this random word, it kind of baffles me.

Patrick: Yeah, I mean I can understand that. There are two, you know, there’s a couple thoughts, domain names, branding, it can have an impact on getting funded, I’ve heard multiple people say this before that if you have a great pitch and great domain name you’ll go a lot farther than if you just have a great pitch. Is that fair? Is that vanity or cosmetic? Perhaps, but it is something that I’ve seen repeated multiple times, and so you do have as far as, like you said, people go to Google, the domain name does impact searches and results, what’s in the domain name. So, for example, domainname.com might have a decent chance at ranking for the search term domain name if you were starting now versus starting as eNom, let’s say eNom has built up links and they’ll get credit for that, but if you are one of those right now and you’re targeting that term, domainname.com is gonna put you head and shoulders above generic branding. But I can understand your point because that’s a point a lot of people make is that if you have a million to spend on a domain name then you have a million to spend on something else.

Louis: It just seems to me like if you’ve got — let’s say I’ve got an idea for a website that is gonna be the next social network, right, I can either spend 2.6 million dollars hiring developers and designers and making a product, or I can buy social.com and then spend a thousand dollars hiring designers and developers making a product. And if feels to me, like my gut feeling is that the better product is a more worthwhile investment of my time, whether or not it’ll be more successful, and you mentioned funding, I mean the funding thing is crazy too, right, because that’s not an indication of actual success, as we’ve seen recently with Groupon and things like that, you know, getting funding isn’t an end in itself, right, it’s just another step along the way, and if you don’t have a business model or if you can’t turn a profit or if you don’t have a product then that’s not getting you any further than a good domain name is.

Patrick: Yeah, and one thing that you might throw out there is that if you have the money to pay developers and you have the money to get a great domain name, then it’s maybe better to have both instead of one. But if you have to choose one then you want to be careful where you invest it.

Louis: You know up to a point, I can understand if you’re starting a new venture that domain names you want aren’t necessarily available, right, or if somebody’s got them and you can get them for two or seven or even ten thousand dollars, if it’s part of a big business venture and you say this is the domain name, and I’m not expecting you to be able to start — I’m not saying that people can ‘I want to start a new website about whatever’ and the domain name is just gonna cost me the ten dollar registration, I don’t think that’s very common anymore because a lot of domain names are taken or squatted, right. So you might have to pay something for them, but it just seems to me like paying that much for them is kind of crazy. Again, part of it is coming from the perspective that I come from working at Flippa where we do a lot of sales of websites, established websites, and not a lot of sales of domains like Sedo, which is mentioned in this article, do more domain sales, but for us we’re seeing like when you’re looking at a website it’s all about traffic and links and even revenue, because these are real businesses, right, you’re buying something, not just a property, which is hard to quantify anything about other than it’s a dictionary word and it’s short and so it’s worth two million dollars, I don’t know, it baffles me. Clearly it doesn’t baffle people who have two million dollars, and maybe they’re smarter than me because that’s why they have two million dollars.

Patrick: I don’t know if that’s the case, but domain names do have value, I think, at the end of the day, so that it’s kind of like that — the address or the real estate of the Web, there’s value there, and there’s different examples, like I could say Flippa, for example, if you search websites for sale Flippa is number one right now, flippa.com/buy, and that’s a great place to be. Of course Flippa has the SitePoint –

Louis: The SitePoint bump.

Patrick: — party limited. Yeah, the SitePoint bump, but if you go to the third site there, Websites for Sales, plural, is the third site listed there. And the site that I go to is nothing particularly nice let me tell ya. So, there is something to be said for that, but I do agree with you, and, you know, I think it’s an interesting discussion, and also one thing I wanted to point out also was country code domain names, the most expensive country code domain names, so non-.com, .net, .org, specific countries, was at Aktein.de which is stocks in German, that sold for $725,000.00, and on the web development note, or at least the Web note, internet.co sold for $40,000.00, seo.in sold for $18,500.00, servers.eu and addserver.d sold for $18,000 and $17,940 respectively.

Louis: You know, of that I would have to say that seo.in sounds like that was a bargain, like it sounds like you would expect to pay more than $18,000 for that given the sort of explosion of SEO. So, in is India, right, I’m not getting that wrong?

Patrick: I believe that is the case, yeah.

Louis: Yeah, anyway, I think someone got a steal with that one, but, again, I don’t know anything because I don’t have two million dollars.

Patrick: I wish I had lots of money. I would have many beautiful domain names. With that said, I think it’s time to talk about spotlights, and I will go first with my patented offbeat spotlight, Patrick’s offbeat spotlight corner, a regular series here on the SitePoint Podcast.

Louis: Is Patricksoffbeatspotlight.com available? (Laughter)

Patrick: It might be.

Louis: Is that worth $18,000.00?

Patrick: I think it’s worth the registration fee; might not even be worth that. But, so my spotlight is a commercial from the Superbowl called Man’s Best Friend, it was part of Doritos Crash the Superbowl website where people can submit different commercials, this one was by Jonathan Friedman, and the description is: while working in his yard a man observes a crime being covered up, but the culprit has a unique way of keeping the two witnesses quiet, and I kind of don’t want to talk about it because it’s 30 seconds, so if I describe it it’s ruined, so just check out the link and enjoy the commercial.

Louis: Right. And the Superbowl is an American football competition, if I understand correctly.

Patrick: Yes, yes, and assuming — it’s inconsequential to what we’re discussing here. Now, the one thing is, though, I’m hoping that people beyond U.S. will be able to see the commercial. I can’t guarantee that for sure, but hopefully that is the case.

Louis: We’ll find out. Yep, I just tested it and it works here, so most likely it is available in all countries, or at least most countries.

Patrick: That’s what they say about Australia, right, if you can make it here you can make it anywhere, isn’t that Australia?

Louis: (Laughs) if you can see it here you can see it anywhere, that’s what they say about Australia on the Internet.

Patrick: There we go. Down to the last minute. Stephan, what do you got?

Stephan: I can go next. I’ve got this website called yourls, it’s y-o-u-r-l-s.org, and it’s a custom short URL creator, and it has a plugin for WordPress, so it’s a set of PHP scripts to create your own short URLs. I know we love those on this show, so I figured why not.

Louis: Yeah, I mean I think we have talked about this before, and it is definitely cool to be able to have your URL shortner on a server you control so you have it in your own database, and it also does click tracking and statistics like Bit.ly does, yeah, it looks really cool.

Stephan: Yeah, simple.

Patrick: Do you use this, Stephan?

Stephan: No, I don’t, I just found it today, so I thought it would be neat to share.

Patrick: Yeah, I’m familiar with it, I just haven’t made the decision of what I want to use, like, and if I want to even do it, because I have ifrog.gy, so ifroggy but i-f-r-o-g.gy, and I’m not sure if I want to put it on bit.ly or if I want to use this, or what; if anyone has a recommendation leave it in the comments.

Louis: What’s gy?

Stephan: I think it’s Guyana.

Patrick: That’s correct, Stephan, it is. Gee-yana, Guyana, something like that.

Louis: Was Guyana fairly easy to deal with registration.

Patrick: I paid via carrier pigeon.

Louis: Like some of them you have to fax something in, some of them you have to prove you’re a business.

Patrick: No, it’s a bad joke, but yeah, I mean it was a slow process, I had to register, like wait a month and wait for it to go through and them to email me, because the site that I registered through, 101domain.com, they’re a pretty well-known registrar, but I guess it was the actual person who manages the registry in that country that takes a long time, but once it’s set up and on the server I mean my assumption is that it should be okay, but that is part of my hesitation.

Louis: Yeah, a friend of mine was trying to register at .ie, a domain name, which is Ireland, and apparently they just said, no, that’s not a website devoted to an Irish business, like you really have to demonstrate that you’re making an Ireland-related website or you’re an Irish business.

Patrick: Yeah, yeah.

Louis: You can’t just use it as part of a word like people do with ly or gy in your case.

Patrick: Yeah, different countries have different restrictions as far as what you can do, and many of them do require you to at least maintain a presence in the country or in some cases even stricter than that.

Louis: I’d maintain a presence in Guyana, I could get a little beach house.

Patrick: (Laughs) I don’t know.

Kevin: Carrier pigeon.

Louis: Just for the domain name, of course.

Patrick: Yeah, I’m looking at the Wikipedia page for a list of Internet top-level domains, and like Finland requires you to be a company or organization registered in Finland, or be a Finnish national, Guinea requires a local contact, so, yeah, it seems like — I don’t know how common that is or how restricted they are, but in some cases it definitely is the case. I mean they make less money, but I guess they maintain a more, how do I want to put this, pure domain pool, I don’t know.

Louis: Yeah.

Patrick: Kevin! What do you got?

Kevin: I have an excellent article on SSH, since SSH is super exciting.

Patrick: Yay.

Louis: I’m really excited by SSH, I don’t know about anyone else, but I didn’t even take that sarcastically. (Laughter)

Kevin: It actually is a very cool thing, in fact, it can be more cool for you if you’re using it for just secure — connecting to your server securely, connecting to a server; you can use it for a lot more, and this article covers just that, and so they cover why you should use SSH, and then also maybe executing remote commands, copying files, you know, so there’s a lot of really cool stuff in here you need to check out if you use SSH. I use SSH for everything; I use it to connect MySQL databases, I use it to — I mean if it has to do with a server I use SSH, and I think this is an excellent article on the topic.

Louis: Yeah, I spend pretty much ten hours a day everyday shuffling through SSH because I develop on a virtual machine and I SSH to the terminal.

Patrick: Ouch!

Louis: Any little tips and tricks I definitely appreciate. Speaking of tips and tricks, see segue, man, we’re all about segues this week; my spotlight is a series of screencasts created by a guy called Gary Bernhardt, and they are called Destroy All Software. So, he bills it as screencasts for serious developers, they are not free, they’re a nine dollar a month subscription, but they’re great, we’ve collectively bought a subscription here at Flippa for our dev team, and I’ve been powering through them in the last couple of days, and they’re really good. So they’re kind of more advanced developer topics, so either UNIX command line stuff, test driven development, a lot of stuff about VIM and using VIM effectively, and Git for version control. The bits that are about development and software tend to focus on Ruby, but there are little tidbits and design patterns sort of useful in any language. But it’s one of those things where you’re watching them, and they’re very, very dense, he does a lot of stuff in 10 to 15 minutes per screencast, but just being blown away by how fast and how effective the guy is using his tools and understanding the code that he’s writing, and it really gives you a good insight into the stuff. So if you use any of these tools I recommend checking it out, there’s one of them that is available for free as a demo, and it is the one about avoiding nil or nul values in your code, why that’s important and how to do it, so I’ll put a link to the one that’s free as well in the show notes.

Kevin: Interesting. See now you have me excited.

Louis: Awesome (laughs).

Kevin: It’s a good trade, it’s a good trade.

Louis: That’s what we aim for. Alright, so that wraps it up for this week, and let’s just go around the table.

Kevin: I’m Kevin Dees and you can find me at kevindees.cc, and on Twitter as @kevindees.

Patrick: I’m Patrick O’Keefe for the iFroggy Network; I blog at managingcommunities.com, on Twitter @ifroggy, i-f-r-o-g-g-y.

Stephan: I’m Stephan Segraves, you can find me on Twitter @ssegraves, and I blog at badice.com.

Louis: And you can follow SitePoint on Twitter @sitepointdotcom, that’s sitepointd-o-t-c-o-m, you can email us at podcast@sitepoint.com, and course you can go to sitepoint.com/podcast to find all of our show, subscribe to the RSS, leave a comment, anything you want to do with the podcast will be at sitepoint.com/podcast. Thanks for listening, next week I hope to have maybe a little mini-panel of interviewees talking about the whole vendor prefix kerfuffle, so tune in next week; we should have a great show of some experts being able to comment on that.

Theme music by Mike Mella.

Thanks for listening! Feel free to let us know how we’re doing, or to continue the discussion, using the comments field below.

GA_googleFillSlot("Edit_300x100_C"); GA_googleFillSlot("Edit_300x100_D");
Categories: Web Development

BuildMobile: Twitter in iOS, GTA III, Mobile Analytics, and More

SitePoint - Fri, 02/17/2012 - 15:00

Designing Responsively: Fundamental Practices

You might already know of responsive design, mobile-first approach, and graceful degradation techniques to build widely accessible websites and web apps. In this post, I focus on the mobile-first aspect of design, and beyond this will highlight some techniques that could also enhance the desktop version of your site.

Authorizing Twitter in iOS

iOS5 provides an API for securing authorisation details centrally and providing access to them to any application that wants it. This means that users only have one place to go if they wish to de-authorise or modify account details. Neat.

GTA III: 10 Year Anniversary Edition

Rockstar Games released a port of Grand Theft Auto III for iOS and select Android devices in celebration of the game’s 10th anniversary. So, does the epic Liberty City saga of violence and revenge translate to mobile devices?

Software Testing: A History

Software testing now enjoys a level of acceptance that was not always there. In the early days of software development, debugging was the primary form of software test. It was primarily performed by the programmer who wrote the code and the object was to get the application to working without crashing the system. GA_googleFillSlot("InArticle_728x90_1");

Supercharge Your Twitter Experience with UberSocial

Google Analytics Tracking for Mobile Sites

Mobile sites are becoming extremely popular with businesses today. You could even argue that it’s catching up to Social Media’s popularity. This tutorial is going to show how to make sure your new jQuery Mobile site is performing properly, and getting the results you want.

GA_googleFillSlot("Edit_300x100_C"); GA_googleFillSlot("Edit_300x100_D");
Categories: Web Development

How to Upload Files with Ease Using DragonFly: New on Premium

Nettuts - Thu, 02/16/2012 - 17:39
File uploads are generally a tricky area in web development. In this Tuts+ Premium tutorial, we will learn how to use Dragonfly, a powerful Ruby gem that makes it easy and efficient to add any kind of upload functionality to a Rails project. Become a Premium member to read this tutorial, as well as hundreds [...]
Categories: Web Development

DesignFestival: CSS Menus, Multiple Backgrounds, and More

SitePoint - Thu, 02/16/2012 - 14:20

Create a Reusable CSS Menu with Photoshop

Your site’s menu system should reflect the style of your site. You can choose smaller, subtler sizes and fonts, or you can scale up to big spaces and matching typefaces. In this tutorial, we are going to create a more subtle, more sophisticated look.

Using Multiple Backgrounds for Flexibility in Web Design

It’s a tricky task to design an image-based background that stretches and shrinks to accommodate different browser sizes. But with a little CSS know-how, you can create a sharp, scalable background that fits both small and large pages without compromising your design.

The Best jQuery Plugins for Typography

For those graphic designers taking advantage of jQuery to enhance their sites, this collection of plugins is dedicated specifically to typography enhancing tools.

How to Create a Flashy Menu Using CSS

You don’t need plugins or heavy image files to create a dynamic, intuitive menu, and Rupesh has updated this great tutorial to include added support for Internet Explorer transforms. Make sure you read it to keep up to date with vendor prefixes! GA_googleFillSlot("InArticle_728x90_1");

What was the first website you designed?

We have an old, classic design buried in the back of our hard drive or hidden in some cobweb-ridden corner of the web. Share yours, and take a look at how far we’ve all come from our first website.

GA_googleFillSlot("Edit_300x100_C"); GA_googleFillSlot("Edit_300x100_D");
Categories: Web Development

How to Customize Your Command Prompt

Nettuts - Thu, 02/16/2012 - 09:47
Lately, I’ve been getting this question a lot: “how did you get your terminal to look the way it does?” If you’ve noticed my terminal and are curious about how I set it up, this is the tutorial for you! Of course, what you learn here will be enough to get you started on creating [...]
Categories: Web Development

How to Create a CSS3-Only Vertical Accordion Using the :target Selector

SitePoint - Thu, 02/16/2012 - 08:18

We recently created a CSS3-Only tab control which used the powerful :target selector. One of the major benefits of CSS is that we can restyle HTML how we like; so we’re going to transform our mark-up into a vertical accordion.

View the demonstration page…

The solution works in IE9, Chrome, Firefox, Safari and Opera and doesn’t require JavaScript or images. It fails miserably in IE6, 7 and 8 so you could either use the selectivizr shim or hide the widget from those users and tell them to upgrade.

The HTML

Our HTML5 code is identical to that used by the tab control. I’ve only changed the article class to “accordion” and renamed some of the IDs so it’s easier to understand what’s going on. There are also five sections since it looks a little better:

<article class="accordion"> <section id="acc1"> <h2><a href="#acc1">Title One</a></h2> <p>This content appears on page 1.</p> </section> <section id="acc2"> <h2><a href="#acc2">Title Two</a></h2> <p>This content appears on page 2.</p> </section> <section id="acc3"> <h2><a href="#acc3">Title Three</a></h2> <p>This content appears on page 3.</p> </section> <section id="acc4"> <h2><a href="#acc4">Title Four</a></h2> <p>This content appears on page 4.</p> </section> <section id="acc5"> <h2><a href="#acc5">Title Five</a></h2> <p>This content appears on page 5.</p> </section> </article>

As before, the clickable section heading is contained within each section as the initial h2 tag. GA_googleFillSlot("InArticle_728x90_1");

The CSS

First, we’ll style the article container and section elements. Each section starts in its closed state with a height of 2em (note that overflow is set to hidden):

article.accordion { display: block; width: 30em; padding: 0.5em 0.5em 1px 0.5em; margin: 0 auto; background-color: #666; border-radius: 5px; box-shadow: 0 3px 3px rgba(0,0,0,0.3); } article.accordion section { display: block; width: 28em; height: 2em; padding: 0 1em; margin: 0 0 0.5em 0; color: #333; background-color: #333; overflow: hidden; border-radius: 3px; }

The section title is now styled to use all the available room in the closed state:

article.accordion section h2 { font-size: 1em; font-weight: bold; width: 100%; line-height: 2em; padding: 0; margin: 0; color: #ddd; } article.accordion section h2 a { display: block; width: 100%; line-height: 2em; text-decoration: none; color: inherit; outline: 0 none; }

We can now ‘open’ the active section using the :target selector. We set a larger height and background color, then enlarge and re-color the title too:

article.accordion section:target { height: 15em; background-color: #fff; } article.accordion section:target h2 { font-size: 1.6em; color: #333; }

If necessary, you can set the section height to auto so it uses the minimum space it requires. However, that makes it impossible to add nice CSS3 transitions which smoothly resizes the element…

article.accordion section, article.accordion section h2 { -webkit-transition: all 1s ease; -moz-transition: all 1s ease; -ms-transition: all 1s ease; -o-transition: all 1s ease; transition: all 1s ease; }

View the demonstration page…

If anything, this CSS is simpler than the tab control and looks better. But vertical accordions are easy — horizontal ones are far cooler! Stay tuned to SitePoint for more :target code soon…

GA_googleFillSlot("Edit_300x100_C"); GA_googleFillSlot("Edit_300x100_D");
Categories: Web Development

MySQL Master-Slave Replication: Setting Up

SitePoint - Wed, 02/15/2012 - 08:05

Very recently, at Fraudpointer.com, having reached a database of 25Gb after just six months of operation, we decided to start using replication for our backend persistent storage.

Why would you want to do that

Replication of MySQL can be a solution to various problems that you might want to solve:

  • Scale-out solutions
  • Data security
  • Analytics
  • Long-distance data distribution
  • Backup taken from slaves, rather than from master

MySQL documentation on replication, that can be found here, is quite explanatory and gives more detail about these uses.

Where have we been?

Before implementing replication, we had a configuration such as the following:

We had a debian squeeze machine (name: Plato) with MySQL 5.1. installed and serving all of Fraudpointer traffic. When we decided to implement replication it was already 25Gb. A lot of transactions took place per minute, and we were facing two major problems. GA_googleFillSlot("InArticle_728x90_1");

1)    We wanted to take daily backups and backup put a lot of load on the machine. Though the backup utility that we used (Percona xtrabackup) didn’t lock the database, the machine was getting quite unresponsive during backup time.

2)   We wanted to run heavy queries and get reports, very frequently. Just this was a good reason to start discussing replication.

Where are we after replication?

After MySQL replication, we are now in the following picture:

We now have two machines with MySQL installed. The old one, Plato, is now acting as the Master and the new one, Ares, is now acting as the Slave of the replication scheme. In our setup, the advantages of this configuration are as follows:

1)    We can get the daily backups from the Slave. No load on the production Master machine for this task.

2)   We can get our reports from the Slave node.

3)   If the Slave node is down, this is not a problem at all. Replication is performed asynchronously and when the Slave node is up and live after a downtime, it continues replication from the point it has been paused.

4)   Records that are created or updated at Master machine, are almost instantly “transferred” to Slave machine (even if asynchronously).

How did we do that?

Here is the process that we followed to carry out the replication:

Assumptions
  1. Both Master and Slave are debian squeeze machines.
  2. Master has static IP: 10.100.10.80.
  3. Slave has static IP: 10.100.10.103.
  4. Master and Slave are on the same LAN.
  5. Master has MySQL installed and you have the root password to connect to it from ‘localhost’. MySQL does not allow remote connections by default, and that was our case too.
  6. Slave does not have MySQL installed yet.
  7. Master debian allows incoming connections on 3306 port, the standard MySQL listening port.
PHASE 1Overview

In the first phase of the work, the overview of what we did is as follows:

1)    On Master

  1. Allow remote connections
  2. Set bind-address
  3. Enable binary logging
  4. Establish a unique server ID
  5. Restart server
  6. Create a user for replication

2)   On Slave

  1. Install MySQL
  2. Stop MySQL
  3. Set bind-address
  4. Enable binary logging
  5. Set unique server ID
Detailed ActionsOn Master

1)    Allow remote connections

Since you are about to change the bind address on your MySQL server, you are essentially allowing access to your MySQL server from “remote” machines. If you do not do that, after the change of the bind address and restarting of your MySQL server, users from remote or local machines will not be able to connect to your server. All the remote and local machine IPs need to be granted access for the users that access MySQL from these machines.

The following mysql commands (which can be issued using mysql shell)

mysql> grant all on *.* to bar@’10.100.10.55’ identified by ‘bar_password’; mysql> flush privileges;

allow the user ‘bar’ to connect to this MySQL server and to all databases from the machine with IP ’10.100.10.55’. This is necessary even if the user connects from the machine that MySQL server is installed.

Hence, connect to your MySQL server using mysql and set these commands accordingly before proceeding to the following.  Don’t forget that this is true for the ‘root’ user too, even if he connects from the local machine.

2)   Set bind-address to the IP of the machine.

This is done inside the my.cnf file. bind-address is a configuration parameter of the section [mysqld]. Set it to the IP of your Master machine. In our case, it was 10.100.10.80. Note that if you have enabled skip-networking you need to disable it.

3)   Set binary log file pattern

The parameter is called log_bin and it should exist in the [mysqld] section. Note that the full path to the binary log file should be given. Example: /var/log/mysql/mysql-bin.log.

Important gotcha: make sure that the folder/disk has enough space to write the binary logs there.

4)   Set server id

This is the Master replication server ID. It has to be unique among all the ids used in the whole replication setup. For example, set this to “100” and make sure that you set “101” on your Slave (see later).

The parameter is server-id and should be set in the section [mysqld].

5)   innodb_flush_log_at_trx_commit and sync_binlog

These should be set to “1”, both of them. According to MySQL documentation for the greatest possible durability and consistency in a replication setup using InnoDB with transactions … you have to do this. More on this you can find here.

These parameters are set in section [mysqld].

6)   RESTART MySQL Server

Having done all the necessary changes on the configuration file of MySQL Server and having granted access to all existing users to be able to connect using their IP, you can restart your MySQL Server.

7)   Create user for replication

You need to create a user that will have the right to work as the replication/slave client. The following commands:

mysql> create user ‘repl’@’10.100.10.103’ identified by ‘slavepassword’; mysql> grant all on *.* to ‘repl’@’10.100.10.103’; mysql> flush privileges;

are creating the user ‘repl’ and give him the right to do replication from the slave machine with IP 10.100.10.103 using the specified password.

On Slave

1)    Install MySQL Server

On Slave machine you need to install MySQL Server.

2)   Stop MySQL server

You do not need to have it running, for the time being. Proceed with changing MySQL configuration parameters to support Slave replication.

3)   bind-address

Set bind-address to the value of the IP of your Slave machine. In our case was 10.100.100.103. The parameter should be set in the [mysqld] section.

4)   log_bin

Set the full path to the binary log file. For example: /var/mysql/log/mysql-bin.log. The parameter is set in the [mysqld] section of the my.cnf file.

Important gotcha:: make sure that your binary log folder has lots of space. You will need it.

5)   server-id

You need to give the server ID for the Slave node for this replication setup. Put for example “101”. It has to be different from the server IDs of the Master and other Slave nodes in your configuration.

Do not start Slave MySQL server. You still do not need to do that.

You are done for now. Phase 1 is finished.

In Phase 2, we will start replication.

GA_googleFillSlot("Edit_300x100_C"); GA_googleFillSlot("Edit_300x100_D");
Categories: Web Development

Building a High Performance Website

SitePoint - Wed, 02/15/2012 - 08:00

Building a fast website is hard.

Leading an initiative to improve site performance is even harder.

With the numerous techniques that can be used to increase site speed, project managers are constantly struggling with both technical and project management questions. Do you focus on front end or back end optimization? What do you need to find out from your web development team before developing a strategy to improve website performance? Which optimizations should be done manually, and which should be done automatically through site performance services?

Having the best possible answers to these questions is absolutely crucial to the overall success of any initiative to improve website performance. Before choosing techniques that will increase site speed, project managers must first have a solid grasp of factors that affect website performance, and analyze how these factors are affecting the site in question. This, coupled with an understanding of available site optimization techniques, will help project managers make the most well informed site performance decisions.

Front End vs. Back End

There are the behind the scenes choices that your in-house or contracted website developer may invisibly create for you that will affect how easy or difficult it will be to improve your website performance and optimizations in the long run. Furthermore, these “dark” decisions can be broken down into two distinct categories: front-end choices and back-end choices. GA_googleFillSlot("InArticle_728x90_1");

The front-end choices (and there are many choices to make here!) impact how your website is assembled when it reaches the end user by the browser that they are using to visit your site.

The back-end choices tend to be more rigid and inflexible than the front-end choice. These choices relate to decisions regarding how you host and maintain your website in addition to the same choices made by the many different 3rd party providers that are commonly integrated into a modern website (think social networking and advertising widgets).

You should become intimately aware of four specific metrics, because the solutions and techniques that you can apply from these metrics impact both the front-end and back-end choices.

Time to first byte

This is actually the combination of two separate measures: the time to find (which has its own internal time to connect costs) and the time to connect to your webpage. This occurs for every resource that your webpage needs in order to function properly.

A service called the domain name service (DNS) is at the “lowest” level of the network stack that delivers the modern Internet as we know it. Without DNS, a device would not be able to find the resources needed to assemble your website. All DNS services are not equal. Every device (and browser on the device) may have different policies in place that impact where it gets its DNS information and how long it saves (caches) that information.

DNS resolution is amortized across many resource requests. It is frequently amortized across multiple browser sessions and even browser instances (e.g. Firefox versus Chrome or IE).

The other time to connect is how long it takes to establish the HTTP connection to the backend servers (yours and those 3rd party assets your site depends on). This is often a more expensive operation than DNS because it is inherently more complicated and subject to longer “code paths”.

Backend decisions impact how much work must be done to satisfy the request once a connection is established. Serving static resources (e.g. scripts, style sheets and images) are often significantly faster than executing code that applies a template and substitutes user-specific resources. C’est la vie.

Time to title

The time to title is the first indication to the end user that his or her browser has performed DNS lookups, connected to the primary domain, and that your web server has delivered the first resource (the HTML document) that defines the webpage.

The time to title records how long it took from initial request to updating the title bar in the browser with the page name. Many users may not notice this change. However, it does happen and it’s a very important data point.

Getting to this point is just the beginning of a very long chain of actions that are automated by your users browser.

The average website in 2011 has fewer than 50 resources (images, javascript files, CSS files, etc). The browser will parse (analyze) the HTML document and build a mini computer program that it must execute in order to obtain all of the other resources that your webpage says must be present. Unfortunately, the current standards for the web don’t have the notion that a resource is optional and can be ignored if it’s difficult or costly to obtain it.

The 49 other resources will be requested and processed immediately after the title is updated.

Time to display

This is the point when your website MAY be usable. Simply put, this is the point at which the browser has started to render. Render is the fancy word that engineers use to describe the process of applying all of the specified style sheets and inline styles to the text, graphic resources, and HTML layout markup.

Time to display became more complicated because some browsers (particularly for mobile devices) adopted many techniques to “optimize” the layout for small screens. This takes time and each device maker is capable of applying different rules and heuristics.

If your site is text heavy, the time to display is typically that point at which your users can actually start reading the page.

If your site is graphics heavy, the time to display is typically that point at which your users start to see the layout … but the graphics may take time to render because of advanced imaging tricks such as progressive rendering.

Time to interactivity

This is the point when your website is fully interactive. The simplest way to tell the difference between “display” and “interactive” is to find a website that won’t allow you to scroll while it’s loading.

I’m from Boston and here, we are big sports fans. So a local newspaper’s sports page is a good example. These are highly templatized pages — the content and the advertisements change frequently — but the overall structure does not.

My favorite (worst) site for this is the Boston Herald (sorry, guys). This is a site that often loads quickly when I click on the latest story about Tom Brady and I can usually read the first two paragraphs that are “above the fold”. However, I can’t scroll down. Why? Because the site pages used synchronous advertisements that are being downloaded after the time to display but before full interactivity. I can’t tell you how many times I’ve found myself “stuck” and mildly frustrated by this behavior.

Managing Your Team

In order to bridge the gap between the delivery teams and the marketing and business teams — and accelerate the planning and implementation process — it’s best to have some common ground.

Asking the following are 10 questions will greatly help determine which website performance techniques to use moving forward:

  1. Do we have compression turned on?
  2. How many resource requests do we make
  3. How many 3rd party assets do we have?
  4. What will happen to our site if a 3rd party widget becomes inaccessible or very slow?
  5. Have we sized our images to decrease their size?
  6. Have we encoded our images to allow progressive rendering?
  7. Does our host provide optimization services?
  8. Are we using a backend template system? If so, are we targeting mobile devices?
  9. Are we doing any asynchronous javascript requests?
  10. Have we combined and minimized our javascript files?
StrategyEstablish a Baseline

Before embarking on the performance and optimization process, it’s critical to get a baseline in place so you can measure success and understand return on investment. It may seem unnecessary or unduly complicated. However, without this, you’ll never be able to answer the simplest questions that your boss will eventually ask you:

  • How much faster is our site?
  • How much did it cost us to get here?
  • How much will it cost us to maintain going forward?

One approach: you might deploy two distinct versions of the site on separate domains. For example, a sub-domain (e.g. old.domain.com is perfectly fine) could contain a copy of your website before optimizations are performed. To get apples to apples comparison you’d want to host on equivalent hardware.

The other critical and implicit point of establishing a baseline: you are actually measuring and learning about changes over time. Failure to measure when there are so many tools and services available will be punished … by the lack of users who will eventually abandon your site because of its poor performance.

Manual vs. Automated Optimization

If you have a template system with highly dynamic content, you might want to look into optimizing the template system. This may require some special purpose contracting but the return on investment will be amortized across the thousands or millions of times the template system is used (for every page requested).

If you have an internal team and/or the resources and budget, first get the team up to speed on the state of the art. Buy them a copy of Steve Souder’s book High Performance Websites. Give the team a few days to read the book and do all of the exercises.

If you’re running an agile shop, you can make the training a two- or three-point story. Acceptance will be demonstrating a local copy of the many samples provided in the book.

If you have a graphics heavy website, you need to find a way to ensure that you’re delivering graphics at the best scale and quality. Delivering graphics at full resolution and full scale is a speed killer. If you’re a photo site, you deal with this automatically as part of the upload process.

If you’re a catalog site, you may simply be dumping high-res images into a database that are dynamically assembled on demand by the template system. This will require planning some development stories to create an automated process that defines and creates semi-automated tasks to transform images by the min, max, and preferred resolution to validate that the database is not polluted with high res images on a periodic basis.

Deferring loading of resources is easy to do, but requires an acute understanding of the site’s workflow.

For example, if you have a website that may allow interactive chat with a customer support rep to occur, you’ve got an embedded chat system and often dozens of images that could be used for emoticons.

There is no good reason to load dozens of resources a new user may not even use during his or her first visit to the site. There are numerous tricks to execute the deferred load.

Extract the markup defining the resources into a separate HTML file and on a one-time basis load that markup with an AJAX call and side-affect the DOM. Another option is to load those resources in defer loaded, hidden iframe. Regardless of the technique adopted, it requires some javascript programming to pull it off.

CSS spriting is a very powerful resource “reduction” technique. Simply put, CSS spriting refers to the technique that combines images into a bigger image that is loaded once and used many different times in many different ways.

Every time you remove a resource request to your backend servers, it directly increases the speed of the webpage. This action improves the user experience and improves the scalability and throughput of your backend systems.

Third party assets are the hardest to deal with in many ways. You want your site to be modern and connected to social media but you are completely under their control once you do this. These widgets are trivial to integrate into the markup using a technique called script injection. Google has used this same technique for over 10 years with “ad injection.”

If these injectable scripts are loaded synchronously (and they invariably are), it can lead to complete page load failure. This happens because each script is side-affecting the global state of the javascript engine for the HTML document that attaches to these scripts.

The simplest way to think about this is that an HTML page is actually a software program no different in many ways than the C and C++ code that was used to implement the browser. The browser is a software program that executes other programs. Modern browsers isolate each of the programs that they are executing in order to ensure that one bad program doesn’t impact the performance of another program. However, one key aspect of executing the HTML program is that order matters. Since order matters, the browser must wait until a script injection completes before executing the next one. A browser may load the to-be-executed script in the background, but it must wait until the previous script fully loads (or fails to load) before moving down the sequence.

Doing the extra work to manually (and asynchronously) side-affect can have dramatic benefits in terms of time to display and time to interactivity. However, it does require special purpose programming skills and can become brittle over time. Invest carefully and wisely.

One trick we use is to provide the image of the widget as “scaffolding,”  and to dynamically inject the final rendering asynchronously.

This is the technique that AJAX oriented advertising is adopting, using iframes and advanced CSS ordering tricks to load advertisements in the background and swap them in ONLY after they successfully loaded. These are all variations on the JSONP protocol (http://en.wikipedia.org/wiki/JSONP).

JSONP and related techniques are critical in the manual optimization and dynamic, asynchronous rendering space. Make sure your team is familiar with these approaches and applies them to your website.

Automated Optimization

Many of the above optimizations can be dynamically performed with no code change to your site.

How can this be? And why would you do it this way?

Obviously, this is an ideal scenario: you don’t have to manually modify your site; you don’t have to become an expert on DNS and CDN providers; you don’t have to manually code your site to deal with a particular CDN; you don’t have to turn external resources into inline data; you don’t have to combine images into sprites; and you don’t have to manually analyze your image resolution and create alternative size and resolution images.

The reason automated optimization can be delivered as a service is because of the very nature of an HTML “program”. The HTML document resources are sequential blocks of programming data (and code). Your browser must retrieve and assemble these blocks. Furthermore, your browser works less, consumes less bandwidth, and introduces less points of failure when 50 resources are turned into 20 resources to deliver the same “data + code” that needs to be parsed and executed.

Of course, as always, there is a trade-off to be considered here. The trade-off is between getting the latest and greatest performance tricks automatically applied to your site … and the speed at which your team can do this manually for every page on your site.

If you have outsourced website development and aren’t running your own infrastructure (backend-servers), you may have limited options available to you because your website hosting service may disable compression on the common entry level plans. They do this because compression requires backend computation and backend computation is a shared resource across many other sites hosted on the same machine.

The simple option here is to upgrade to a more expensive hosting plan. Ask your hosting provider for help here.

If you use a complete virtual machine or dedicated server, you still may have compression turned off because it is typically disabled by default. You may not have access to the configuration files. Again, ask your hosted for help here.

Helpful Resources

The techniques for building a high-performing website are well known and there are many books and free tools available to help you understand this:

GA_googleFillSlot("Edit_300x100_C"); GA_googleFillSlot("Edit_300x100_D");
Categories: Web Development

Student to Freelancer? Don’t Do It!

SitePoint - Wed, 02/15/2012 - 07:37

I know. I’m the author of a motivating book on successful freelancing (The Principles of Successful Freelancing, SitePoint), so why would I write a title like that?

The truth is I sucked at being a freelancer the first time. To be honest, I wasn’t much better the second time either. The reason? I didn’t have enough business experience under my belt.

Cast your mind back to the mid-nineties (no, we didn’t wear flares!). I had been working in a totally unrelated industry when I started to design and build websites in my spare time (yes, the days of table-based layouts and Perl programming).

I was great at what I did: I had a design degree, clients loved me, I was a quick learner with HTML and it didn’t take me long to learn how to manage a Linux server with Apache.

Before you knew it, I had enough work on the horizon to ditch my full time employment and start creating websites full time. It was great: flexible hours, interesting projects, working in the comfort of my own home and I felt like I was finally doing what I really loved. GA_googleFillSlot("InArticle_728x90_1");

The issue was, I wasn’t doing what I didn’t enjoy. You know: finances, invoicing, contracts, legal and administration. I lasted many months before I admitted to myself that I wasn’t charging enough, I was sending out invoices way too late, and I wasn’t aggressive in chasing them. My cash flow was all over the place, and I had trouble making ends meet.

It was obvious to me that when I started freelancing, I focused on what I was good at, and what I enjoyed doing, to the detriment of my finances and my business.

It didn’t take long for me to start applying for jobs within other companies once I had come to this realization. Sure, I didn’t get to work from home any more, but I was still doing what I enjoyed, and even more importantly, I was learning about everything else while I went, with someone else paying me to do it.

It wasn’t until I had worked in a senior role at a few other companies that I felt confident I had enough skills in enough areas–mostly areas I didn’t know much about the first time–to succeed as a freelancer.

If you are finishing college and thinking of becoming a freelancer full time, my advice is don’t. Sure, take on the occasional weekend project (with your employer’s permission, of course), but land yourself a job that will help you skill up in the areas you aren’t as good at.

Embrace that opportunity and learn everything about as many other roles in your employer’s company as you possibly can. Offer to go on sales calls, help scope new projects, even do the filing between other more exciting tasks.

Before too long, invoicing, sales, chasing debtors and balancing the books won’t be as daunting, and dare I say it, nor as boring as you once thought. Once you have a more rounded skill set, and probably a greater desire than ever to freelance, you can be be confident in stepping out there and doing it.

Best of luck making that well informed leap!

GA_googleFillSlot("Edit_300x100_C"); GA_googleFillSlot("Edit_300x100_D");
Categories: Web Development

Is Your PHP Behind the Curve?

SitePoint - Wed, 02/15/2012 - 00:56

Using Traits in PHP 5.4

Less code duplication, more code reuse is a goal of OOP, but sometimes it can be difficult with PHP’s single inheritance model. Traits offer a workaround to horizontally reuse code across different class hierarchies. They’re new in PHP 5.4 so learn about them today!

Tracking Upload Progress with PHP and JavaScript

A problem that has plagued web developers for years is how to add real-time information to their applications, such as a progress bar for file uploads. Learn how a new feature in PHP 5.4 can be used to create a dynamic upload progress bar without any external libraries or browser dependencies.

Where on Earth are you?

Modern geolocation applications use latitude and longitude to identify the location of people and places to within a few meters – but it’s highly unlikely you’ll answer the question “Where on Earth are you?”. Learn how to use the Yahoo! Placemaker server and write a simple program to ask users where they are before identifying their location in concrete terms. GA_googleFillSlot("InArticle_728x90_1");

Autoloading in PHP and the PSR-0 Standard

Including a slew of extra files at the top of your scripts can be a drag! Learn about the “history of autoloading” and the current PSR-0 standard used in many PHP frameworks such as Lithium, Symfony, and Zend, that makes lengthy include lists a thing of the past.

Under the Hood of Yii’s Component Architecture Part 2

This is Part 2 of the 3-part series that shows you some of the inner-workings of the Yii Framework’s component architecture. In this installment you’ll learn how you can do event-based programming in PHP and how Yii’s CComponent class helps facilitate it.

GA_googleFillSlot("Edit_300x100_C"); GA_googleFillSlot("Edit_300x100_D");
Categories: Web Development