<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
> <channel><title>SitePoint » Learn CSS &#124; HTML5 &#124; JavaScript &#124; Wordpress &#124; Tutorials-Web Development &#124; Reference &#124; Books and More &#187; Web Tech</title> <atom:link href="http://www.sitepoint.com/category/tech/webtech/feed/" rel="self" type="application/rss+xml" /><link>http://www.sitepoint.com</link> <description></description> <lastBuildDate>Sun, 27 May 2012 15:59:16 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" /> <item><title>HTML5 and the Future of Online Games</title><link>http://www.sitepoint.com/html5-and-the-future-of-online-games/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=html5-and-the-future-of-online-games</link> <comments>http://www.sitepoint.com/html5-and-the-future-of-online-games/#comments</comments> <pubDate>Fri, 25 May 2012 17:30:00 +0000</pubDate> <dc:creator>Jarred Draney</dc:creator> <category><![CDATA[Web Tech]]></category> <guid
isPermaLink="false">http://www.sitepoint.com/?p=54549</guid> <description><![CDATA[The Golden Child: Flash Games For several years now Adobe Flash has been the dominate technology used to create online games. It is so popular in fact that the term &#8220;flash games&#8221; has almost become synonymous with browser based games in general. Take a look at all of the major gaming portals; with a few [...]]]></description> <content:encoded><![CDATA[<p></p><h2>The Golden Child: Flash Games</h2><p>For several years now Adobe Flash has been the dominate technology used to create online games. It is so popular in fact that the term &#8220;flash games&#8221; has almost become synonymous with browser based games in general. Take a look at all of the major gaming portals; with a few exceptions, practically all of the games they offer are flash games.</p><p>What&#8217;s so wrong with Flash you ask? Well nothing really. It was an amazing technology that was used to add all sorts of functionality to browsers. Through the use of a plug-in developers could now include all sorts of interactivity and animated graphics to their web pages. However things are changing, and Flash may no longer be the best fit for many online applications.</p><p>Browsers are a lot smarter now and they are only going to continue to get smarter. Rather than relying upon plug-ins to display interactive and graphically intense pages modern browsers can do it all by themselves. Utilizing the W3C, the specification for HTML5, browser makers are including all sorts of functionality into their products<br
/> that web developers can now use to make graphically intensive and interactive websites. This has special  implications for online game designers. Soon (hopefully) designers will no longer be forced to choose from a select few proprietary technologies that not only are expensive, but also obligate their end users to download, install, and regularly update the respective plug-ins.<div
id='div-gpt-ad-1328644474660-10' style='width:728px; height:90px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1328644474660-10'); });</script> </div></p><h2>The New Kid on the Block: HTML5 Games</h2><p>Traditionally the role of HTML has been used primarily to define and layout the text on web pages. Over the years, however, its role has slowly evolved to be more interactive. The new HTML5 spec furthers this evolution by including definitions for several additional elements aimed at interactivity, multimedia, and graphics. Combine<br
/> these new HTML5 elements with the faster and enhanced JavaScript engines available in modern browsers and you now have a set of tools perfectly suited for online game development.</p><h2>Some advantages of HTML5 for Games</h2><p>Not only are the HTML5 technologies well suited for creating browser based games, they offer several advantages over proprietary options. HTML5 is an open technology. It doesn’t cost anything and technically only requires a simple text editor to code in. Never underestimate the power of free. Flash and other proprietary technologies all cost the developer. While this certainly isn’t the only factor that a game developer would consider, it certainly does play a role, and for the small time indie developer it might be a very big factor. Compatibility is another huge advantage HTML5 has. HTML is the lowest common denominator for all web based devices. By using HTML5 you can target a wider array of devices and gadgets without having to specifically port your game to each different platform. Another often forgotten advantage is ease of use. For the technically savvy, downloading, installing, and updating plug-ins is only a minor hassle. However, for less technically savvy users this can be quite a hurdle and just may turn away users altogether.</p><h2>Some Interesting Charts</h2><p>Above you will find some charts from Google Trends for the search term &#8220;flash games&#8221; and then also the term &#8220;html5 games&#8221;.  It is easy to see that searches for &#8220;flash games&#8221; have been in steady decline for over the past 5 years while searches for HTML5 games have seen some pretty impressive growth in the past 3 years. While this really doesn’t prove anything, it is an interesting metric to help gauge the popularity trends of the two different technologies. It is important to note that these charts show only relative search volume and not overall volume. Per the Google Adwords tool, the monthly global search volume for &#8220;flash games&#8221; is 11,100,000 compared to a measly 49,500 for &#8220;html5 games&#8221;.</p><h2>The Future of online Games</h2><p>Will HTML5 be the end of plug-in based games? If it is, it is pretty safe to say that it won&#8217;t be happening anytime soon. It is estimated that the HTML5 spec will not be fully implemented until 2022. Despite this long time-frame, browser makers are already racing to include all the HTML5 functionality that they can. Game developers have taken advantage of this and created numerous quality games that easily compete with their flash counterparts. Take a look at all these <a
href='http://html5gamer.net '>HTML5 games</a> to see some excellent<br
/> examples of what is already possible with the new technology.</p><p>Given the current search trends and the several advantages HTML5 has over Flash, the future for HTML5 games looks bright. While it is not certain if HTML5 will eventually win out to become the gaming technology of choice, one thing is for certain: the love of online casual gaming has captured the interest of millions and as long as<br
/> that interest exists developers will continue to create fun and exciting games.</p> <span
id="pty_trigger"></span><div
style='padding:20px 0px 50px 0px;'><div
style='float:left;padding-left:40px;'><div
id='div-gpt-ad-1335489406190-0' style='width:300px; height:100px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1335489406190-0'); });</script> </div></div><div
style='float:right;padding-right:40px;'><div
id='div-gpt-ad-1335489406190-1' style='width:300px; height:100px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1335489406190-1'); });</script> </div></div><div
style='clear:both'></div></div><div
style='clear:both'></div>]]></content:encoded> <wfw:commentRss>http://www.sitepoint.com/html5-and-the-future-of-online-games/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>How Start a Newsletter in Minutes With TinyLetter</title><link>http://www.sitepoint.com/how-start-a-newsletter-in-minutes-with-tinyletter/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-start-a-newsletter-in-minutes-with-tinyletter</link> <comments>http://www.sitepoint.com/how-start-a-newsletter-in-minutes-with-tinyletter/#comments</comments> <pubDate>Fri, 25 May 2012 15:00:22 +0000</pubDate> <dc:creator>Lior Levin</dc:creator> <category><![CDATA[Web Tech]]></category> <guid
isPermaLink="false">http://www.sitepoint.com/?p=53895</guid> <description><![CDATA[An email newsletter is a brilliant way to stay connected to your customers or community members. Many people who visit your website may like it. Some may even love it, but if no one reminds them to keep visiting, those people may forget all about it. By inviting them to subscribe to a periodic newsletter, you can [...]]]></description> <content:encoded><![CDATA[<p></p><p>An email newsletter is a brilliant way to <strong><a
href="http://webmasterformat.com/blog/benefits-from-offering-email-newsletter" target="_blank">stay connected</a></strong> to your customers or community members. Many people who visit your website may like it. Some may even love it, but if no one reminds them to keep visiting, those people may forget all about it. By inviting them to subscribe to a periodic newsletter, you can turn those site visitors into regulars, and <strong><a
href="http://tinyletter.com/" target="_blank">TinyLetter</a></strong> makes it easy to get started in a matter of minutes.<strong></p><p></strong>TinyLetter is a free service that makes it extremely easy to setup an email newsletter, share it with subscribers, and even charge them a fee for your high-quality periodical content. TinyLetter is a <strong><a
href="http://blog.mailchimp.com/mailchimp-acquires-tinyletter/" target="_blank">subsidiary of MailChimp</a></strong>, but it uses a simplified interface and is designed for &#8220;distraction free&#8221; mass communication with your subscribers, rather than robust email marketing campaigns.<strong></p><p></strong><strong>Creating a Newsletter</strong><strong></p><p></strong>To get started with TinyLetter, follow these simple instructions:<strong></p><p></strong>1. Point your web browser to <strong><a
href="http://tinyletter.com/" target="_blank">tinyletter.com</a></p><p></strong>2. Click &#8220;Register&#8221;<strong></p><p></strong>3. Fill out the registration form, including your username, real name (yours or your organization’s), newsletter name, a brief description, your email address, and a password.<strong></p><p></strong>4. Click &#8220;create my account&#8221;<strong></p><p></strong>5. Click where it says &#8220;click here to get the embed code&#8221;. This will allow you to publicize it on your website.<strong></p><p></strong>6. Paste the embed code into your website’s code where you want it to appear.<strong></p><p></strong>Users should now be able to subscribe directly from your site. Alternatively, you can give them the direct link (<a
href="http://tinyletter.com/your-username" target="_blank">tinyletter.com/your-username</a>)<wbr>, which is helpful if you want to share it on Facebook, Twitter, etc.<strong></p><p></strong><strong>Sending Your First Message</strong><strong></p><p></strong>Once you have some subscribers, you should start communicating with them. Go back to the TinyLetter website and click “Write A Newsletter”.  Enter a subject, and start writing just like you would with a normal email message. When you are finished, click “Preview” to get a glimpse of what your message will look like, and then click “Send to all” to make it final.<strong></p><p></strong><strong>Other Features</strong><strong><br
/> </strong>If you already have a contact list of users, you can import their email addresses directly into TinyLetter. On the main configuration screen, click &#8220;Import email address.&#8221; Note that it has a limit of 25 email addresses per day, likely to <strong><a
href="http://www.spamhaus.org/whitepapers/mailinglists.html" target="_blank">prevent spammers</a></strong> from using it to quickly build lists. <strong></p><p></strong>Another useful feature is that you can configure the appearance of the subscription page to look more integrated with your website’s theme. By clicking “Design and settings”, you can upload a background image, change the text that appears on the page, add a background pattern to the email subscription box, and configure payment information.<strong></p><p></strong><strong>Payments</strong><strong></p><p></strong>On the same “Design and settings” page, click the red link at the bottom of the first section that says “show even more settings”. Most of these settings allow you to tweak the text of your subscription form, but the bottom three settings allow you to configure payment options.<strong></p><p></strong>The first payment option, ”make money price”, sets the amount that subscribers must pay to get your newsletter. They will be charged monthly for the subscription. Therefore, if you only plan to send four newsletters per year, you should definitely make sure they know that. The “Free trial” setting gives you the option to give users their first month free. The final option is for how payment is collected, either from TinyLetter or directly to your PayPal account.<strong></p><p></strong>When you are finished changing settings, click “Save Changes” at the very bottom.<strong></p><p></strong><strong>Expanding Your Reader Base</strong><strong></p><p></strong>An email newsletter is a great way to extend your website to your readers who may not have time to check your site for updates and may not be accustomed to <strong><a
href="http://searchenginewatch.com/article/2067871/Study-RSS-Still-Not-Widely-Adopted" target="_blank">using RSS</a></strong>. Some users may have Facebook. Some may have Twitter. But all of your users probably have email accounts, and as long as you use some restraint with the frequency of your messages, many of them will love to get mail with <strong><a
href="http://googleblog.blogspot.com/2011/02/finding-more-high-quality-sites-in.html" target="_blank">quality content</a></strong> from you.<strong><br
/> </strong><br
/> </wbr></p> <span
id="pty_trigger"></span><div
style='padding:20px 0px 50px 0px;'><div
style='float:left;padding-left:40px;'><div
id='div-gpt-ad-1335489406190-0' style='width:300px; height:100px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1335489406190-0'); });</script> </div></div><div
style='float:right;padding-right:40px;'><div
id='div-gpt-ad-1335489406190-1' style='width:300px; height:100px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1335489406190-1'); });</script> </div></div><div
style='clear:both'></div></div><div
style='clear:both'></div>]]></content:encoded> <wfw:commentRss>http://www.sitepoint.com/how-start-a-newsletter-in-minutes-with-tinyletter/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Scalable Vector Graphics: Drawing Basics</title><link>http://www.sitepoint.com/svg-drawing-basics/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=svg-drawing-basics</link> <comments>http://www.sitepoint.com/svg-drawing-basics/#comments</comments> <pubDate>Tue, 22 May 2012 16:38:16 +0000</pubDate> <dc:creator>Craig Buckler</dc:creator> <category><![CDATA[Client Side Coding]]></category> <category><![CDATA[Design]]></category> <category><![CDATA[HTML5]]></category> <category><![CDATA[Responsive Web Design]]></category> <category><![CDATA[Tutorials]]></category> <category><![CDATA[Web Design Tutorials & Articles]]></category> <category><![CDATA[Web Tech]]></category> <category><![CDATA[graphics]]></category> <category><![CDATA[HTML5 Dev Center]]></category> <category><![CDATA[SVG]]></category> <guid
isPermaLink="false">http://www.sitepoint.com/?p=54645</guid> <description><![CDATA[<img
width="50" height="50" src="http://www.sitepoint.com/wp-content/uploads/1/files/2012/05/672-svg-basics-50x50.png" class="attachment-thumbnail wp-post-image" alt="672-svg-basics" title="672-svg-basics" />Craig's latest tutorial explains how to create SVG images and add simple drawing elements with nothing more than a text editor.]]></description> <content:encoded><![CDATA[<img
width="50" height="50" src="http://www.sitepoint.com/wp-content/uploads/1/files/2012/05/672-svg-basics-50x50.png" class="attachment-thumbnail wp-post-image" alt="672-svg-basics" title="672-svg-basics" /><p></p><p>In my previous posts we discussed <a
href="http://www.sitepoint.com/svg-scalable-vector-graphics-overview/">what SVGs are</a> and <a
href="http://www.sitepoint.com/7-reasons-to-consider-svgs-instead-of-canvas/">reasons you should consider SVGs for your project</a>. In this article we&#8217;ll look at the basic concepts, document structure and drawing elements.</p><h2>SVG Co-ordinate Space</h2><p>An SVG is defined in whatever co-ordinate space you give it. That space does not necessarily relate to pixels, cm, inches or other units because the images are scalable to any dimension.</p><p>Optionally, you can define a viewbox which determines the co-ordinates your SVG uses. The following SVGs would look identical:</p><ul><li>An SVG with a viewbox of 0,0 to 200,100 with a line from 0,0 to 100,50.</li><li>An SVG with a viewbox of 0,0 to 300,150 with a line from 0,0 to 150,75.</li></ul><p><img
src="http://blogs.sitepointstatic.com/images/tech/675-svg-drawing-space.png" width="300" height="267" alt="SVG drawing space" class="center" /></p><p>Your images are rendered within a viewport, i.e. the whole browser window or a block in an HTML page. By default, an SVG viewbox will stretch in either direction to fill the viewport space. However, you can state that you want the aspect ratio preserved.<div
id='div-gpt-ad-1328644474660-10' style='width:728px; height:90px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1328644474660-10'); });</script> </div></p><p>Unlike mathematical graphs, the SVG co-ordinate system starts at the top left (usually 0,0) with the x-axis pointing right and y-axis pointing down. Therefore, a point at 100,200 represents 100 units to the right of the left hand edge and 200 units down from the top edge.</p><h2>SVG Length Units</h2><p>Lengths in SVG can be specified either as:</p><ul><li>a relative value in the SVG space, e.g. 10</li><li>an absolute or relative measurement, e.g. 10px. SVG supports em, ex, px, pt, pc, cm, mm, in and percentage units.</li></ul><p>If your image will be scaled, use units which are relative to your viewbox, e.g. a line width of 10 within a 100&#215;100 viewbox will be 10% of the full width/height.</p><h2>SVG XML Document</h2><p>An SVG image is defined as an XML document. Assuming you&#8217;re creating a new SVG file, such as <a
href="http://blogs.sitepointstatic.com/examples/tech/svg-basics/image.svg">image.svg</a>, an XML declaration and doctype must appear at the top of the document:</p><pre><code>
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;
&lt;!DOCTYPE svg PUBLIC &quot;-//W3C//DTD SVG 1.1//EN&quot; &quot;http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd&quot;&gt;
</code></pre><p>This is followed by the root SVG element:</p><pre><code>
&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;
</code></pre><p>Several <a
href="http://www.w3.org/TR/SVG11/struct.html#SVGElement">optional attributes can be applied to the svg element</a>. Two important ones are:</p><ul><li><a
href="http://www.w3.org/TR/SVG/coords.html#ViewBoxAttribute">viewBox</a>: establish the dimensions &#8212; a rectangular co-ordinate area used for your image specified as &#8220;min-X min-Y width and height&#8221;, e.g. <code>viewBox="0 0 600 400"</code>. It&#8217;s important to remember this is an abstract space; it does not relate to pixels and your drawing elements are not constrained within these co-ordinates.</li><li><a
href="http://www.w3.org/TR/SVG11/coords.html#PreserveAspectRatioAttribute">preserveAspectRatio</a>: defines how a viewbox is scaled. There are many options, for example <code>preserveAspectRatio="xMidYMid meet"</code> ensures the middle of an SVG&#8217;s viewbox is aligned with the middle of the viewport (the browser window or HTML element containing the SVG) and the image fits the space available while preserving its aspect ratio.</li></ul><p>An optional title and description can be defined using <code>title</code> and <code>desc</code> elements. Our basic XML document is therefore:</p><pre><code>
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;
&lt;!DOCTYPE svg PUBLIC &quot;-//W3C//DTD SVG 1.1//EN&quot; &quot;http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd&quot;&gt;
&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 600 400&quot; preserveAspectRatio=&quot;xMidYMid meet&quot;&gt;
	&lt;title&gt;My First Scalable Vector Graphic&lt;/title&gt;
	&lt;desc&gt;An experimental SVG from SitePoint.com&lt;/desc&gt;
	&lt;!-- drawing elements to go here --&gt;
&lt;/svg&gt;
</code></pre><h2>Grouping Elements</h2><p>Any set of elements (lines, circles, rectangles, text, etc.) can be grouped using <code>&lt;g&gt; &hellip; &lt;/g&gt;</code> tags. In essence, it&#8217;s identical to grouping drawing objects in a graphics package so they can be manipulated as a single item.</p><p>Personally, I prefer to define a root group node so I can modify the whole image easily via JavaScript or CSS, e.g.</p><pre><code>
&lt;g id=&quot;main&quot;&gt;
	&lt;!-- drawing elements to go here --&gt;
&lt;/g&gt;
</code></pre><p>A single group can have any number of nested inner groups.</p><h2>Lines</h2><p>A single line between two points is drawn using the <code>line</code> element:</p><pre><code>
&lt;line x1=&quot;10&quot; y1=&quot;10&quot; x2=&quot;100&quot; y2=&quot;200&quot;
stroke=&quot;#999&quot; stroke-width=&quot;5&quot; stroke-linecap=&quot;round&quot; /&gt;
</code></pre><p>The stroke-linecap attribute defines the line-end effect and accepts values of butt (the default), round, square or inherit:</p><p><img
src="http://www.w3.org/TR/SVG11/images/painting/linecap.png" alt="SVG stroke-linecap" class="center" /></p><h2>Polylines</h2><p>Polylines define a set of connected straight line segments:</p><pre><code>
&lt;polyline points=&quot;580,10 560,390 540,200 520,390 400,390&quot;
stroke=&quot;#c00&quot; stroke-width=&quot;5&quot; stroke-linecap=&quot;round&quot;
stroke-linejoin=&quot;round&quot; fill=&quot;none&quot; /&gt;
</code></pre><p>The stroke-linejoin attribute defines the line-joining effect and accepts values of miter (the default), round, bevel or inherit:</p><p><img
src="http://www.w3.org/TR/SVG11/images/painting/linejoin.png" alt="SVG stroke-linejoin" class="center" /></p><h2>Polygons</h2><p>Polygons are are similar to polylines except that the resulting shape will always be closed:</p><pre><code>
&lt;polygon points=&quot;350,75 379,161 469,161 397,215 423,301 350,250 277,301 303,215 231,161 321,161&quot;
stroke=&quot;#ff0&quot; stroke-width=&quot;10&quot; fill=&quot;#ff6&quot; /&gt;
</code></pre><h2>Rectangles</h2><p>Square or rounded rectangles are defined using the <code>rect</code> element:</p><pre><code>
&lt;rect x=&quot;100&quot; y=&quot;10&quot; width=&quot;150&quot; height=&quot;100&quot; rx=&quot;10&quot; ry=&quot;20&quot;
stroke=&quot;#060&quot; stroke-width=&quot;8&quot; fill=&quot;#0f0&quot; /&gt;
</code></pre><p>The x and y attributes define the top-left corner. rx and ry specify the horizontal and vertical corner rounding.</p><h2>Circles</h2><p>Circles are defined using a center point and radius:</p><pre><code>
&lt;circle cx=&quot;100&quot; cy=&quot;300&quot; r=&quot;80&quot;
stroke=&quot;#909&quot; stroke-width=&quot;10&quot; fill=&quot;#f6f&quot; /&gt;
</code></pre><h2>Ellipses</h2><p>Ellipses are defined using a center point and two radii values:</p><pre><code>
&lt;ellipse cx=&quot;450&quot; cy=&quot;50&quot; rx=&quot;80&quot; ry=&quot;30&quot;
stroke=&quot;#0cc&quot; stroke-width=&quot;10&quot; fill=&quot;#0ff&quot; /&gt;
</code></pre><h2>Text</h2><p>Basic text can be added using the <code>text</code> element:</p><pre><code>
&lt;text x=&quot;240&quot; y=&quot;390&quot; font-family=&quot;sans-serif&quot; font-size=&quot;50&quot; fill=&quot;#00f&quot;&gt;SVG&lt;/text&gt;
</code></pre><p>The x and y attributes define the bottom-left co-ordinate of the first character in the string.</p><h2>The Result</h2><p>Our final SVG document contains the following XML code:</p><pre><code>
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;
&lt;!DOCTYPE svg PUBLIC &quot;-//W3C//DTD SVG 1.1//EN&quot; &quot;http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd&quot;&gt;
&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 600 400&quot; preserveAspectRatio=&quot;xMidYMid meet&quot;&gt;
	&lt;title&gt;My First Scalable Vector Graphic&lt;/title&gt;
	&lt;desc&gt;An experimental SVG from SitePoint.com&lt;/desc&gt;
	&lt;g id=&quot;main&quot;&gt;
		&lt;line x1=&quot;10&quot; y1=&quot;10&quot; x2=&quot;100&quot; y2=&quot;200&quot; stroke=&quot;#00c&quot; stroke-width=&quot;5&quot; stroke-linecap=&quot;round&quot; /&gt;
		&lt;polyline points=&quot;580,10 560,390 540,200 520,390 400,390&quot; stroke=&quot;#c00&quot; stroke-width=&quot;5&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; fill=&quot;none&quot; /&gt;
		&lt;polygon points=&quot;350,75 379,161 469,161 397,215 423,301 350,250 277,301 303,215 231,161 321,161&quot; stroke=&quot;#ff0&quot; stroke-width=&quot;10&quot; fill=&quot;#ffc&quot; /&gt;
		&lt;rect x=&quot;100&quot; y=&quot;10&quot; width=&quot;150&quot; height=&quot;100&quot; rx=&quot;10&quot; ry=&quot;20&quot; stroke=&quot;#060&quot; stroke-width=&quot;8&quot; fill=&quot;#0f0&quot; /&gt;
		&lt;circle cx=&quot;100&quot; cy=&quot;300&quot; r=&quot;80&quot; stroke=&quot;#909&quot; stroke-width=&quot;10&quot; fill=&quot;#f6f&quot; /&gt;
		&lt;ellipse cx=&quot;450&quot; cy=&quot;50&quot; rx=&quot;80&quot; ry=&quot;30&quot; stroke=&quot;#0cc&quot; stroke-width=&quot;10&quot; fill=&quot;#0ff&quot; /&gt;
		&lt;text x=&quot;240&quot; y=&quot;390&quot; font-family=&quot;sans-serif&quot; font-size=&quot;50&quot; fill=&quot;#00f&quot;&gt;SVG&lt;/text&gt;
	&lt;/g&gt;
&lt;/svg&gt;
</code></pre><p>and renders this image:</p><p><a
href="http://blogs.sitepointstatic.com/examples/tech/svg-basics/image.svg"><br
/> <img
src="http://blogs.sitepointstatic.com/images/tech/675-svg-drawing-screen.png" width="407" height="274" alt="SVG example" class="center" style="block" /><p
class="center">click to view the actual SVG</p><p></a></p><p>While this is a simple example, the file is 1,176 bytes <strong>before</strong> minification and gzipping. The equivalent compressed PNG above is 5,611 bytes &#8212; it&#8217;s almost 5x larger and cannot be scaled above its native 407&#215;274 resolution without losing quality.</p><p>Further Scalable Vector Graphic articles will appear on SitePoint soon&hellip;</p> <span
id="pty_trigger"></span><div
style='padding:20px 0px 50px 0px;'><div
style='float:left;padding-left:40px;'><div
id='div-gpt-ad-1335489406190-0' style='width:300px; height:100px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1335489406190-0'); });</script> </div></div><div
style='float:right;padding-right:40px;'><div
id='div-gpt-ad-1335489406190-1' style='width:300px; height:100px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1335489406190-1'); });</script> </div></div><div
style='clear:both'></div></div><div
style='clear:both'></div>]]></content:encoded> <wfw:commentRss>http://www.sitepoint.com/svg-drawing-basics/feed/</wfw:commentRss> <slash:comments>8</slash:comments> </item> <item><title>Get Tweeting and win a Kindle Fire at Web Directions Code!</title><link>http://www.sitepoint.com/get-tweeting-and-win-a-kindle-fire-at-web-directions-code/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=get-tweeting-and-win-a-kindle-fire-at-web-directions-code</link> <comments>http://www.sitepoint.com/get-tweeting-and-win-a-kindle-fire-at-web-directions-code/#comments</comments> <pubDate>Tue, 22 May 2012 03:40:52 +0000</pubDate> <dc:creator>Tom Museth</dc:creator> <category><![CDATA[Web Tech]]></category> <category><![CDATA[Community]]></category> <category><![CDATA[CSS3]]></category> <category><![CDATA[Design]]></category> <category><![CDATA[HTML5 Tutorials & Articles]]></category> <category><![CDATA[twitter]]></category> <category><![CDATA[WordPress]]></category> <guid
isPermaLink="false">http://www.sitepoint.com/?p=54794</guid> <description><![CDATA[At SitePoint we live and breathe web tech &#8230; and we love our ebooks. Combining these two passions is a challenge we relish, whether we&#8217;re releasing an all-encompassing guide to the world of WordPress (like The WordPress Anthology), an analysis of cutting-edge design approaches (say, The Principles of Beautiful Web Design) or an introduction to [...]]]></description> <content:encoded><![CDATA[<p></p><p>At SitePoint we live and breathe web tech &#8230; and we love our ebooks. Combining these two passions is a challenge we relish, whether we&#8217;re releasing an all-encompassing guide to the world of WordPress (like <em>The WordPress Anthology</em>), an analysis of cutting-edge design approaches (say, <em>The Principles of Beautiful Web Design</em>) or an introduction to the latest web development standards and methods (for instance, <em>HTML5 &amp; CSS3 For the Real World</em>).</p><p>Which is why we decided we ought to share these passions with our treasured SitePoint community &#8211; especially those of you who are attending the bound-to-be-awesome Web Directions Code conference, taking place in Melbourne on Wednesday, May 23 and Thursday, May 24. We&#8217;re sending a whole bunch of SitePoint staffers along to this two-day festival of all things JavaScript and HTML5 (check out the <a
title="Web Directions Code" href="http://code12melb.webdirections.org/" target="_blank">program</a>) where we&#8217;ll be attending excellent talks from the likes of Max Wheeler, Ryan Seddon and Rob Hawkes, to name a few. But our crew are also going to be hoping you&#8217;ll hook up with them and enter our SitePoint Twitaway Competition! Check out the details on the <a
title="SitePoint Twitaway Competition" href="http://www.sitepoint.com/wdc/" target="_blank">Twitaway Competition page</a>.</p><p>Here&#8217;s how it works.</p><ul><li>When you&#8217;re at the conference, look out for a SitePoint staffer (you can find us wandering around in our T-shirts, probably armed to the teeth with books, mugs and other SitePoint gear we&#8217;re itching to give away). Who&#8217;ll be there? Louis, Tom, Di, Alex, Harley and Ole. We&#8217;re waiting to meet you.</li><li>Grab one of us &#8230; but be gentle.</li><li>Take a photo of yourself with said SitePointer.</li><li>Send a unique, funny tweet, with your photo and the hashtag <strong>#lovesitepoint</strong>.</li><li>That&#8217;s it &#8230; unless, of course, you want to stick around and have a chat with us!</li></ul><p>This will put you in the running for our great giveaway: a Kindle Fire, which we&#8217;ll hand over to the winner on the Thursday afternoon, and happily load up with a whole bunch of SitePoint ebooks.</p><p>But wait &#8230; &#8216;cos there&#8217;s more. Everyone who sends a tweet with a photo and the <strong>#lovesitepoint</strong> hashtag will win an ebook anyway. Why? Well, because you deserve it. And we want you to be awesome developers &#8230; something we hope we can give you a hand with when you choose one ebook from the following: <em>The WordPress Anthology</em>, <em>The Principles of Beautiful Web Design</em>, or <em>HTML5 &amp; CSS3 For the Real World</em>.</p><p>The details are all on the <a
title="SitePoint Twitaway Competition" href="http://www.sitepoint.com/wdc/" target="_blank">promotion page</a>. All you have to do is get to Web Directions Code, hunt us down and get tweeting!</p><p>&nbsp;</p> <span
id="pty_trigger"></span><div
style='padding:20px 0px 50px 0px;'><div
style='float:left;padding-left:40px;'><div
id='div-gpt-ad-1335489406190-0' style='width:300px; height:100px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1335489406190-0'); });</script> </div></div><div
style='float:right;padding-right:40px;'><div
id='div-gpt-ad-1335489406190-1' style='width:300px; height:100px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1335489406190-1'); });</script> </div></div><div
style='clear:both'></div></div><div
style='clear:both'></div>]]></content:encoded> <wfw:commentRss>http://www.sitepoint.com/get-tweeting-and-win-a-kindle-fire-at-web-directions-code/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item><div><div
class="post_box two_ads" style="float:left;padding-left:2px;"><div
id='div-gpt-ad-1328645237920-0' style='width:728px; height:90px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1328645237920-0'); });</script> </div></div></div><div
class="clear">&nbsp;</div> <item><title>Ubuntu 12.04 LTS Precise Pangolin: File sharing with Samba.</title><link>http://www.sitepoint.com/ubuntu-12-04-lts-precise-pangolin-file-sharing-with-samba/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ubuntu-12-04-lts-precise-pangolin-file-sharing-with-samba</link> <comments>http://www.sitepoint.com/ubuntu-12-04-lts-precise-pangolin-file-sharing-with-samba/#comments</comments> <pubDate>Mon, 21 May 2012 15:00:10 +0000</pubDate> <dc:creator>Jonathan Hobson</dc:creator> <category><![CDATA[Web Tech]]></category> <category><![CDATA[WebOS]]></category> <category><![CDATA[Ubuntu]]></category> <guid
isPermaLink="false">http://www.sitepoint.com/?p=54695</guid> <description><![CDATA[<img
width="50" height="39" src="http://www.sitepoint.com/wp-content/uploads/1/files/2012/04/ubuntu-50x39.png" class="attachment-thumbnail wp-post-image" alt="ubuntu" title="ubuntu" />Samba is the software package that allows you to share files, printers and other common resources across a network, and in this article I will be showing you how to install, set-up and manage a Samba Server on Ubuntu 12.04.]]></description> <content:encoded><![CDATA[<img
width="50" height="39" src="http://www.sitepoint.com/wp-content/uploads/1/files/2012/04/ubuntu-50x39.png" class="attachment-thumbnail wp-post-image" alt="ubuntu" title="ubuntu" /><p></p><p>Samba is the software package that allows you to share files, printers and other common resources across a network. Delivering full connectivity with the Windows workgroup it is known and respected as an invaluable tool in homes and offices around the world and in this article I will be showing you how to install, set-up and manage a Samba Server on Ubuntu 12.04 LTS Precise Pangolin.<br
/> So let&#8217;s begin &#8230;</p><h2>Prerequisites</h2><p>To get the best out of Samba your system should be running a static IP address and if you happen to be running a firewall, you should open the relevant ports to give the Samba service full access to your network.</p><p>Yes, you can use DHCP, but you will need to ensure that your DHCP server or router is providing you with a &#8216;fixed&#8217; DHCP licence; but for those who wish to learn how to implement a static IP address on Ubuntu 12.04 you can read my previous article on <a
href="http://www.sitepoint.com/ubuntu-12-04-lts-precise-pangolin-networking-tips-and-tricks">networking tips and tricks</a></p><h2>Update your system</h2><p>Installing Samba is a very straight forward process so we shall begin by updating the system.<br
/> In Terminal or in your console type:<div
id='div-gpt-ad-1328644474660-10' style='width:728px; height:90px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1328644474660-10'); });</script> </div></p><pre>sudo apt-get update &amp;&amp; apt-get upgrade</pre><p>If there are any updates available to you, do that now before we proceed :-)</p><h2>Installing Samba</h2><p>For the purposes of this article I will have provided you with three different approaches to installing Samba:<br
/> <strong>1. For desktop users</strong>, who want to take advantage of &#8216;winbind&#8217; (winbin) and use the graphical tools (system-config-samba), open Terminal and type:</p><pre>sudo apt-get install samba samba-common system-config-samba winbind</pre><p><strong>2. For desktop users</strong>, who wish to take advantage of &#8216;winbind&#8217; (winbind) but do not wish to use the graphical tools, open Terminal and type:</p><pre>sudo apt-get install samba samba-common winbind</pre><p><strong>3. For server users</strong>, in your console type:</p><pre>sudo apt-get install samba samba-common</pre><h2>Configuring Winbind</h2><p>Before we tackle the subject of Samba itself, desktop users will notice that we have installed Winbin.<br
/> The purpose of this is to ensure that Ubuntu can provide full hostname resolution when viewing your local network and so we will want to configure this before moving on. Don&#8217;t worry, it is very simple as all we need to do is make a quick &#8216;order change&#8217; to the &#8216;nsswitch.conf&#8217; file.<br
/> To begin, open Terminal and type:</p><pre>sudo gedit /etc/nsswitch.conf</pre><p>Find the line that looks like this:</p><pre>osts:          files mdns4_minimal [NOTFOUND=return] dns mdns4</pre><p>Now change it to look like this:</p><pre>hosts:          files mdns4_minimal [NOTFOUND=return] wins dns mdns4</pre><p>Your nsswitch.conf file should now look something like this:</p><pre>passwd:         compat
group:          compat
shadow:         compat
hosts:          files mdns4_minimal [NOTFOUND=return] wins dns mdns4
networks:       files
protocols:      db files
services:       db files
ethers:         db files
rpc:            db files
netgroup:       nis</pre><p>When complete, simply &#8216;save&#8217; and close your file before rebooting like so:</p><pre>sudo reboot</pre><p>Having done this you should now be able to select &#8216;GO &gt; Network&#8217; from the desktop menu and view your entire Windows and Linux based network.</p><blockquote><p>From this point onwards the article will act a guide and depending on your needs it should not be viewed as an ordered process or a solution. For example, you may wish to add system users prior to completing any configuration work or you may even need to repeat some processes in order to add multiple users. Remember, everyone&#8217;s network needs are unique :-)</p></blockquote><h2>Using the desktop graphical tools.</h2><p>Before you begin to use the graphical tools (system-config-samba) we will need to &#8216;fine-tune&#8217; the Samba Server Settings.</p><p>To do this, open the dash and use the search bar to find Samba like so:</p><p><a
href="http://www.sitepoint.com/?attachment_id=54698" rel="attachment wp-att-54698"><img
class="alignnone size-full wp-image-54698" src="http://www.sitepoint.com/wp-content/uploads/1/files/2012/05/u11.jpg" alt="" width="500" height="370" /></a></p><p>Launch the Samba configuration tool and choose, &#8216;Preferences &gt; Server Settings&#8217; like so:</p><p><a
href="http://www.sitepoint.com/?attachment_id=54699" rel="attachment wp-att-54699"><img
class="alignnone size-full wp-image-54699" src="http://www.sitepoint.com/wp-content/uploads/1/files/2012/05/u21.jpg" alt="" width="500" height="370" /></a></p><p>In most cases the &#8216;default settings&#8217; may be exactly what you need but in some instances you may need to make a few changes.</p><p>Complete the &#8216;basic&#8217; tab settings and click &#8216;OK&#8217; when done:</p><ul><li><strong>Workgroup.</strong>This field should be the same value as that used by your Windows Workgroupi.e if your WIndows Users are members of the &#8216;Home&#8217; workgroup, type &#8216;Home&#8217; in this field.</li><li><strong>Description.</strong>This is the name of your computer as seen by Windows Users.i.e.<br
/> keep it simple, use a name similar to that of your actual computer name and do not use spaces on non-internet friendly characters.</li></ul><p><a
href="http://www.sitepoint.com/?attachment_id=54704" rel="attachment wp-att-54704"><img
class="alignnone size-full wp-image-54704" src="http://www.sitepoint.com/wp-content/uploads/1/files/2012/05/u31.jpg" alt="" width="500" height="370" /></a></p><p>As it is not advisable to allow &#8216;Guests&#8217; there should be no reason to change the &#8216;security&#8217; settings tab unless you wish to do so:</p><p><a
href="http://www.sitepoint.com/?attachment_id=54705" rel="attachment wp-att-54705"><img
class="alignnone size-full wp-image-54705" src="http://www.sitepoint.com/wp-content/uploads/1/files/2012/05/u41.jpg" alt="" width="500" height="370" /></a></p><p>Now click &#8216;OK&#8217; to close the &#8216;Server Settings&#8217; window.<br
/> To manage your current users simply choose &#8216;Preferences &gt; Samba Users&#8217; like so:</p><p><a
href="http://www.sitepoint.com/?attachment_id=54707" rel="attachment wp-att-54707"><img
class="alignnone size-full wp-image-54707" src="http://www.sitepoint.com/wp-content/uploads/1/files/2012/05/u22.jpg" alt="" width="500" height="370" /></a></p><p>Now launch the &#8216;Samba Users&#8217; dialogue box. Select your username and click &#8216;Edit User&#8217; to launch the &#8216;Create New Samab User&#8217; dialogue box.</p><p><a
href="http://www.sitepoint.com/?attachment_id=54708" rel="attachment wp-att-54708"><img
class="alignnone size-full wp-image-54708" src="http://www.sitepoint.com/wp-content/uploads/1/files/2012/05/u51.jpg" alt="" width="500" height="370" /></a></p><p>Complete the fields as required:</p><ul><li><strong>Windows Username.</strong> Confirm the username to be used by Windows users when accessing your share folder(s).</li><li><strong>Samba Password.</strong> Use this field to confirm the password to be used by Windows users when accessing your share folder(s).</li><li><strong>Confirm Samba Password. </strong>Use this field to re-confirm the password to be used by Windows users when accessing your share folder(s).</li></ul><blockquote><p>Although you may see &#8216;stars&#8217; in the password field(s) prior to doing this. Delete them and re-type the password.</p></blockquote><p>When complete, click &#8216;OK&#8217; to close both dialogue boxes before restarting the Samba service like so.</p><p>Open Terminal and type:</p><pre>sudo restart smbd &amp;&amp; sudo restart nmbd</pre><h2>Adding a new (Linux) user account with the desktop graphical tools.</h2><p>If you want to add a new Linux user account, simply:</p><ul><li>Open &#8216;System Settings&#8217;.</li><li>Choose &#8216;User Accounts&#8217; and unlock the panel using your administration password.</li><li>Use the + (plus) icon to create a new user.</li><li>Enter the new user&#8217;s full name (the username will be filled in automatically based on the full name).</li></ul><p>As this folder is for &#8216;sharing purposes only&#8217; do not assign &#8216;administrative rights&#8217; to this user account.</p><p><a
href="http://www.sitepoint.com/?attachment_id=54709" rel="attachment wp-att-54709"><img
class="alignnone size-full wp-image-54709" src="http://www.sitepoint.com/wp-content/uploads/1/files/2012/05/u8.jpg" alt="" width="500" height="370" /></a></p><p>When finished, click &lt;Create&gt;.<br
/> As the account is initially disabled, we now need to set the users password.</p><p>To do this, simply:</p><ul><li>Ensure the &#8216;User Accounts&#8217; panel is still unlocked.</li><li>Click &#8216;Account Disabled&#8217; and complete the resulting dialogue box.</li></ul><p><a
href="http://www.sitepoint.com/?attachment_id=54710" rel="attachment wp-att-54710"><img
class="alignnone size-full wp-image-54710" src="http://www.sitepoint.com/wp-content/uploads/1/files/2012/05/u9.jpg" alt="" width="500" height="370" /></a></p><p>When finished, click &#8216;Change&#8217;.<br
/> If you return to the &#8216;Samba Users&#8217; dialogue box and click &#8216;Add User&#8217;, your new user account should be found in the Unix Username drop-down box like so:</p><p><a
href="http://www.sitepoint.com/?attachment_id=54711" rel="attachment wp-att-54711"><img
class="alignnone size-full wp-image-54711" src="http://www.sitepoint.com/wp-content/uploads/1/files/2012/05/u10.jpg" alt="" width="500" height="370" /></a></p><p>Simply complete the relevant details and click &lt;OK&gt; to finish.<br
/> When done, you will be able to assign this user account to specific folders like so:</p><p><a
href="http://www.sitepoint.com/?attachment_id=54712" rel="attachment wp-att-54712"><img
class="alignnone size-full wp-image-54712" src="http://www.sitepoint.com/wp-content/uploads/1/files/2012/05/u111.jpg" alt="" width="500" height="370" /></a></p><p>More information on user accounts can be found here <a
href="https://help.ubuntu.com/12.04/ubuntu-help/user-accounts.html" target="_blank">https://help.ubuntu.com/12.04/ubuntu-help/user-accounts.html</a>.</p><h2>Sharing folders with the graphical tools.</h2><p>To share a folder with Samba, click the green &#8216;+&#8217; (plus) icon to open a dialogue box called &#8216;Create Samba Share&#8217; like so:</p><p><a
href="http://www.sitepoint.com/?attachment_id=54713" rel="attachment wp-att-54713"><img
class="alignnone size-full wp-image-54713" src="http://www.sitepoint.com/wp-content/uploads/1/files/2012/05/u6.jpg" alt="" width="500" height="370" /></a></p><p>Complete the &#8216;basic&#8217; tab with the required information.</p><ul><li><strong>Directory.</strong> Click &#8216;Browse&#8217; to locate the relevant folder you wish to share.</li><li><strong>Share Name.</strong> Use this field to specify a &#8216;human friendly&#8217; name for your share folder.</li><li><strong>Description.</strong> Type a description of the &#8216;share folder&#8217; in this field.</li><li><strong>Writable.</strong> Shared folders are &#8216;read-only&#8217; by default, so place a tick in this box if you would like to enable &#8216;write&#8217; access.</li><li><strong>Visible.</strong> Place a tick in this box if you want your share folder to be &#8216;visible&#8217; on the network.</li></ul><p>Following this, we now need to set the permissions for your new share folder.</p><p>To do this, simply click the &#8216;access&#8217; tab in the same dialogue box like so:</p><p><a
href="http://www.sitepoint.com/?attachment_id=54714" rel="attachment wp-att-54714"><img
class="alignnone size-full wp-image-54714" src="http://www.sitepoint.com/wp-content/uploads/1/files/2012/05/u112.jpg" alt="" width="500" height="370" /></a></p><p><strong>If you would like to restrict access to this folder:</strong></p><ul><li>Select &#8216;Only allow access to specific users&#8217;.</li><li>Use the tick boxes to confirm which users can access the folder in question.</li></ul><p><strong>If you would like everyone to access the folder:</strong></p><ul><li>Select &#8216;Allow access to everyone&#8217;.</li></ul><p>When complete, click &#8216;OK&#8217; to close the dialogue box.</p><blockquote><p>To remove any shared folder from Samba, simply choose the relevant folder in the configuration tool and click the &#8216;red icon&#8217;. Don&#8217;t worry, this action will not delete the folder or its contents.</p></blockquote><p>And that&#8217;s it, your share folders are now active.</p><h2>Configuring Samba on the command line</h2><p>Using the graphical tools has its advantages, but if you really want to control every aspect of your Samba server, nothing beats the command line.</p><p>So let&#8217;s begin by making a backup of our original configuration file:</p><pre>cp /etc/samba/smb.conf /etc/samba/smb.conf.bak</pre><p>And open the content of the current configuration file like so:</p><pre>sudo nano /etc/samba/smb.conf</pre><p>We are now going to configure the Samba Server by using a basic example to get you started &#8230;</p><p>I am not going to explain every aspect of Samba (as most server administrators will want to read the official documentation found at <a
href="http://www.samba.org/" target="_blank">http://www.samba.org/</a>) so instead I have provided you with a template in order to get you up and running in no time at all. You should consider this to be a basic template only. It is not definitive by any means and nor do I expect you to replicate it but if you do use it &#8211; remember to change the values shown with values relevant to your specific needs or network requirements:<br
/> And here is the template:</p><pre>[global]
    unix charset = UTF-8
    # -------------------------------------------
    # DEFINE YOUR WORKGROUP AND COMPUTER NAME HERE
    workgroup = YOUR-WORKGROUP-NAME
    server string = YOUR-COMPUTER-NAME
	  netbios name = YOUR-COMPUTER-NAME
    # -------------------------------------------
    dns proxy = no
    # -------------------------------------------
    # IF YOU SET BIND INTERFACES TO YES, TO AVOID LOG ERRORS,
	  # MAKE SURE YOUR SAMBA SERVICE STARTS AFTER THE ETHERNET CARD IS SWITCHED ON
    # bind interfaces only = no
    # bind interfaces only = yes
    bind interfaces only = no
    # ADD THE ETHERNET CARD AND IP ADDRESSES YOU ALLOW
    interfaces = eth0 127.0.0.0/8 192.168.1.0/24
    # -------------------------------------------
    # SAMBA LOG FILES
    log file = /var/log/samba/log.%m
    max log size = 1000
    syslog only = no
    syslog = 0
    # -------------------------------------------
    panic action = /usr/share/samba/panic-action %d
    # LIMIT ACCESS TO USERS ONLY
    security = user
    # USING TDBSAM
    encrypt passwords = true
    passdb backend = tdbsam
    obey pam restrictions = yes
    unix password sync = yes
    passwd program = /usr/bin/passwd %u
    passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
    pam password change = yes
    map to guest = bad user
    usershare allow guests = no
    # -------------------------------------------
    # INCLUDE THIS SECTION TO DISABLE PRINTERS/CUPS ONLY
    #load printers = no
    #printing = bsd
    #printcap name = /dev/null
    #disable spoolss = yes
    # -------------------------------------------
    # DIRECTORIES
    # -------------------------------------------
    # ENABLE HOME FOLDER ACCESS
    [homes]
        comment = Home Directories
        browseable = no
        writable = yes
        valid users = %S
        valid users = MYDOMAIN\%S
        create mask =0755
        directory mask =0755
    # -------------------------------------------
    # EXAMPLE FOLDER WITH LIMITED ACCESS, UNCOMMENT AND CUSTOMISE AS NECESSARY
    #[example]
    #   comment = example share folder on my-computer-name
    #   path = /foldername/foldername/
    #   browseable = yes
    #   guest ok = no
    #   writable = yes
    #   create mask = 0755
    #   directory mask = 0755
    #   valid users = @your-username
    #   force group = your-username-or-group
    #   force create mode = 0755
    # -------------------------------------------</pre><p>To un-comment a line, simply remove the # (hash) symbol.</p><p>Either copy the content of this file to <strong>/etc/samba/smb.conf</strong> or simply work through the samba configuration file using my template as a guide. Don&#8217;t worry, there&#8217;s no rush &#8230;</p><p>When done, &#8216;save&#8217; the file, &#8216;close&#8217; it and restart the Samba service in order that it can apply the new settings by using:</p><pre>sudo service smbd restart &amp;&amp; sudo service nmbd restart</pre><h2>Creating (Linux) users and home folders on the command line</h2><p>Although a complete tutorial on &#8216;working with files, directories and users&#8217; is beyond the scope of this current article, adding a new user account and creating a home folder is a relatively simple task &#8211; just remember to replace my values with something relevant to your needs.</p><p>To create a new user with an associated home folder on your server or desktop, use:</p><pre>sudo adduser new-username-here</pre><p>Ubuntu will now ask you a few basic questions and then complete the task of [a] creating the new user, [b] creating a specific group for that user and then [c] creating a home folder for the user in question.</p><p>And all with a single command :-)</p><p>To explain this, here is a step-by-step example with the resulting output. I am going to create a new user called &#8216;new-username-here&#8217;.</p><p>The process begins after I type the following command:</p><pre>sudo adduser new-username-here</pre><p>Ubuntu will now start the process:</p><pre>Adding user `new-username-here' ...
Adding new group `new-username-here' (1004) ...
Adding new user `new-username-here' (1004) with group `new-username-here' ...
Creating home directory `/home/new-username-here' ...
Copying files from `/etc/skel' ...</pre><p>At this point you will be asked to create a password:</p><pre>Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for new-username-here</pre><p>At this point you will be asked to complete some user-based details:<br
/> (to leave a field blank, just press the &lt;RETURN&gt; key)</p><pre>Enter the new value, or press ENTER for the default
	Full Name []: new-username-here
	Room Number []:
	Work Phone []:
	Home Phone []:
	Other []:</pre><p>At this point you will be asked to confirm your instruction:</p><pre>Is the information correct? [Y/n]</pre><p>Wasn&#8217;t that easy :-)</p><h2>Adding (Samba) users on the command line</h2><p>Finally let&#8217;s create a Samba user based on the example above with the following command.</p><pre>smbpasswd -a new-username-here</pre><p>You will be asked to confirm a password, but it is as simple as that &#8230;</p><blockquote><p>Remember, you will need to give the relevant username and password to your network user.</p></blockquote><p>So until next time &#8230;<br
/> I hope you continue to enjoy using Ubuntu 12.04 LTS Precise Pangolin.</p> <span
id="pty_trigger"></span><div
style='padding:20px 0px 50px 0px;'><div
style='float:left;padding-left:40px;'><div
id='div-gpt-ad-1335489406190-0' style='width:300px; height:100px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1335489406190-0'); });</script> </div></div><div
style='float:right;padding-right:40px;'><div
id='div-gpt-ad-1335489406190-1' style='width:300px; height:100px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1335489406190-1'); });</script> </div></div><div
style='clear:both'></div></div><div
style='clear:both'></div>]]></content:encoded> <wfw:commentRss>http://www.sitepoint.com/ubuntu-12-04-lts-precise-pangolin-file-sharing-with-samba/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>An Introduction to C</title><link>http://www.sitepoint.com/an-introduction-to-c/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=an-introduction-to-c</link> <comments>http://www.sitepoint.com/an-introduction-to-c/#comments</comments> <pubDate>Sat, 19 May 2012 15:00:53 +0000</pubDate> <dc:creator>Surabhi Saxena</dc:creator> <category><![CDATA[Web Tech]]></category> <guid
isPermaLink="false">http://www.sitepoint.com/?p=53509</guid> <description><![CDATA[C. You've all heard about it, but how much do you actually know about it? In this piece, Surabhi introduces us to this powerful language.]]></description> <content:encoded><![CDATA[<p></p><p><strong>Introduction</strong></p><p>C is a general purpose, structured programming language. Its instructions consist of terms that resemble algebraic expressions, augmented by certain English keywords such as if, else, for, do and while. In this respect it resembles high level structured programming languages such as Pascal and Fortran. C also contains additional features, that allow it to be used at a lower level, thus bridging the gap between machine language and high level language. This flexibility allows C to be used for systems programming as well as for applications programming. Therefore C is called a <strong><em>middle level language.  </em></strong></p><p>C is characterized by the ability to write very concise source programs, due in part to the large number of operators included within the language. It has a relatively small instruction set, though actual implementations include extensive library functions which enhance the basic instructions. C encourages users to create their own library fuctions.</p><p>An important characteristic of C is that its programs are highly portable. The reason for this is that C relegates most computer dependent features to its library functions. Thus, every version of C is accompanied by its own set of library functions which are relatively standardized. Therefore most C programs can be processed on many different computers with little or no alteration.<div
id='div-gpt-ad-1328644474660-10' style='width:728px; height:90px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1328644474660-10'); });</script> </div></p><p><strong>History of C:</strong></p><p>C was developed in the 1970&#8242;s by <strong>Dennis Ritchie</strong> at <strong>Bell Telephone Laboratories</strong>,Inc. (now a part of AT&amp;T). It is an outgrowth of two earlier languages, called BCPL and B, which were also developed at Bell Laboratories.</p><p>The <strong>Combined Programming Language(CPL)</strong> was developed at Cambridge University in 1963 with the goal of developing a common programming language which can be used to solve different types of problems on various hardware platforms. However it turned out to be too complex, hard to learn and difficult to implement. Subsequently in 1967, a subset of CPL, <strong>Basic CPL(BCPL)</strong> was developed by <strong>Martin Richards</strong> incorporating only the essential features. However it was not found to be sufficiently powerful. Around the same time another subset of CPL, a language called <strong>B</strong> was developed by <strong>Ken Thompson</strong> at Bell Labs. However it also turned out to be insufficient . Then, in 1972, Dennis Ritchie at Bell Labs developed the C language incorporating the best features of both BCPL and B.</p><p>C was largely confined to use within Bell Labs until 1978, when Brian Kernighan and Ritchie published a definitive description of the language . The <strong>Kerninghan and Ritchie description of C</strong> is commonly referred to as <em><strong>&#8216;K &amp;R C&#8217;</strong></em>.</p><p>Following the publication of &#8216;K&amp;R C&#8217;,computer professionals, impressed with C&#8217;s many desirable features, began to promote the use of C. By the mid 1980&#8242;s the popularity of C had become widespread-many c compilers and interpreters had been written for computers of all sizes and many commercial application programs had been developed. Moreover, many commercial software products that had originally been written in other languages were rewritten in C in order to take advantage of its efficiency and portability.</p><p>Early commercial implementations of C differed a little from Kerninghan and Ritchie&#8217;s original description, resulting in minor incompatibilities between different implementations. As a result, <strong>the American National Standards Institute(ANSI committee X3J11)</strong>  developed a standardized definition of C. Virtually all commercial compilers and interpreters adhere to the ANSI standard. Many provide additional features of their own.</p><p><strong>C and Systems Programming:</strong></p><p>There are several features of C, which make it suitable for systems programming. They are as follows:</p><ul><li>C is a machine independent and highly portable language.</li><li>It is easy to learn; it has only 28 keywords.</li><li>It has a comprehensive set of operators to tackle business as well as scientific applications with ease.</li><li>Users can create their own functions and add to the C library to perform a variety of tasks.</li><li>C language allows the manipulation of bits, bytes and addresses.</li><li>It has a large library of functions.</li><li>C operates on the same data types as the computer, so the codes generated are fast and efficient.</li></ul><p><strong>Structure of a C Program:</strong></p><p>Every C program consists of one or more modules called <strong><em>functions. </em></strong>One of the functions must be called <strong><em>main</em></strong>. The program will always begin by executing the <em>main</em> function, which may access other functions. The main function is normally,but not necessarily located at the beginning of the program. The group of statements within main( ) are executed sequentially. When the closing brace of main( ) is encountered, program execution stops and control is returned to the operating system.</p><p>Any other function defintions must be defined separately, either ahead or after main( ). Each function must contain:</p><p>1. A <strong><em>function heading</em></strong>, which consists of the <strong><em>function name</em></strong>, followed by an optional list of arguments, enclosed in parantheses.</p><p>2. A <strong><em>return type</em></strong> written before the function name. It denotes the type of data that the function will return to the program.</p><p>3. A list of <strong><em>argument declarations</em></strong>, if arguments are included in the heading.</p><p>4. A <strong><em>compound statement</em></strong>, which comprises the remainder of the function.</p><p>The arguments(also called parameters) are symbols that represent information being passed between the function and other parts of the program.</p><p>Each compound statement is enclosed between a pair of braces{ }. The braces may contain one or more elementary statements (called <strong><em>expression statements</em></strong>) and other compound statements. Thus compound statements may be nested one within another. Each expression statement must end with a semicolon(;).</p><p><strong><em>Comments (remarks)</em></strong> may appear anywhere within a program as long as they are enclosed within the delimiters /* and */. Comments are used for documentation and are useful in identifying the program&#8217;s principal features or in explaining the underlying logic of various program features.</p><p><span
style="text-decoration: underline"><strong>Components of C Language:</strong></span></p><p>There are five main components of the C Language:-</p><p>1. <strong>The character set:</strong> C uses the uppercase letters A to Z, the lowercase letters a to z, the digits 0 to 9 and certain special characters as building blocks to form basic program elements(e. g. constants, variables, expressions, statements etc. ).</p><p>2. <strong>Data Types:</strong> The C language is designed to handle five <em>primary data types, </em>namely, <em>character, integer, float, double and void;</em> and <em>secondary data types </em>like<em> array, pointer, structure, union and enum. </em></p><p><strong>3. </strong><strong>Constants:</strong> A constant<strong> </strong>is a fixed value entity that does not change its value throughout program execution.</p><p>4. <strong>Variables:</strong> A variable is an entity whose value can change during program execution. They are used for storing input data or to store values generated as a result of processing.</p><p>5. <strong>Keywords:</strong> Keywords are <strong><em>reserved</em></strong> words which have been assigned specific meanings in the C language. Keywords cannot be used as variable names.</p><p>The components of C language will be discussed in greater detail in the following articles. This section gives only a brief introduction to the components of C.</p><p><strong>Example 1:</strong> The following program reads in the radius of a circle, calculates the area and then prints the result.</p><pre style="padding-left: 30px">/* program to calculate the area of a circle*/
#include&lt;stdio.h&gt; /*Library file access*/
#include&lt;conio.h&gt; /*Library file access*/
void main( )            /* Function Heading*/
    {
       float radius, area; /*Variable declarations*/
       /*Output Statement(prompt)*/
       printf("Enter the radius :");
      /*Input Statement*/
      scanf("%f", &amp;radius);
      /*Assignment Statement*/
      area = 3.14159*radius*radius;
      /*Output Statement*/
      printf("Area of the circle :%f", area);
       getch( );
     }</pre><p
style="padding-left: 30px">Program output:-</p><p
style="padding-left: 30px">Enter the radius: 3</p><p
style="padding-left: 30px">Area of the circle: 28. 27431</p><p>The following points must be considered to understand the above program:-</p><p>1. The program is typed in lowercase. C is <strong>case sensitive</strong> i. e. uppercase and lowercase characters are not equivalent in C. It is customary to type C instructions in lowercase. Comments and messages(such as those printed using <code>printf() )</code> can be typed in anycase.</p><p>2. The first line is a comment that identifies the purpose of the program.</p><p>3. The instruction<strong> #include &lt;stdio.h&gt;</strong> contains a reference to a special file called stdio. h . This file contains the definition of certain functions required to read and print data such as printf() and scanf() . It is a header file and hence the extension . h.</p><p>4. Similarly <strong>#include &lt;conio.h&gt;</strong> links the file conio. h which is another header file that contains the definitions of functions used for reading and printing data at the console. The function <strong><code>getch()</code></strong> is defined in conio. h. # denotes a preprocessor directive. More about this in a later article.</p><p>5. The instruction <strong>void main()</strong> is a heading for the function main( ). The keyword <strong>void</strong> denotes the return type of main and indicates that the function does not return any value to the program after the program has finished executing. The empty parantheses ( ) after main indicates that this function does not include any arguments. Program execution always begins from main( ).</p><p>6. The remaining five lines of the program are indented and enclosed in a pair of braces { }. These five lines comprise the compound statement within the function main( ).</p><p>7. The instruction <strong>float radius, area;</strong>  is a <strong><em>variable declaration. </em></strong> It establishes the symbolic names &#8216;radius&#8217; and &#8216;area&#8217; as floating point variables. These variables can accept values of type &#8216;float &#8216; i. e numbers containing a decimal point or an exponent.</p><p>8. The next four instructions are <strong><em> expression statements. </em></strong>The instruction <strong>printf(&#8220;Enter the radius :&#8221;);</strong> generates a request for information namely,the value for the radius. This statement generates a prompt where the user enters the value .</p><p>9. The value of the radius is read into (or stored in) the variable <em>radius </em>with the help of the scanf ( ) function. The instruction<strong> scanf(&#8220;%f&#8221;, &amp;radius);</strong> is used for reading data.   &#8220;%f&#8221; is a <strong><em>conversion character</em></strong> which is used to accept a floating point value.</p><p>10. The next instruction, <strong>area = 3.14159*radius*radius;</strong> is called an <strong><em> assignment statement. </em></strong>This instruction calculates the area by using the value of radius entered by the user and assigns the value to the variable <em>area. </em></p><p>11. The next printf( ) statement prints the message <em>Area of the circle </em>followed by the calculated area.</p><p>12. The statement <strong>getch();</strong> is used to pause the screen so that you can read the output. If getch( ) is not used the screen will just flash and go away. This function waits for the user to input some character(as it accepts a character as input), after the program has finished executing. Any key present on the keyboard pressed by the user is accepted by the getch function as input and its ASCII value is returned to main( ).</p><p><strong>Example2:</strong> Below is a variation of the above program:</p><pre>/*program to calculate the area of a circle using a user defined function*/
#include &lt;stdio.h&gt;
#include &lt;conio.h&gt;
#define PI 3.14159
float process(float radius);/*function prototype*/
void main()
    {
      float area,radius;
      printf("\n Enter the radius:");
      scanf("%f", &amp;radius);
      area= process(radius);
      printf("Area =%f", area);
      getch();
     }
float process( float r)
     {
     float a; /*local variable declaration*/
     a= PI*r*r;
     return(a);
     }</pre><p>This version utilizes a separate programmer defined function called <strong><em>process</em></strong>, to calculate the area. Within this function, r is an argument (also called a parameter) that accepts the value of radius supplied to <strong><em> process</em></strong> from <strong><em>main</em></strong>, and a is the calculated result returned to main. A reference to the function appears in main( ), within the statement area= process(radius);</p><p>In this statement, the value of area being returned from the function <em>process </em>is stored in the variable area.</p><p>The main function is preceeded by a function prototype, which indicates that there is a user defined function called process which is defined after main and that it accepts a floating point argument and returns a floating point value. If the user defined function <em>process, </em>was defined before main( ), the function prototype would,generally, have not been required.</p><p>More explanation about this when I write about functions in a later article.</p><p>This program also contains a <strong><em>symbolic constant, PI, </em></strong>which represents the numeric value 3. 14159. This is a form of shorthand that exists for the programmers convenience. When the program is actually compiled, the symbolic constant will automatically be replaced by its numerical value. The output of this program is the same as that of the previous program.</p><p>This article was a brief introduction, it gives an idea of C programming. The next article will talk about the fundamental concepts of C which include the C character set, Identifiers and keywords, data types in detail, constants,variables, variable declarations, expressions, statements and symbolic constants .</p> <span
id="pty_trigger"></span><div
style='padding:20px 0px 50px 0px;'><div
style='float:left;padding-left:40px;'><div
id='div-gpt-ad-1335489406190-0' style='width:300px; height:100px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1335489406190-0'); });</script> </div></div><div
style='float:right;padding-right:40px;'><div
id='div-gpt-ad-1335489406190-1' style='width:300px; height:100px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1335489406190-1'); });</script> </div></div><div
style='clear:both'></div></div><div
style='clear:both'></div>]]></content:encoded> <wfw:commentRss>http://www.sitepoint.com/an-introduction-to-c/feed/</wfw:commentRss> <slash:comments>17</slash:comments> </item> <item><title>What&#8217;s New in Chrome 19</title><link>http://www.sitepoint.com/chrome-19-whats-new/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=chrome-19-whats-new</link> <comments>http://www.sitepoint.com/chrome-19-whats-new/#comments</comments> <pubDate>Thu, 17 May 2012 17:24:05 +0000</pubDate> <dc:creator>Craig Buckler</dc:creator> <category><![CDATA[CSS3]]></category> <category><![CDATA[Discussion]]></category> <category><![CDATA[Gems]]></category> <category><![CDATA[JavaScript]]></category> <category><![CDATA[News & Trends]]></category> <category><![CDATA[Open Source]]></category> <category><![CDATA[Opinion]]></category> <category><![CDATA[Web Tech]]></category> <category><![CDATA[browser]]></category> <category><![CDATA[chrome]]></category> <category><![CDATA[Google Tutorials & Articles]]></category> <guid
isPermaLink="false">http://www.sitepoint.com/?p=54727</guid> <description><![CDATA[<img
width="50" height="50" src="http://www.sitepoint.com/wp-content/uploads/1/files/2011/05/518-chrome-11-50x50.png" class="attachment-thumbnail wp-post-image" alt="518-chrome-11" title="518-chrome-11" />Craig looks at several interesting features which have appeared in Google Chrome 19.]]></description> <content:encoded><![CDATA[<img
width="50" height="50" src="http://www.sitepoint.com/wp-content/uploads/1/files/2011/05/518-chrome-11-50x50.png" class="attachment-thumbnail wp-post-image" alt="518-chrome-11" title="518-chrome-11" /><p></p><p>I doubt you noticed but Chrome 19 was released this week. I rarely mention Chrome&#8217;s updates because, well, they&#8217;re rarely worth mentioning. However, I&#8217;ve discovered a few hidden gems in the latest browser&hellip;</p><h2>Tab Syncing</h2><p>The big new feature is tab syncing. If you&#8217;re using Chrome on two or more PCs/smartphones, you <em>should</em> see an <em>&#8220;Other devices&#8221;</em> link on the new tab page. Click it and you can open synchronized links. I say <em>&#8220;should&#8221;</em> because I haven&#8217;t been able to get it working.</p><p>Tab syncing has been available in Firefox for a while so I&#8217;m surprised it&#8217;s taken quite so long to appear in Chrome. Hopefully, you&#8217;ll have better luck than I did.</p><h2>CSS3 calc() Support</h2><p>The webkit team has finally implemented one of my favorite CSS3 features: the little-known <a
href="http://www.sitepoint.com/css3-calc-function/">calc() function</a>. It allows you to define calculated dimensions, e.g.</p><pre><code>
#myelement { width: calc(50% - 2em + 4px); }
</code></pre><p>Chrome supports calc() with the -webkit prefix. Firefox uses -moz and IE9 is happy without prefixes. To use it effectively, you&#8217;ll need fallback code such as:<div
id='div-gpt-ad-1328644474660-10' style='width:728px; height:90px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1328644474660-10'); });</script> </div></p><pre><code>
#myelement
{
	width: 46%;
	width: -webkit-calc(50% - 2em + 4px);
	width: -moz-calc(50% - 2em + 4px);
	width: -o-calc(50% - 2em + 4px);
	width: calc(50% - 2em + 4px);
}
</code></pre><h2>Combined Settings Page</h2><p>Choosing tool &gt; Settings now displays a side menu with History, Extensions, Settings and Help. The Help page provides a couple of links and the update checker which normally appears on the &#8220;About&#8221; dialog <em>(will that disappear soon?)</em></p><h2>New JavaScript/ECMAScript 5.1 (Harmony) Features</h2><p>A number of <a
href="http://blog.chromium.org/2012/02/future-of-javascript-take-peek-today.html">experimental JavaScript features</a> have made their way from the Harmony specification into Chrome&#8217;s V8 engine. However, they&#8217;re not available by default &#8212; you&#8217;ll need to &#8220;Enable Experimental JavaScript&#8221; in <a
href="http://www.sitepoint.com//flags" class="broken_link">chrome://flags</a>. Language structures such as collections and proxies look great, but it&#8217;ll be some time before they&#8217;re available in all browsers.</p><h2>Security and Bug Fixes</h2><p>21 issues have been fixed in Chrome 19 and Google has paid almost $15,000 to eagle-eyed security hackers.</p><p>Chrome has remained fast and stable. It looks set to knock IE from the top of the <a
href="http://www.sitepoint.com/browser-trends-may-2012/">browser usage chart</a> during the summer of 2012. I&#8217;m not convinced any other vendor can prevent Google&#8217;s domination of the web and the software we use to access it.</p> <span
id="pty_trigger"></span><div
style='padding:20px 0px 50px 0px;'><div
style='float:left;padding-left:40px;'><div
id='div-gpt-ad-1335489406190-0' style='width:300px; height:100px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1335489406190-0'); });</script> </div></div><div
style='float:right;padding-right:40px;'><div
id='div-gpt-ad-1335489406190-1' style='width:300px; height:100px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1335489406190-1'); });</script> </div></div><div
style='clear:both'></div></div><div
style='clear:both'></div>]]></content:encoded> <wfw:commentRss>http://www.sitepoint.com/chrome-19-whats-new/feed/</wfw:commentRss> <slash:comments>7</slash:comments> </item> <item><title>Two New Proposals to Solve the CSS3 Vendor Prefix Crisis</title><link>http://www.sitepoint.com/css3-vendor-prefix-crisis-solutions-2/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=css3-vendor-prefix-crisis-solutions-2</link> <comments>http://www.sitepoint.com/css3-vendor-prefix-crisis-solutions-2/#comments</comments> <pubDate>Tue, 15 May 2012 15:41:07 +0000</pubDate> <dc:creator>Craig Buckler</dc:creator> <category><![CDATA[CSS Tutorials]]></category> <category><![CDATA[CSS3]]></category> <category><![CDATA[Discussion]]></category> <category><![CDATA[HTML & CSS]]></category> <category><![CDATA[HTML5]]></category> <category><![CDATA[News & Trends]]></category> <category><![CDATA[Web Tech]]></category> <category><![CDATA[CSS]]></category> <category><![CDATA[HTML5 Dev Center]]></category> <category><![CDATA[HTML5 Tutorials & Articles]]></category> <category><![CDATA[vendor prefixes]]></category> <guid
isPermaLink="false">http://www.sitepoint.com/?p=54609</guid> <description><![CDATA[<img
width="50" height="50" src="http://www.sitepoint.com/wp-content/uploads/1/files/2012/02/641-css-vendor-prefix-crisis-50x50.jpg" class="attachment-thumbnail wp-post-image" alt="641-css-vendor-prefix-crisis" title="641-css-vendor-prefix-crisis" />Craig discusses two new proposals which could prevent the CSS3 vendor prefix catastrophe before it begins.]]></description> <content:encoded><![CDATA[<img
width="50" height="50" src="http://www.sitepoint.com/wp-content/uploads/1/files/2012/02/641-css-vendor-prefix-crisis-50x50.jpg" class="attachment-thumbnail wp-post-image" alt="641-css-vendor-prefix-crisis" title="641-css-vendor-prefix-crisis" /><p></p><p>Web developers have been concerned about the <a
href="http://www.sitepoint.com/w3c-css-webkit-prefix-crisis/">vendor prefix crisis</a> since February 2012. To summarize the issue, this is what should happen in an ideal world:</p><ol><li>Vendors implement experimental CSS3 properties using their own prefix, e.g. -webkit-transform, -moz-transform, -ms-transform, -o-transform.</li><li>Developers can use the technologies today without breaking cross-browser compatibility. Properties can be listed with their prefixed and unprefixed names to ensure they work everywhere.</li><li>Once a property becomes a W3C recommendation, all browser vendors can provide a stable unprefixed property, e.g. transform.</li><li>Optionally, developers can remove the prefixed properties from their stylesheets. However, it&#8217;s not strictly necessary if the unprefixed property is defined last and CSS cascade rules apply.</li></ol><p>This is what occurs in the real world:</p><ol><li>Vendors implement experimental CSS3 properties using their own prefix. In some cases, vendors promote them as an HTML5 <em>&#8220;standard&#8221;</em> even if they&#8217;re device-specific or never submitted to the W3C.</li><li>Some developers use the proprietary property from a single vendor, e.g. only -webkit-transform. This might be owing to ignorance, laziness or because they&#8217;re testing a limited number of devices.</li><li>Once a property becomes a W3C recommendation, all browser vendors can provide a stable unprefixed property, e.g. transform&hellip;</li><li>but developers neglect to change their stylesheets. The site looks good in some browsers but worse in others even when they support the standard W3C specification.</li><li>The vendors become concerned and add support for other prefixes into their browser, i.e. <a
href="http://www.sitepoint.com/opera-css3-webkit-prefix/">Opera implements the -webkit prefix for some properties</a>. The prefix process is broken and, while it&#8217;s too early to predict the outcome, the majority of developers consider it to be a bad move.</li></ol><p>We have discussed the issues at length on SitePoint; <a
href="http://www.sitepoint.com/css3-vendor-prefix-crisis-solutions/">there are no easy solutions</a>. However, two interesting proposals have been raised by W3C members during the past week.<div
id='div-gpt-ad-1328644474660-10' style='width:728px; height:90px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1328644474660-10'); });</script> </div></p><h2>Option 1: Unprefixed Properties are Supported From Day One</h2><p>The first proposal comes from Florian Rivoal, Opera&#8217;s W3C representative:</p><blockquote><p> When a browser vendor implements a new CSS feature, it should support it, from day 1, both prefixed and unprefixed, the two being aliased. If a style sheet contains both prefixed and unprefixed, the last one wins, according to the cascade.</p><p>Authors should write their style sheets using the unprefixed property, and only add a prefixed version of the property (below the unprefixed one) if they discover a bug or inconsistency that they need to work around in a particular browser.</p><p>If a large amount of content accumulates using the a particular vendor prefix to work around an issue with the early implementation in that browser, the vendor could decide to freeze the behavior of the prefixed property while continuing to improve the unprefixed one.</p></blockquote><p>For example, you could use the following transform code in your CSS:</p><pre><code>
transform: rotate(30deg);
</code></pre><p>The property would be ignored by all browsers which had not implemented transforms. If there were a difference between two or more implementations, e.g. webkit browsers rotated anti-clockwise by default, you could override the property accordingly, e.g.</p><pre><code>
transform: rotate(30deg);
-webkit-transform: rotate(-30deg);
</code></pre><p>It&#8217;s a simple solution and easy to implement. Most existing stylesheets would continue to work and prefixed properties would rarely be necessary. In most cases, you would never need to update your CSS again.</p><p>However, what would happen if webkit changed rotation to the W3C-approved clockwise direction? Developers would need to fix their stylesheets by removing or rearranging the <code>-webkit-transform: rotate(-30deg);</code> property. Unfortunately, not everyone uses the same version of the webkit engine at the same time. You could encounter a situation where your site works in Chrome but not in Safari for several months.</p><h2>Option 2: A New Vendor-Draft Modifier</h2><p>The second proposal comes from Fran&ccedil;ois Remy:</p><blockquote><p> Let&#8217;s introduce the &#8220;!vendor-draft&#8221; value modifier. I propose we use unprefixed properties from start, but with a token explaining which version of the property we built our CSS for:<br
/> <code>border-radius: 3px !webkit-draft;</code></p><p>Any browser which is not webkit but implemented border-radius in a way that is compatible with the &#8220;webkit draft&#8221; can support the declaration. This is different from vendor prefixes: other browsers don&#8217;t impersonate webkit, they just acknowledge they support one specific property the way the webkit draft defines it. Browsers which are not compatible with that draft will just ignore the declaration. Browsers that change their implementation of a property are encouraged to iterate their &#8220;!vendor-draft&#8221; flag (using a version number, if appropriate).</p></blockquote><p>This solves the issue by changing the property value rather than its name (in a similar way to the <code>!important</code> modifier). Again, the following transform code could be used:</p><pre><code>
transform: rotate(30deg);
</code></pre><p>But a default anti-clockwise rotation could be fixed in any browser adhering to a webkit specification:</p><pre><code>
transform: rotate(30deg);
transform: rotate(-30deg) !webkit-draft;
</code></pre><p>If a browser subsequently supported the W3C specification, the second property would be ignored.</p><p>It would also be possible to implement draft versioning, e.g.</p><pre><code>
transform: rotate(30deg);
transform: rotate(-30degrees) !webkit-draft;
transform: rotate(-30deg) !webkit-draft-2;
</code></pre><p>It&#8217;s a flexible solution which finally addresses the issue of properties evolving over time.</p><p>Unfortunately, it&#8217;s more difficult to implement and could take months to appear in browsers even if all vendors agreed today. It may be technically better, but it&#8217;s a fundamentally different approach which could break existing stylesheets. In the short term, vendors would probably support both prefixes and value modifiers &#8212; and that would lead to confusion.</p><p>I like both solutions. From a coding perspective, vendor-draft modifiers seems the most logical option but I doubt it can be considered until vendors <em>&#8220;complete&#8221;</em> CSS3 and begin work on CSS4.</p><p>Supporting unprefixed properties is more practical but will certainly cause versioning issues which couldn&#8217;t be fixed in CSS alone. But perhaps that&#8217;s the price you pay for using experimental technology?</p><p>Do you have a preference for either of these options? Or is it too late to prevent a vendor prefix catastrophe?</p> <span
id="pty_trigger"></span><div
style='padding:20px 0px 50px 0px;'><div
style='float:left;padding-left:40px;'><div
id='div-gpt-ad-1335489406190-0' style='width:300px; height:100px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1335489406190-0'); });</script> </div></div><div
style='float:right;padding-right:40px;'><div
id='div-gpt-ad-1335489406190-1' style='width:300px; height:100px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1335489406190-1'); });</script> </div></div><div
style='clear:both'></div></div><div
style='clear:both'></div>]]></content:encoded> <wfw:commentRss>http://www.sitepoint.com/css3-vendor-prefix-crisis-solutions-2/feed/</wfw:commentRss> <slash:comments>34</slash:comments> </item><div><div
class="post_box two_ads" style="float:left;padding-left:2px;"><div
id='div-gpt-ad-1328645237920-1' style='width:728px; height:90px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1328645237920-1'); });</script> </div></div></div><div
class="clear">&nbsp;</div> <item><title>Ubuntu 12.04 LTS Precise Pangolin: Networking tips and tricks</title><link>http://www.sitepoint.com/ubuntu-12-04-lts-precise-pangolin-networking-tips-and-tricks/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ubuntu-12-04-lts-precise-pangolin-networking-tips-and-tricks</link> <comments>http://www.sitepoint.com/ubuntu-12-04-lts-precise-pangolin-networking-tips-and-tricks/#comments</comments> <pubDate>Mon, 14 May 2012 15:00:50 +0000</pubDate> <dc:creator>Jonathan Hobson</dc:creator> <category><![CDATA[Web Tech]]></category> <category><![CDATA[WebOS]]></category> <category><![CDATA[Ubuntu]]></category> <guid
isPermaLink="false">http://www.sitepoint.com/?p=54343</guid> <description><![CDATA[<img
width="50" height="39" src="http://www.sitepoint.com/wp-content/uploads/1/files/2012/04/ubuntu-50x39.png" class="attachment-thumbnail wp-post-image" alt="ubuntu" title="ubuntu" />Networking is often regarded to be complicated and very difficult to manage but as it forms an essential role in the day-to-day use of your computer the purpose of this article is to expose a few &#8216;tips and tricks&#8217; that will serve to improve your computers connectivity and overall performance by showing you how easy [...]]]></description> <content:encoded><![CDATA[<img
width="50" height="39" src="http://www.sitepoint.com/wp-content/uploads/1/files/2012/04/ubuntu-50x39.png" class="attachment-thumbnail wp-post-image" alt="ubuntu" title="ubuntu" /><p></p><p>Networking is often regarded to be complicated and very difficult to manage but as it forms an essential role in the day-to-day use of your computer the purpose of this article is to expose a few &#8216;tips and tricks&#8217; that will serve to improve your computers connectivity and overall performance by showing you how easy it is to take control of Ubuntu 12.04, LTS Precise Pangolin.</p><p>So let&#8217;s get started &#8230;</p><h2>What is my local IP address</h2><p>It may be a easy question to begin with, but in a world of complexity it is often the simple questions that get overlooked.</p><h3>Using the graphical tools:</h3><p>Right click on the &#8216;networking icon&#8217; in the top panel of the Ubuntu desktop and choose &#8216;Connection Information&#8217; as shown below:</p><p><a
href="http://www.sitepoint.com/?attachment_id=54344" rel="attachment wp-att-54344"><img
class="alignnone size-full wp-image-54344" src="http://www.sitepoint.com/wp-content/uploads/1/files/2012/05/u1.jpg" alt="" width="500" height="486" /></a></p><p>The resulting dialogue box will then provide feedback on your current settings.</p><h3>Using the command line interface:</h3><p>On the other hand, for those individuals who are beginning to enjoy the power of Terminal or for those of you who use a server (via the Console or Putty or similar).<div
id='div-gpt-ad-1328644474660-10' style='width:728px; height:90px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1328644474660-10'); });</script> </div></p><p>If you have a wireless based connection, run:</p><pre>iwconfig</pre><p>If you have a &#8216;wired&#8217; connection, run</p><pre>ifconfig</pre><p>The results for &#8216;ifconfig&#8217; will look something like this:</p><pre>eth0      Link encap:Ethernet  HWaddr 00:1d:92:65:09:e1
          inet addr:192.168.1.100  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::21d:92ff:fe65:9e1/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:510 errors:0 dropped:0 overruns:0 frame:0
          TX packets:315 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:80353 (80.3 KB)  TX bytes:38731 (38.7 KB)
          Interrupt:42 Base address:0xa000
lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:108 errors:0 dropped:0 overruns:0 frame:0
          TX packets:108 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:8176 (8.1 KB)  TX bytes:8176 (8.1 KB)</pre><p>And because the command line provides us with additional opportunities, if you would like to quickly identify all the available ethernet devices on your computer, you can run</p><pre>ifconfig -a | grep eth</pre><p>The result will look something like this:</p><pre>eth0      Link encap:Ethernet  HWaddr 00:1d:92:65:09:e1</pre><p>Well done, but just before we finish-up I would like to take this opportunity to show you another useful command that can help identify all the network interfaces available to your system. Known as the &#8216;lshw&#8217; command, this tool will not only detail your ethernet devices but it will also provide a plethora of information on your hardware&#8217;s &#8216;other&#8217; capabilities.</p><p>To use this tool, simply run the following command and wait a few seconds whilst Ubuntu quieries your devices:</p><pre>sudo lshw -class network</pre><p>And the result will look something like this:</p><pre>  *-network
       description: Ethernet interface
       product: RTL8111/8168B PCI Express Gigabit Ethernet controller
       vendor: Realtek Semiconductor Co., Ltd.
       physical id: 0
       bus info: pci@0000:02:00.0
       logical name: eth0
       version: 01
       serial: 00:1d:92:65:09:e1
       size: 100Mbit/s
       capacity: 1Gbit/s
       width: 64 bits
       clock: 33MHz
       capabilities: pm vpd msi pciexpress bus_master cap_list rom ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd 1000bt 1000bt-fd autonegotiation
       configuration: autonegotiation=on broadcast=yes driver=r8169 driverversion=2.3LK-NAPI duplex=full firmware=N/A ip=192.168.1.160 latency=0 link=yes multicast=yes port=MII speed=100Mbit/s
       resources: irq:43 ioport:d800(size=256) memory:feaff000-feafffff memory:feac0000-feadffff</pre><p>Sometimes you&#8217;ve just &#8216;gotta&#8217; love the details, but now we know something about our computer we can begin to take control :-)</p><h2>How do I create a static IP address with the Network Manager</h2><p>The following instruction shows you how to create a fixed (or static) IP address with the Network Manager.</p><p>This approach is best suited to all desktop users who may require the need to keep the functionality of the Network Manager or for those that use netbooks, laptops and and other wireless connections that may require a DHCP based option in the future. Don&#8217;t worry, it is all very simple:</p><p>Click the network menu on the top panel (the &#8216;up/down&#8217; arrows icon) and select &#8216;Edit Connections&#8217;.</p><p>Alternatively you can choose System Settings &gt; Network &gt; Choose your &#8216;Network Connection&#8217; from the left hand panel and select &#8216;Options&#8217;.</p><p><a
href="http://www.sitepoint.com/?attachment_id=54345" rel="attachment wp-att-54345"><img
class="alignnone size-full wp-image-54345" src="http://www.sitepoint.com/wp-content/uploads/1/files/2012/05/u2.jpg" alt="" width="500" height="400" /></a></p><p>Now choose the relevant connection and click edit.</p><p>For example, if you are using a &#8216;wired connection&#8217;, choose the &#8216;wired&#8217; tab to find your connection.</p><p><a
href="http://www.sitepoint.com/?attachment_id=54346" rel="attachment wp-att-54346"><img
class="alignnone size-full wp-image-54346" src="http://www.sitepoint.com/wp-content/uploads/1/files/2012/05/u3.jpg" alt="" width="500" height="583" /></a></p><p>In the resulting dialogue box you should:</p><ul><li>Select the &#8216;IPv4 Settings&#8217; tab and change the &#8216;Method&#8217; to &#8216;Manual&#8217;.</li><li>Click Add and complete each field with your IP address, network mask and default gateway.Always press the &#8216;Enter/Return&#8217; when you&#8217;ve finished typing each address otherwise the dialogue will fail to accept your new settings and the &#8216;save&#8217; button will remain inactive/greyed-out.</li><li>Include the IP addresses of the DNS servers. Multiple addresses should be separated by commas.</li><li>Click Save and close the remaining dialogue boxes.</li></ul><p>And there you go &#8230;</p><p>If all is well you should be able to view web sites and/or view your local network but in some situations and depending on your network topology a reboot may be necessary.</p><p>To confirm your new settings, simply check your connection settings as shown previously (see above)</p><p><strong>But what if I need DHCP again?</strong><br
/> If you ever need to return to a dynamically assigned IP address simply re-run the previous steps. Find your current connection, select the &#8216;IPv4 Settings&#8217; tab and change the &#8216;Method&#8217; to &#8216;Automatic (DHCP)&#8217;. To finalise this reversal click save and reboot (depending on the network conditions and how the DHCP server is configured).</p><h2>Disable the Network Manager and &#8216;hard-code&#8217; a static IP address</h2><p>This solution explains how to create a fixed (or static) IP address without using the Network Manager.</p><p>The Network Manager is a very nice feature, but only suitable for individuals who require dynamically assigned connections or those who require wireless connectivity. Yes, it is true to say that these are both very popular in homes and offices throught the world but for those of us who use and prefer the benefit of a &#8216;wired connection&#8217; using the Network Manager does come at the cost of performance. So this solution uses the traditional approach to &#8216;hard-coding&#8217; your network connection and it is most suitable to those individuals who demand maximum performance or absolute stability.</p><blockquote><p>By using this approach you should note that we will not be removing the Network Manager, merely disabling it with the intention to capitalise on the performance gains by by-passing or side-stepping this device. These performance gains will not only be noticed in terms of network speed but also in terms of the computer in general.</p></blockquote><p>Again, don&#8217;t worry, the process to disable the Network Manager is very simple but it will require us to run various &#8216;commands&#8217; in Terminal in order to complete some steps.</p><p>So let&#8217;s begin by making a backup of our original file.</p><p>In Terminal type:</p><pre>sudo cp /etc/NetworkManager/NetworkManager.conf /etc/NetworkManager/NetworkManager.conf.bak</pre><blockquote><p>This will serve to back-up our original file to &#8216;/etc/NetworkManager/NetworkManager.conf.bak&#8217;. Hopefully you will not need it, but if you ever need to restore the original file simply open Terminal and reverse the command like so: &#8216;sudo cp /etc/NetworkManager/NetworkManager.conf.bak /etc/NetworkManager/NetworkManager.conf&#8217; and reboot.</p></blockquote><p>And with the confidence that we are fully backed-up we shall now proceed to disable the Network Manager.</p><p>In Terminal, type:</p><pre>sudo gedit /etc/NetworkManager/NetworkManager.conf</pre><p>This will open the &#8216;NetworkManager.conf&#8217; file in our text editor.</p><p>Now change:</p><p>managed=false</p><p>to</p><p>managed=true</p><p>So it looks like this:</p><p><a
href="http://www.sitepoint.com/?attachment_id=54347" rel="attachment wp-att-54347"><img
class="alignnone size-full wp-image-54347" src="http://www.sitepoint.com/wp-content/uploads/1/files/2012/05/u4.jpg" alt="" width="500" height="409" /></a></p><p>When done, save the file and close it.</p><blockquote><p>You can re-enable the network manager at any time by simply reversing the steps shown above or by restoring your back-up file. Remember to reboot in order to apply these changes.</p></blockquote><p>Now we have successfully disabled the Network Manager we can proceed to create our Static IP address by making some direct changes to the &#8216;interface&#8217; file; but with safety in mind let&#8217;s begin by making a backup of our original file.</p><p>In Terminal and type:</p><pre>sudo cp /etc/network/interfaces /etc/network/interfaces.bak</pre><blockquote><p>This will back-up our original file to /etc/network/interfaces.bak. Again, it is not expected that we will need it but if you ever need to restore it open Terminal and reverse the command like so: sudo cp /etc/network/interfaces.bak /etc/network/interfaces</p></blockquote><p>Now lets add our static IP address.</p><p>In Terminal type:</p><pre>sudo gedit /etc/network/interfaces</pre><p>Authenticate yourself in the usual way and then replace the file contents as shown below, where xxx represents values relevant to your needs:</p><pre>auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
	address 	xxx.xxx.xxx.xxx
	netmask 	xxx.xxx.xxx.xxx
	network 	xxx.xxx.xxx.xxx
	broadcast 	xxx.xxx.xxx.xxx
	gateway 	xxx.xxx.xxx.xxx</pre><p>And to help you out, here is an example with an explanation of the values concerned:</p><pre>auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
	address 	192.168.1.100 	(this is my computers IP address)
	netmask 	255.255.255.0 	(this is my subnet mask)
	network 	192.168.1.0	(this is my network base address)
	broadcast 	192.168.1.255	(this is my broadcast address)
	gateway 	192.168.1.254	(this is my gateway/router's ip address)</pre><p>When complete, simply save and close the file and reboot your computer to complete these steps.</p><p>We are re-booting our computer at this point in order to &#8216;dis-engage&#8217; the Network Manager, and once complete you can always re-configure your IP address at any time by making the necessary changes to the &#8216;interfaces&#8217; file (shown above) and using the following command to restart your networking service: &#8216;sudo /etc/init.d/networking restart&#8217;.</p><p>After you restart your computer you will discover (visually) that nothing has changed but as a consequence you should be experiencing a &#8216;more&#8217; responsive computer and network connection.</p><blockquote><p>Should you ever want to re-enable the Network Manager. Simply reverse the steps we have taken above and/or restore you back-up files and reboot and as we created them with the &#8216;cp&#8217; or copy command &#8211; unless you delete them, your original backup files will always remain for future reference.</p></blockquote><h2>Create Virtual Network Adapters (add more than 1 IP address to a single ethernet card)</h2><p>In some situations this can be very useful and as an extension to our previous solution of &#8216;disabling the network manager and hard-coding a static IP address&#8217; I will now show you how to assign more than one IP address to the same ethernet card:</p><p>In Terminal type:</p><pre>sudo gedit /etc/network/interfaces</pre><p>Authenticate yourself and then replace the file contents like so, where xxx represents values relevant to your needs:</p><pre>auto lo
iface lo inet loopback
auto eth0
iface eth0 static
	address 	xxx.xxx.xxx.xxx
	netmask 	xxx.xxx.xxx.xxx
	network 	xxx.xxx.xxx.xxx
	broadcast 	xxx.xxx.xxx.xxx
	gateway 	xxx.xxx.xxx.xxx
auto eth0:0
iface eth0:0 static
	address 	xxx.xxx.xxx.xxx
	netmask 	xxx.xxx.xxx.xxx
	gateway 	xxx.xxx.xxx.xxx</pre><p>And to make this as simple as possible, here is an example:</p><pre>auto lo
iface lo inet loopback
auto eth0
iface eth0 static
	address 	192.168.1.100
	netmask 	255.255.255.0
	network 	192.168.1.0
	broadcast 	192.168.1.255
	gateway 	192.168.1.254
auto eth0:0
iface eth0:0 static
	address 	192.168.1.101
	netmask 	255.255.255.0
	gateway 	192.168.1.254</pre><p>By doing this I will be adding two IP addresses to my a single ethernet card. It will not only have the IP address of 192.168.1.100 but it will also have the alternative address of 192.168.1.101 (as a virtual instance).</p><p>The trick is to follow the virtual naming scheme (i.e. eth0:0, eth0:1, eth0:2 etc &#8230;) and to ensure that every instance maintains a unique IP address. In this way you can create as many &#8216;instances&#8217; of an IP address as required.</p><p>To illustrate this point, let&#8217;s add a third IP address to our example:</p><pre>auto lo
iface lo inet loopback
auto eth0
iface eth0 static
	address 	192.168.1.100
	netmask 	255.255.255.0
	network 	192.168.1.0
	broadcast 	192.168.1.255
	gateway 	192.168.1.254
auto eth0:0
iface eth0:0 static
	address 	192.168.1.101
	netmask 	255.255.255.0
	gateway 	192.168.1.254
iface eth0:1 static
	address 	192.168.1.102
	netmask 	255.255.255.0
	gateway 	192.168.1.254</pre><p>When complete, remember to reboot your computer to apply the changes or open Terminal and type:</p><pre>sudo /etc/init.d/networking restart</pre><p>You can then run &#8216;ifconfig&#8217; to view your new settings.</p><p>Have fun ..!</p><h2>Change your computer&#8217;s hostname</h2><p>You may like your current computer name, or you may want to change it.</p><p>In this short recipe I will show you how to view and change your computer name with relative ease &#8230;</p><p>In Terminal type:</p><pre>sudo gedit /etc/hostname</pre><p>The file will probably look something like this:</p><pre>ubuntu-computername</pre><p>To change the name of your computer, simply delete the existing content and replace as required.</p><p>Remember, the actual name can be anything your want as long as you remember some basic principles:</p><ul><li>Desktops generally use a singular name (as shown above) whereas all servers or &#8216;desktops acting as servers&#8217; should be in the format of computername.computerdomain.suffix.</li><li>On a local network computers should refrain from using the standard or typical internet based suffix or TLD unless your local DNS can account for such similarities.</li><li>Use &#8216;internet friendly&#8217; names and do not use a computer name that already exists on your network.</li><li>Do not use spaces or non-internet friendly characters.</li></ul><p>Once complete, simply choose &#8216;save&#8217;, &#8216;close&#8217; the file and reboot your computer to see the changes.</p><p>Your new computer name will be in the top-left hand side of the login screen but if you missed this or need to confirm your current or new hostname at any time.</p><p>Open Terminal and type:</p><pre>sudo hostname</pre><p>And the result should reflect the changes you made &#8230;</p><h2>Managing the Hosts file</h2><p>The hosts file file consists of a list of IP addresses and corresponding hostnames. Most users may never need to touch this area of their computer but there maybe an occasion when you need to edit the hosts file on your machine. This can because of any number of reasons (i.e. reversing the effect of malicious activity) or it can be because your are trying to make your life that little &#8216;quicker&#8217; buy &#8216;hard-coding&#8217; the address of an internal or external web site. Similarly, if your network contains computers whose IP addresses that are not listed in an existing DNS record, then it is recommended that you add them to the hosts file. So with this in mind I will now show you how to manage you hosts file.</p><p>Before you begin, you can make a back-up of this file by simply typing the following command in to Terminal:</p><pre>sudo cp /etc/hosts /etc/hosts.bak</pre><p>Now, to proceed and customise your hosts file simply return to the command line and type:</p><pre>sudo gedit /etc/hosts</pre><p>A typical desktop file will look like this (simply substitue the example values with those relevant to your computer):</p><pre>127.0.0.1			localhost
127.0.1.1			ubuntu-computername
# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters</pre><p>However, having said that and just for the record, for the &#8216;server&#8217; or &#8216;desktop server&#8217; version of the same file should look more like this:</p><pre>127.0.0.1       localhost.localdomain   localhost
192.168.1.100 	ubuntu-computername.ubuntu-domainname.lan  ubuntu-computername
# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters</pre><p>You will notice that my examples include the IPv6 instruction and this is entirely at your discretion as it depends on whether your network supports it.</p><p>For example, you may ignore these values (not include them or comment them out by placing a &#8216;hash&#8217; character at the beginning of the line) like so if your computer does not use IPv6.</p><pre># The following lines are desirable for IPv6 capable hosts
#::1     ip6-localhost ip6-loopback
#fe00::0 ip6-localnet
#ff00::0 ip6-mcastprefix
#ff02::1 ip6-allnodes
#ff02::2 ip6-allrouters</pre><p>Of course, disabling IPv6 is optional and can sometimes improve performance but if you are in doubt, simply ignore them (but as they sometimes say in &#8216;old blighty&#8217; &#8211; &#8216;don&#8217;t fix what ain&#8217;t broke&#8217;).</p><p>So getting back on track &#8230;</p><p>In your hosts file you may want to include a list or pre-identified servers and workstations in order to speed-up name resolution like so:</p><pre>192.168.1.200		servername1 www servername1.localdomain.lan
192.168.1.200		servername2 mail servername2.localdomain.lan</pre><blockquote><p>In my example I have included an alias in addition to the actual names &#8211; i.e. servername1 is also known as www and servername2 is also known as mail. You do not need to do this as my other examples will show.</p></blockquote><p>Windows (and Mac) users should notice that this process very similar to customisng the &#8216;hosts&#8217; file on any Windows/Mac based operating system and the resulting file could look like this:</p><pre>127.0.0.1			localhost
127.0.1.1			ubuntu-computername
# PUT YOU COMMENT AFTER A HASH (#) FOR REFERENCE - NOT REQUIRED BUT USEFUL
192.168.1.200		www.website1.com
192.168.1.201		www.website2.com
# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters</pre><p>Consequently, my computer will now use the IP address for www.website1.com instead of searching a DNS record thereby ensuring that my ability to view the website in question would be quicker than before.</p><p>Taking this one step further &#8230; and by giving it a little twist.</p><p>For those of you who wish to excercise some &#8216;parental power&#8217; you could easily use this as a way to block direct access to some &#8216;unwanted web sites&#8217; by sending someone who expects to go to www.website1.com to www.website2.com, like so:</p><pre>#192.168.1.200	www.website1.com
192.168.1.201		www.website1.com
192.168.1.201		www.website2.com
192.168.1.202		www.website3.com
192.168.1.123		www.website4.com
192.168.1.167		www.website5.com</pre><p>Notice I have commented out the real address of website1 with a hash (#) and that both website1 and website 2 now have the same IP address &#8230; (the IP address being the actual address of website2)</p><p>It isn&#8217;t a perfect of solution by any means but it is food for thought and can serve as a starting point for future development ;-)</p><h2>How to re-configure DNS resolution</h2><p>The purpose of this section is to show you how to configure the appropriate nameserver to use when resolving IP address to hostnames and vice versa. It is not intended to explain how to configure the system as a name server as this is something I will be covering in a future article. You should only affect this file if you are not using the Network Manager and want to use a static IP address.</p><blockquote><p>The resolv.conf file is the resolver configuration file and it is used to configure workstation or server access to the Internet Domain Name System (DNS). This file defines which nameservers to use and in what order they are tried. You should therefore put the most reliable server first. It is convention that up to three name servers are supported. However, if no nameserver option is given, the resolver will attempt to connect to the name server on the local host.</p></blockquote><p>Resolv.conf still does this, but with the release of the Precise Pangolin a few things have changed, and regardless as to whether you are running a desktop or a server your system is probably running the resolveconf program:</p><p>&#8216;Resolveconf&#8217; is a small program that resides in &#8216;/etc/resolvconf&#8217; that dynamically modifies the nameserver information on boot. It is a useful tool, but for our purposes it can be disruptive, so we are going to work around it by simply adding a new entry to our &#8216;/etc/network/interfaces&#8217; file:</p><p>In Terminal type:</p><pre>sudo gedit /etc/network/interfaces</pre><p>Now add the following nameserver line to your file, changing XXX to something more applicable to your needs:</p><pre>dns-nameservers xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx</pre><p>Similar to the example shown above here is the new file using Google&#8217;s public nameservers:</p><pre>auto lo
iface lo inet loopback
auto eth0
iface eth0 static
	address 	192.168.1.100
	netmask 	255.255.255.0
	network 	192.168.1.0
	broadcast 	192.168.1.255
	gateway 	192.168.1.254
        dns-nameservers 8.8.8.8 8.8.4.4</pre><p>When complete, click &#8216;save&#8217;, then &#8216;close&#8217; the file and reboot to apply the changes.</p><p>On reboot, you can see that the new nameserver information has now been applied to our &#8216;resolve.conf&#8217; file by opening Terminal and typing:</p><pre>cat /etc/resolv.conf</pre><p>Which may look something like this:</p><pre># Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 127.0.0.1</pre><p>So having made your changes, to query the DNS capabilities of your system, simply return to the command line and type:</p><pre>nslookup www.sitepoint.com</pre><p>or alternatively try</p><pre>dig www.sitepoint.com</pre><p>And that&#8217;s it for now &#8230; but most of all, have fun :-)</p><p>So until next time &#8230;</p><p>I hope that you continue to enjoy using Ubuntu 12.04 LTS Precise Pangolin.</p> <span
id="pty_trigger"></span><div
style='padding:20px 0px 50px 0px;'><div
style='float:left;padding-left:40px;'><div
id='div-gpt-ad-1335489406190-0' style='width:300px; height:100px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1335489406190-0'); });</script> </div></div><div
style='float:right;padding-right:40px;'><div
id='div-gpt-ad-1335489406190-1' style='width:300px; height:100px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1335489406190-1'); });</script> </div></div><div
style='clear:both'></div></div><div
style='clear:both'></div>]]></content:encoded> <wfw:commentRss>http://www.sitepoint.com/ubuntu-12-04-lts-precise-pangolin-networking-tips-and-tricks/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Scalable Vector Graphics: an Overview</title><link>http://www.sitepoint.com/svg-scalable-vector-graphics-overview/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=svg-scalable-vector-graphics-overview</link> <comments>http://www.sitepoint.com/svg-scalable-vector-graphics-overview/#comments</comments> <pubDate>Fri, 11 May 2012 18:30:38 +0000</pubDate> <dc:creator>Craig Buckler</dc:creator> <category><![CDATA[Client Side Coding]]></category> <category><![CDATA[Design]]></category> <category><![CDATA[HTML & CSS]]></category> <category><![CDATA[HTML5]]></category> <category><![CDATA[Web Tech]]></category> <category><![CDATA[canvas]]></category> <category><![CDATA[HTML5 Dev Center]]></category> <category><![CDATA[SVG]]></category> <guid
isPermaLink="false">http://www.sitepoint.com/?p=54386</guid> <description><![CDATA[<img
width="50" height="50" src="http://www.sitepoint.com/wp-content/uploads/1/files/2012/05/672-svg-basics-50x50.png" class="attachment-thumbnail wp-post-image" alt="672-svg-basics" title="672-svg-basics" />Craig provides a concise overview of Scalable Vector Graphics and its associated technologies.]]></description> <content:encoded><![CDATA[<img
width="50" height="50" src="http://www.sitepoint.com/wp-content/uploads/1/files/2012/05/672-svg-basics-50x50.png" class="attachment-thumbnail wp-post-image" alt="672-svg-basics" title="672-svg-basics" /><p></p><p>In my recent article, we discussed <a
href="http://www.sitepoint.com/7-reasons-to-consider-svgs-instead-of-canvas/">7 Reasons to Consider SVGs Instead of Canvas</a>. SVGs are ideal if you require a scalable diagram such as a chart or logo which can be altered or animated using JavaScript DOM methods.</p><p>So &hellip; <em>what are SVGs and how do we use them?</em> This is the first part in a series articles about the vector image format.</p><h2>What Are SVGs?</h2><p>SVGs are vector graphics. Rather than defining the color of each pixel like you would in a bitmap (JPEG, PNG, GIF, BMP etc.), vector graphics define lines and shapes, e.g. draw a black line from co-ordinate 0,0 to 100,100. This has a number of advantages: vectors are easy to modify, generally require smaller files and are scalable to any dimension without losing quality &#8212; which makes them ideal for responsive web design. Bitmaps remain the best choice for photographs or very complex images (note that SVGs can include embedded bitmaps).</p><p><img
src="http://blogs.sitepointstatic.com/images/tech/672-svg-basics-vector.png" width="339" height="267" alt="vector vs bitmap comparison" class="center" style="margin:20px auto" /></p><p>SVG is a royalty-free web standard maintained by the <a
href="http://www.w3.org/Graphics/SVG/">W3C SVG Working Group</a>. Version 1.0 of the technology was originally proposed in 1999. <a
href="http://www.w3.org/TR/SVG11/">Version 1.1</a> is the most recent standard with <a
href="http://www.w3.org/Graphics/SVG/WG/wiki/Roadmap">version 2.0</a> expected in 2013.<div
id='div-gpt-ad-1328644474660-10' style='width:728px; height:90px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1328644474660-10'); });</script> </div></p><p>There are a couple of other flavors: <a
href="http://www.w3.org/TR/SVGTiny12/">SVG Tiny</a> and <a
href="http://www.w3.org/TR/SVGMobile/">SVG Mobile</a>. These are simplified profiles or subsets of the full SVG specification which target devices with reduced computational and display capabilities. These standards largely relate to how rendering engines parse the image; an SVG 1.1 file can be rendered on a device which supports SVG Tiny but some effects such as gradients and opacities would not be applied.</p><h2>How are SVGs Defined?</h2><p>SVGs are declared using eXtensible Markup Language (XML). It uses tags like HTML &#8212; the following code draws a white circle with a black border:</p><pre><code>
&lt;circle cx=&quot;100&quot; cy=&quot;100&quot; r=&quot;50&quot; stroke-width=&quot;4&quot; stroke=&quot;#000&quot; fill=&quot;#fff&quot; /&gt;
</code></pre><p>Be aware that XML is stricter than HTML. You cannot, for example, omit a closing tag since this will make the file invalid and the SVG will not be rendered.</p><p>The W3C SVG1.1 specification defines 14 main features:</p><ol><li><strong>Basic shapes</strong>: straight lines, polygons, circles, ellipses, and rectangles with or without rounded corners.</li><li><strong>Paths</strong>: outlined or filled paths containing curved or straight lines.</li><li><strong>Text</strong>: on straight or curved paths in any direction.</li><li><strong>Painting</strong>: fills and outlines using solid colors, gradients, patterns, transparency, and markers (line terminators such as arrow heads).</li><li><strong>Color</strong>: fill and stroke properties defined using standard 3 or 6-digit hex or rgb values.</li><li><strong>Gradients and patterns</strong>: CSS3-like gradient declarations or bitmap backgrounds.</li><li><strong>Clipping, masking and compositing</strong>: using elements to outline regions which can be painted.</li><li><strong>Filters</strong>: effects applied to all elements within a container, e.g. blurring, lighting, color adjustments, etc.</li><li><strong>Linking</strong>: hyperlinks to other documents.</li><li><strong>Interactivity</strong>: attaching event handlers using JavaScript.</li><li><strong>DOM Scripting</strong>: accessing and manipulating SVG elements using the Document Object Model.</li><li><strong>Animation</strong>: built-in animations using Synchronized Multimedia Integration Language (SMIL).</li><li><strong>Fonts</strong>: text glyphs defined in an SVG file which can be used as a standard font.</li><li><strong>Metadata</strong>: titles, descriptions, subjects, creators and other properties about the SVG image.</li></ol><h2>Cascading Stylesheets in SVGs</h2><p>SVGs also support embedded or external CSS rules. Like HTML, the selectors can target tag types or IDs and classes assigned to specific elements. CSS properties and values generally follow element attributes. For example, this CSS renders every circle in the SVG with the same white fill and black border color:</p><pre><code>
circle
{
	stroke: #000;
	fill: #fff;
}
</code></pre><h2>SVG Creation Tools</h2><p>Creating SVGs in a text editor is possible but it&#8217;s a slow process, error-prone and not much fun. Fortunately, there are several open source and commercial tools which allow designers and non-programmers to easily create SVG images:</p><ul><li><a
href="http://www.inkscape.org/">Inkscape</a></li><li><a
href="http://www.openoffice.org/">OpenOffice</a> or <a
href="">LibreOffice</a> Draw</li><li><a
href="http://svg-edit.googlecode.com/svn/branches/2.5.1/editor/svg-editor.html">svg-edit</a></li></ul><p>Therefore, a design team could create a great-looking chart which a programmer can modify by applying real data to specific elements.</p><p>However, note that some graphics packages may not create the most optimal code or apply their own XML extensions.</p><h2>SVG Browser Support</h2><p>Although the technology has been available for more than a decade, SVG use within browsers was held back by Internet Explorer which first provided support in IE9. Today, most desktop and mobile browsers can handle SVGs and it is a recognized HTML5 standard.</p><p>Browser implementations vary, but SVGs can either be:</p><ul><li>viewed as a separate file directly in a web browser.</li><li>embedded as an XML section within an HTML page.</li><li>defined as an external page resource within <code>img</code>, <code>object</code> or the old <code>embed</code> tags (or as an <code>iframe</code>, although that&#8217;s effectively viewing the SVG file)</li><li>set as background image in CSS.</li></ul><p>There are a number of plug-in and shim options if you require SVG support in Internet Explorer 8.0 and below. Several fallback to Vector Markup Language (VML); a technology used in Microsoft products which influenced the SVG standard:</p><ul><li><a
href="http://raphaeljs.com/">Rapha&euml;l</a> &#8212; JavaScript/VML</li><li><a
href="http://www.amplesdk.com/">AmpleSDK</a> &#8212; JavaScript/VML</li><li><a
href="http://code.google.com/p/svgweb/">svgweb</a> &#8212; JavaScript/Flash</li><li><a
href="http://xmlgraphics.apache.org/batik/">Batik</a> &#8212; Java toolkit</li></ul><h2>SVG Performance in Browsers</h2><p>SVG XML must be parsed to render images on-screen and represented in memory as a Document Object Model. As with HTML pages, performance will be affected if you attempt to move or manipulate SVGs containing a large number of elements. In extreme cases, the redraw will be noticeable.</p><p>For this reason, it&#8217;s often preferable to use the HTML5 <code>canvas</code> tag for fast action games with hundreds of animated items. However, you may be able to adopt SVGs for some aspects, e.g. a player&#8217;s spaceship could be a simple SVG which can be moved, rotated, scaled and warped over a <code>canvas</code>-generated background.</p><h2>SVGs and Accessibility</h2><p>Owing to their XML data structure, <a
href="http://www.w3.org/TR/SVG-access/">SVGs provide better accessibility</a> than bitmap images. At a basic level, meta data, short text and long text alternatives can be applied to any SVG image.</p><p>That said, screen reader support is poor. SVGs were not considered a viable browser technology until the release of IE9 so vendors did not consider them a priority. The situation will undoubtedly improve.</p><p>In the short term, you could consider transforming SVG XML into a text-based alternative using XSLT.</p><h2>SVGs and Search Engine Optimization</h2><p>Unlike bitmaps, XML is inherently machine-readable so static SVG files can be read, parsed and indexed by search engine bots. Google has been indexing SVG content since August 2010 and results can be found in the standard and image search systems.</p><p>Replacing a few PNGs with SVGs is unlikely to improve your rankings. However, if you&#8217;re displaying data as images without textual fall-backs, switching to SVGs could offer an SEO boost.</p><p>In my next SVG article we&#8217;ll create our first images without the use of a graphics package!</p> <span
id="pty_trigger"></span><div
style='padding:20px 0px 50px 0px;'><div
style='float:left;padding-left:40px;'><div
id='div-gpt-ad-1335489406190-0' style='width:300px; height:100px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1335489406190-0'); });</script> </div></div><div
style='float:right;padding-right:40px;'><div
id='div-gpt-ad-1335489406190-1' style='width:300px; height:100px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1335489406190-1'); });</script> </div></div><div
style='clear:both'></div></div><div
style='clear:both'></div>]]></content:encoded> <wfw:commentRss>http://www.sitepoint.com/svg-scalable-vector-graphics-overview/feed/</wfw:commentRss> <slash:comments>6</slash:comments> </item> <item><title>My Website&#8217;s Broken: 5 Steps to Determine What&#8217;s Wrong</title><link>http://www.sitepoint.com/5-steps-fix-broken-websites/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=5-steps-fix-broken-websites</link> <comments>http://www.sitepoint.com/5-steps-fix-broken-websites/#comments</comments> <pubDate>Wed, 09 May 2012 15:30:03 +0000</pubDate> <dc:creator>Craig Buckler</dc:creator> <category><![CDATA[Best Practices]]></category> <category><![CDATA[Cloud]]></category> <category><![CDATA[Disaster]]></category> <category><![CDATA[Disaster Recovery]]></category> <category><![CDATA[failover]]></category> <category><![CDATA[Resources]]></category> <category><![CDATA[Web Hosting]]></category> <category><![CDATA[Web Tech]]></category> <category><![CDATA[disaster recovery]]></category> <category><![CDATA[website]]></category> <guid
isPermaLink="false">http://www.sitepoint.com/?p=54311</guid> <description><![CDATA[<img
width="50" height="50" src="http://www.sitepoint.com/wp-content/uploads/1/files/2012/05/013-surviving-failure-50x50.jpg" class="attachment-thumbnail wp-post-image" alt="013-surviving-failure" title="013-surviving-failure" />Your website's down but you're convinced nothing has changed? Craig's 5-step guide could help diagnose those pesky performance problems.]]></description> <content:encoded><![CDATA[<img
width="50" height="50" src="http://www.sitepoint.com/wp-content/uploads/1/files/2012/05/013-surviving-failure-50x50.jpg" class="attachment-thumbnail wp-post-image" alt="013-surviving-failure" title="013-surviving-failure" /><p></p><p>We&#8217;ve all been there. Your wonderful website has been running successfully for months then &#8212; BAM &#8212; it disappears. Or, more often, certain features stop functioning. Despite your protests that nothing has changed, your client isn&#8217;t happy. Prepare yourself for a few frustrating hours of problem probing.</p><h2>Step 1: Identify the Issue</h2><p>This might sound obvious, but I&#8217;ve known many developers open their IDE and start hacking at random code. It&#8217;s more important to determine the issue than the cause at this stage. Is the site unavailable? Is a particular page or function failing? Is it limited to specific browsers?</p><h2>Step 2: Test Resource Availability</h2><p>Nine times out of ten, the problem will be caused by a connectivity issue at your end or the client&#8217;s. If you can&#8217;t access any other pages, it&#8217;s not surprising that your website has disappeared. That said, it&#8217;s not always obvious; certain IP ranges, countries or sections of the internet can become temporarily blocked.</p><p>Test your site from a variety of locations &#8212; a <a
href="http://www.publicproxyservers.com/">public proxy server</a> will help identify whether it&#8217;s a local or global problem. If possible, examine the status of other sites running from the same server or web host.<div
id='div-gpt-ad-1328644474660-10' style='width:728px; height:90px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1328644474660-10'); });</script> </div></p><p>One less obvious problem is disk space. If you&#8217;re running a busy site, server logs can rapidly use the available space even when your application&#8217;s storage requirements are low.</p><p>Remember that you might be using resources on other servers. This includes CDN-hosted files, database servers, or remotely-hosted APIs such as those for Google Maps, YouTube, Twitter, advertising services etc.</p><p>You should also check your server loads. A major traffic spike or Denial of Service attack will cause access problems.</p><p>Finally, is your domain registration valid and is the DNS server responding as it should?</p><h2>Step 3: Identify What Changed</h2><p>Once you&#8217;ve rejected connectivity, traffic, DNS and disk space, it&#8217;s time to determine what changed. 999 times out of 1,000 the problem will have been caused by an update.</p><p>You may not have touched the files but are you sure others haven&#8217;t? Check with everyone who has access but don&#8217;t necessarily believe them. Here&#8217;s a typical conversation you&#8217;ll encounter&hellip;</p><p><strong>Client:</strong> My sites not working. What are you going to do about it?<br
/> <strong>You:</strong> I&#8217;ll fix it. Have you made any changes recently?<br
/> <strong>Client:</strong> No. It was like that when I got here.<br
/> <em>&hellip;five hour&#8217;s frantic investigation&hellip;</em><br
/> <strong>You:</strong> You changed X, didn&#8217;t you?<br
/> <strong>Client:</strong> X? Oh yes, I changed X. I did that when I was fiddling with Y and Z.</p><p>Your application may not be directly to blame. Has your web host updated the OS, language runtime, database software or file permissions? While vendors attempt to ensure PHP, Ruby, Python, MySQL, PostgreSQL, etc. remain backward compatible, features will almost certainly change or break between editions.</p><h2>Step 4: Reject the Edge Cases</h2><p>Although rare, you should look for signs of cracking. Software such as <a
href="http://www.sitepoint.com/10-wordpress-security-tips/">WordPress</a>, Joomla and OScommerce are obvious targets, however, changes are often subtle because the cracker wants to retain access. For example, you might discover that a file explorer add-on has been installed or phishing pages have appeared deep within the file structure.</p><p>Finally, you should never rule out hardware problems. Corrupt memory chips or disk sectors could be responsible for any number of bizarre issues. If possible, evaluate your application on a similar set-up or install a separate test version on the same server.</p><h2>Step 5: Fix Your App</h2><p>Once you have eliminated the impossible, whatever remains, however improbable, must be the truth. Perhaps your code isn&#8217;t as perfect as you thought&hellip;</p><p>Do you have any tips for diagnosing website or application problems? What was the most difficult issue you encountered?</p> <span
id="pty_trigger"></span><div
style='padding:20px 0px 50px 0px;'><div
style='float:left;padding-left:40px;'><div
id='div-gpt-ad-1335489406190-0' style='width:300px; height:100px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1335489406190-0'); });</script> </div></div><div
style='float:right;padding-right:40px;'><div
id='div-gpt-ad-1335489406190-1' style='width:300px; height:100px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1335489406190-1'); });</script> </div></div><div
style='clear:both'></div></div><div
style='clear:both'></div>]]></content:encoded> <wfw:commentRss>http://www.sitepoint.com/5-steps-fix-broken-websites/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>Are You as Smart as Kevin Yank? Take the PHP &amp; MySQL Quiz and Find Out.</title><link>http://www.sitepoint.com/are-you-as-smart-as-kevin-yank-take-the-php-mysql-quiz-and-find-out/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=are-you-as-smart-as-kevin-yank-take-the-php-mysql-quiz-and-find-out</link> <comments>http://www.sitepoint.com/are-you-as-smart-as-kevin-yank-take-the-php-mysql-quiz-and-find-out/#comments</comments> <pubDate>Wed, 09 May 2012 06:24:16 +0000</pubDate> <dc:creator>Mick Gibson</dc:creator> <category><![CDATA[PHP & MySQL News & Interviews]]></category> <category><![CDATA[PHP & MySQL Tutorials]]></category> <category><![CDATA[Tech]]></category> <category><![CDATA[Tutorials]]></category> <category><![CDATA[Web Developer Quiz]]></category> <category><![CDATA[Web Tech]]></category> <guid
isPermaLink="false">http://www.sitepoint.com/?p=54479</guid> <description><![CDATA[<img
width="50" height="43" src="http://www.sitepoint.com/wp-content/uploads/1/files/2012/04/php-mysql-50x43.png" class="attachment-thumbnail wp-post-image" alt="php-mysql" title="php-mysql" />We all know Kevin Yank is a pretty smart guy. Now&#8217;s your chance to see if you&#8217;re as smart as Kev, by taking the PHP &#38; MySQL Quiz (which accompanies his new book &#8220;PHP &#38; MySQl: Novice to Ninja&#8220;) Jump in now, and take on the elephant in the room :)]]></description> <content:encoded><![CDATA[<img
width="50" height="43" src="http://www.sitepoint.com/wp-content/uploads/1/files/2012/04/php-mysql-50x43.png" class="attachment-thumbnail wp-post-image" alt="php-mysql" title="php-mysql" /><p></p><p><a
href="http://www.sitepoint.com/launch/d724a6" rel="attachment wp-att-53906"><img
class="alignright size-medium wp-image-53906" title="PHP &amp; MySQL: Novice to Ninja" src="http://www.sitepoint.com/wp-content/uploads/1/files/2012/04/phpmysql5-cover-86x115.jpg" alt="PHP &amp; MySQL: Novice to Ninja" width="86" height="115" /></a>We all know <a
href="http://www.sitepoint.com/launch/d724a6">Kevin Yank</a> is a pretty smart guy.</p><p>Now&#8217;s your chance to see if you&#8217;re as smart as Kev, by taking the <strong><a
href="http://www.sitepoint.com/quiz-phpmysql" target="_blank">PHP &amp; MySQL Quiz</a></strong> (which accompanies his new book &#8220;<a
href="http://www.sitepoint.com/launch/d724a6 ">PHP &amp; MySQl: Novice to Ninja</a>&#8220;)</p><p><strong><a
href="http://www.sitepoint.com/quiz-phpmysql" target="_blank">Jump in now</a>,</strong> and take on the elephant in the room :)</p><p
style="text-align: center;"><a
href="http://www.sitepoint.com/quiz-phpmysql"><img
class="aligncenter size-full wp-image-54486" title="Take the PHP &amp; MySQL Quiz" src="http://www.sitepoint.com/wp-content/uploads/1/files/2012/05/php-mysql5-quiz.jpg" alt="Take the PHP &amp; MySQL Quiz" width="500" height="454" /></a></p> <span
id="pty_trigger"></span><div
style='padding:20px 0px 50px 0px;'><div
style='float:left;padding-left:40px;'><div
id='div-gpt-ad-1335489406190-0' style='width:300px; height:100px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1335489406190-0'); });</script> </div></div><div
style='float:right;padding-right:40px;'><div
id='div-gpt-ad-1335489406190-1' style='width:300px; height:100px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1335489406190-1'); });</script> </div></div><div
style='clear:both'></div></div><div
style='clear:both'></div>]]></content:encoded> <wfw:commentRss>http://www.sitepoint.com/are-you-as-smart-as-kevin-yank-take-the-php-mysql-quiz-and-find-out/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>Judgment Day Arrives: Opera Implements the CSS3 Webkit Prefix</title><link>http://www.sitepoint.com/opera-css3-webkit-prefix/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=opera-css3-webkit-prefix</link> <comments>http://www.sitepoint.com/opera-css3-webkit-prefix/#comments</comments> <pubDate>Sat, 05 May 2012 12:05:30 +0000</pubDate> <dc:creator>Craig Buckler</dc:creator> <category><![CDATA[Android]]></category> <category><![CDATA[CSS3]]></category> <category><![CDATA[Discussion]]></category> <category><![CDATA[HTML & CSS]]></category> <category><![CDATA[HTML5]]></category> <category><![CDATA[iOS]]></category> <category><![CDATA[JavaScript]]></category> <category><![CDATA[JavaScript & CSS]]></category> <category><![CDATA[Mobile Web Dev]]></category> <category><![CDATA[Mobile Web Development]]></category> <category><![CDATA[Opinion]]></category> <category><![CDATA[Web Tech]]></category> <category><![CDATA[apple]]></category> <category><![CDATA[HTML5 Dev Center]]></category> <category><![CDATA[HTML5 Tutorials & Articles]]></category> <category><![CDATA[microsoft]]></category> <category><![CDATA[Mozilla]]></category> <category><![CDATA[opera]]></category> <category><![CDATA[webkit]]></category> <guid
isPermaLink="false">http://www.sitepoint.com/?p=54305</guid> <description><![CDATA[<img
width="50" height="50" src="http://www.sitepoint.com/wp-content/uploads/1/files/2012/02/641-css-vendor-prefix-crisis-50x50.jpg" class="attachment-thumbnail wp-post-image" alt="641-css-vendor-prefix-crisis" title="641-css-vendor-prefix-crisis" />Opera is implementing 14 regularly-used webkit-prefixed properties in their browser. Is this the beginning of the end for CSS3 vendor prefixes?]]></description> <content:encoded><![CDATA[<img
width="50" height="50" src="http://www.sitepoint.com/wp-content/uploads/1/files/2012/02/641-css-vendor-prefix-crisis-50x50.jpg" class="attachment-thumbnail wp-post-image" alt="641-css-vendor-prefix-crisis" title="641-css-vendor-prefix-crisis" /><p></p><p>In February 2012, we reported the minutes of W3C meeting where <a
href="http://www.sitepoint.com/w3c-css-webkit-prefix-crisis/">Mozilla, Opera and Microsoft discussed implementing -webkit prefixes</a> in non-webkit browsers. The reason: some developers use only webkit prefixes &#8212; their sites look good in some browsers, but broken in others even when they offer the same level of CSS3 support. The issue is especially prevalent on mobile browsers and many developers fail to look beyond their high-end Apple or Android devices.</p><p><a
href="http://dev.opera.com/articles/view/opera-mobile-emulator-experimental-webkit-prefix-support/">Opera has now announced support for 14 CSS3 webkit properties</a> in their Mobile Emulator. The implementation will eventually reach all editions of their desktop and mobile browsers. If you&#8217;re thinking <em>&#8220;Opera has a tiny market share&#8221;</em>, think again: <a
href="http://www.sitepoint.com/browser-trends-may-2012/">it&#8217;s the world&#8217;s most-used mobile browser</a>.</p><p>Perhaps I&#8217;m being overly dramatic, but Charlton Heston&#8217;s famous line comes to mind: <em>&#8220;They finally, really did it. You manics. You blew it up!&#8221;</em></p><h2>Opera -webkit Aliasing</h2><p>Opera analyzed stylesheets from 10,000 popular websites to determine which CSS values/properties would receive -webkit aliases:<div
id='div-gpt-ad-1328644474660-10' style='width:728px; height:90px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1328644474660-10'); });</script> </div></p><table
summary="Opera CSS webkit aliases" width="70%" style="text-align:left !important;margin:20px auto"><tr><th>-o- prefix</th><th>-webkit- alias</th></tr><tr><td>-o-linear-gradient</td><td>-webkit-linear-gradient</td></tr><tr><td>box-shadow</td><td>-webkit-box-shadow</td></tr><tr><td>-o-transform</td><td>-webkit-transform</td></tr><tr><td>-o-transform-origin</td><td>-webkit-transform-origin</td></tr><tr><td>border-radius</td><td>-webkit-border-radius</td></tr><tr><td>border-top-left-radius</td><td>-webkit-border-top-left-radius</td></tr><tr><td>border-top-right-radius</td><td>-webkit-border-top-right-radius</td></tr><tr><td>border-bottom-left-radius</td><td>-webkit-border-bottom-left-radius</td></tr><tr><td>border-bottom-right-radius</td><td>-webkit-border-bottom-right-radius</td></tr><tr><td>-o-transition</td><td>-webkit-transition</td></tr><tr><td>-o-transition-delay</td><td>-webkit-transition-delay</td></tr><tr><td>-o-transition-duration</td><td>-webkit-transition-duration</td></tr><tr><td>-o-transition-property</td><td>-webkit-transition-property</td></tr><tr><td>-o-transition-timing-function</td><td>-webkit-transition-timing-function</td></tr></table><p>If the browser encounters a property such as <code>-webkit-border-radius</code>, it will apply that effect. If you&#8217;ve defined <code>-webkit-border-radius</code>, <code>-o-border-radius</code> and <code>border-radius</code>, normal CSS cascading rules apply and the last defined rule or most appropriate selector will be applied, e.g.</p><pre><code>
#myelement
{
	-o-border-radius: 3px;
	border-radius: 6px;
	-webkit-border-radius: 9px;
}
</code></pre><p>All properties are considered to have equal priority so Opera applies a border radius of 9px.</p><p>With regard to differences in behavior, Opera state:</p><blockquote><p> As far as we can tell, the behavior the properties that we have aliased is identical in WebKit and Opera, or at least close enough that the differences will not matter in practice. If it turns out that there are differences big enough to cause breakage, we will consider our options, one of which is to align the behavior of our -webkit- prefixed variant to what WebKit actually does.</p></blockquote><p>Opera make a reasonable case to justify their decision. While they understand the complaints, their primary goal is to create a browser which works well for users &#8212; who outnumber developers by many thousands to one.</p><h2>The Backlash</h2><p>Most developers understand the problem but disagree with the solution. It&#8217;s crude and has the potential to break the web. Taking the decision to it&#8217;s logical extreme, all vendors would support every prefix but any implementation differences would render the CSS property useless.</p><p>The solution rewards bad development practices. While Opera advises you use all vendor prefixes, they will exacerbate the problem:</p><ul><li>Less conscientious developers will see this as justification for only targeting webkit browsers.</li><li>If your site uses differing -webkit and -o values, it will now be affected by CSS cascade rules. Is it easier to analyze and retest your code or simply remove the Opera properties?</li><li>It will become easier to accidentally omit the -o prefix since sites will work as expected.</li></ul><p>Several problems have already been reported. For example, Modernizr evaluates prefixes in turn until it finds one the browser supports. Therefore:</p><pre><code>
Modernizr.prefixed("transition");
</code></pre><p>now returns <code>WebkitTransition</code> in Opera. Transitions are new to Opera and the browser doesn&#8217;t support every webkit CSS and JavaScript property. If you want to adjust or disable effects in Opera, you can&#8217;t rely on Modernizr-like detection code. You may even need to implement <a
href="http://www.sitepoint.com/why-browser-sniffing-stinks/">nasty browser sniffing</a>.</p><p>However, my biggest issue is this: <em>where are all these problem sites?</em> Has user experience suffered from the lack of rounded corner, gradient, shadow, transition and transform effects? Are those sites genuinely broken or has Opera taken a (marketing) opportunity to make their browser look better?</p><p>Since Opera has analyzed 10,000 websites they can contact the owners directly. At the very least, they could publish a &#8220;hall of shame&#8221; which provides examples and highlights the technical issues. Many developers would happily contact companies on Opera&#8217;s behalf. Some would be prepared to fix sites for free since it could lead to future contracts.</p><p>There are <a
href="http://www.sitepoint.com/css3-vendor-prefix-crisis-solutions/">no easy solutions to the vendor prefix crisis</a>. I understand Opera&#8217;s reasons but, regardless of how this is implemented, it&#8217;s inevitable that something will end up broken.</p><p><strong>Some good news:</strong> Microsoft has announced they will not support webkit prefixes in Internet Explorer (although there&#8217;s nothing to prevent them reversing that decision). Mozilla is yet to reveal their intentions &#8212; they will be watching Opera&#8217;s situation closely.</p> <span
id="pty_trigger"></span><div
style='padding:20px 0px 50px 0px;'><div
style='float:left;padding-left:40px;'><div
id='div-gpt-ad-1335489406190-0' style='width:300px; height:100px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1335489406190-0'); });</script> </div></div><div
style='float:right;padding-right:40px;'><div
id='div-gpt-ad-1335489406190-1' style='width:300px; height:100px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1335489406190-1'); });</script> </div></div><div
style='clear:both'></div></div><div
style='clear:both'></div>]]></content:encoded> <wfw:commentRss>http://www.sitepoint.com/opera-css3-webkit-prefix/feed/</wfw:commentRss> <slash:comments>29</slash:comments> </item> <item><title>Add a Web Console to Your Toolbox, Part 1</title><link>http://www.sitepoint.com/add-a-web-console-to-your-toolbox-part-1/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=add-a-web-console-to-your-toolbox-part-1</link> <comments>http://www.sitepoint.com/add-a-web-console-to-your-toolbox-part-1/#comments</comments> <pubDate>Thu, 03 May 2012 15:00:43 +0000</pubDate> <dc:creator>Jeff Friesen</dc:creator> <category><![CDATA[HTML5]]></category> <category><![CDATA[JavaScript]]></category> <category><![CDATA[Web Tech]]></category> <guid
isPermaLink="false">http://www.sitepoint.com/?p=54167</guid> <description><![CDATA[<img
width="50" height="28" src="http://www.sitepoint.com/wp-content/uploads/1/files/2012/05/Screen-Shot-2012-05-02-at-4.06.54-PM-50x28.png" class="attachment-thumbnail wp-post-image" alt="Screen Shot 2012-05-02 at 4.06.54 PM" title="Screen Shot 2012-05-02 at 4.06.54 PM" />In this tutorial, Jeff teaches us how to make a completely interactive terminal, compatible with the top five browsers, make sure you do not miss this one.]]></description> <content:encoded><![CDATA[<img
width="50" height="28" src="http://www.sitepoint.com/wp-content/uploads/1/files/2012/05/Screen-Shot-2012-05-02-at-4.06.54-PM-50x28.png" class="attachment-thumbnail wp-post-image" alt="Screen Shot 2012-05-02 at 4.06.54 PM" title="Screen Shot 2012-05-02 at 4.06.54 PM" /><p></p><p>A <em>console</em> is a software artifact for reading line-oriented textual input from the keyboard and writing line-oriented textual output to the screen. Consoles are often used to implement operating system<a
href="http://en.wikipedia.org/wiki/Command-line_interface" target="_blank">command-line interfaces</a>, but are also handy in <a
href="http://en.wikipedia.org/wiki/Adventure_game#Text_adventure" target="_blank">text-based adventure games</a> and other contexts.</p><p>Although text-oriented consoles are not as popular as they once were because of the proliferation of graphical user interfaces, they can be useful to <a
href="http://en.wikipedia.org/wiki/Power_user" target="_blank">power users</a> who are not intimidated by this style of interface. Also, consoles can open up a new class of web application such as the embedded browser <a
href="http://en.wikipedia.org/wiki/Shell_(computing)" target="_blank">shell</a>.</p><p>This article begins a two-part series that presents a JavaScript-based console library for use with web applications that may benefit from this style of user interface. Part 1 introduces you to the library&#8217;s simple API along with a browser shell application that serves as a useful demonstration of this API. Part 2 shows you how the library is implemented so that you can modify it to meet additional requirements.<div
id='div-gpt-ad-1328644474660-10' style='width:728px; height:90px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1328644474660-10'); });</script> </div></p><h2>Explore the Console Library</h2><p>The console library consists of a global object named <code>Console</code> with several properties. This arrangement minimizes pollution of the global namespace. Furthermore, it reflects my desire to avoid supporting multiple consoles, as I find it easier to implement a singleton console.<br
/> <code>Console</code> provides the following features:</p><ul></ul><ul><li>easy initialization based on number of desired rows and columns (the <code>&lt;canvas&gt;</code> tag requires only an <code>id</code> attribute)</li></ul><ul></ul><ul><li>canvas placed in tab order and gains keyboard focus immediately for browsers such as Firefox</li></ul><ul></ul><ul><li>clear console capability</li></ul><ul></ul><ul><li>green on black text with monospace font</li></ul><ul></ul><ul><li>visible cursor that marks the current input position</li></ul><ul></ul><ul><li>text echoing capability</li></ul><ul></ul><ul><li>vertically scrollable when text flows past the lower-right character position</li></ul><ul></ul><ul><li>simplified editing in terms of the backspace key</li></ul><ul></ul><ul><li>automatically call a function when no input is available</li></ul><ul></ul><ul><li>supports FireFox, Internet Explorer, Chrome, Opera, and Safari</li></ul><p>Although <code>Console</code> encapsulates multiple accessible properties, I consider only four of them to be members of the &#8220;public&#8221; API. The other properties should not be accessed; they exist to support the following four properties and could change in a subsequent version of the library:</p><ul></ul><ul><li><code>init(canvasName, numCols, numRows)</code> initializes the console. The string passed to <code>canvasName</code> must match the value of an existing <code>&lt;canvas&gt;</code> element&#8217;s <code>id</code> attribute. The integer passed to<code>numCols</code> identifies the desired number of columns (e.g., 80), and the integer passed to <code>numRows</code> identifies the desired number of rows (e.g., 25). The console is cleared and the cursor position is set (0, 0). The resulting console displays green text on a black background. This function does not return a value.</li></ul><ul></ul><ul><li><code>clear()</code> clears the console and sets the cursor position to (0, 0). This function does not return a value.</li></ul><ul></ul><ul><li><code>getLine(callback)</code> returns a line of input and echoes this input to the console. It first checks if a line has been entered by noting whether a newline character (indicated by the user having pressed the key labeled Enter or Return) is present in the input. If so, the line is returned without the newline character. If a newline is not present, or if there is no input, this function returns null. When a function is passed to <code>callback</code>, that function is called when nothing has been entered.</li></ul><ul></ul><ul><li><code>echo(msg)</code> echoes the string passed to <code>msg</code> to the console starting at the cursor position, which is updated. The console scrolls vertically when the message flows past the lower-right corner. This function recognizes <code>\b</code> (backspace) and <code>\n</code> (newline) special characters. Also, it does not return a value.</li></ul><p>The <code>getLine(callback)</code> function does not block the current thread while waiting for the user to press Enter/Return. Instead, it returns immediately. It does so because JavaScript code runs on a single thread. (HTML5&#8242;s web workers are an exception, and are beyond the scope of this article.) Blocking this thread for longer than what the browser considers acceptable causes the browser to display a dialog box that reports an unresponsive script.</p><p>The console library is easy to use. After defining a <code>&lt;canvas&gt;</code> element, and after initializing and echoing any preliminary text to the console, repeatedly execute a function via JavaScript&#8217;s<code>setInterval()</code> function. Each execution should invoke <code>getLine(callback)</code> (with an optional callback function) and then take appropriate action based on <code>getLine()</code>&#8216;s return value. Listing 1 presents the HTML for a simple demonstration of this library.</p><pre>&lt;html&gt;
   &lt;head&gt;
      &lt;title&gt;
         Console Demo
      &lt;/title&gt;
      &lt;meta http-equiv="X-UA-Compatible" content="IE=Edge"/&gt;
      &lt;script src="../Console/Console.js"&gt;
      &lt;/script&gt;
   &lt;/head&gt;
   &lt;body style="text-align: center"&gt;
      &lt;p&gt;
      &lt;h2&gt;
        Console Demo
      &lt;/h2&gt;
      &lt;canvas id="mycanvas"&gt;
      HTML5 canvas element not supported by this browser.
      &lt;/canvas&gt;
      &lt;p&gt;
      You might have to press the Tab key or click the canvas to give it keyboard focus.
      &lt;/p&gt;
      &lt;script&gt;
         Console.init("mycanvas", 64, 16);
         Console.echo("&gt;");
         function tick()
         {
            var line = Console.getLine();
            if (line != null)
            {
               if (line != "")
                  Console.echo(line+"\n");
               Console.echo("&gt;");
            }
         }
         setInterval("tick()", 50); // Invoke tick() every 50 milliseconds.
      &lt;/script&gt;
   &lt;/body&gt;
&lt;/html&gt;</pre><p><strong>Listing 1:</strong> Echoing entered text on the console</p><p>Listing 1 describes <code>ConsoleDemo.html</code>. This listing is fairly straightfoward, except perhaps for the <code>&lt;meta&gt;</code> element. This element enforces a <a
href="http://blogs.msdn.com/b/askie/archive/2009/03/23/understanding-compatibility-modes-in-internet-explorer-8.aspx" target="_blank">compatibility mode</a> &#8211; use latest standards rendering mode &#8212; so that the console will work under Internet Explorer 9 (and probably higher versions of this browser). Otherwise, Explorer outputs an error message about the Canvas API&#8217;s <code>getContext()</code> function not being defined.</p><p>Listing 1 continues with a <code>&lt;script&gt;</code> element that includes the contents of a JavaScript source file named <code>Console.js</code>. This file defines the console library and is located in a <code>Console</code> directory that&#8217;s accessed relative to <code>ConsoleDemo.html</code>. The code file that&#8217;s attached to this article contains <code>ConsoleDemo.html</code> and <code>Console.js</code> in appropriate directories relative to each other, so you should be able to run <code>ConsoleDemo</code> without problems.</p><p>The body of this HTML file specifies a <code>&lt;canvas&gt;</code> element whose <code>id</code> attribute is assigned <code>mycanvas</code>. No other attribute is required because the console library takes care of them. The body also contains a <code>&lt;script&gt;</code> element that presents the console demonstration code.</p><p>The code first initializes the canvas to a 64-column-by-16-row drawing area &#8212; I chose these values because they were the dimensions of the text screen on my old TRS-80 Model III microcomputer. The code then echoes a <code>&gt;</code> character to the console as the initial input line&#8217;s prompt.</p><p>At this point, a function named <code>tick()</code> is defined for repeated execution. This function will be executed every 50 milliseconds courtesy of the <code>setInterval("tick()", 50)</code> function call. Each invocation attempts to retrieve and echo back to the console a line of input.</p><p><code>tick()</code> first invokes <code>getLine()</code> without passing a callback function because none is needed in this example. If this function returns null because nothing has been entered or the user is typing some input (and has not yet pressed Enter/Return), nothing further happens. Otherwise, if the returned line is not equal to the empty string (only Enter/Return was pressed), the entered text followed by a newline is echoed to the console. At this point, a <code>&gt;</code> prompt is echoed to inform the user that another line of input is expected.</p><p>Figure 1 shows you the resulting console in the context of Firefox.</p><p><img
src="http://www.sitepoint.com/wp-content/uploads/1/files/2012/05/figure1.jpg"/></p><p><strong>Figure 1:</strong> You don&#8217;t have to press Tab to start using the console on Firefox.</p><h2>Encounter a Browser Shell</h2><p>A <a
href="http://en.wikipedia.org/wiki/Shell_(computing)" target="_blank"><em>shell</em></a> provides an operating system&#8217;s user interface, and its primary purpose is to run programs. Modern operating systems feature graphical shells, but many also feature traditional command-line-oriented shells (e.g, Unix&#8217;s Korn and Bourne shells). A similar shell can be embedded within a web page via the console library, and this <em>browser shell</em> can be used to execute browser-oriented commands.I&#8217;ve created a browser shell application as a useful demonstration of the console library. Figure 2 reveals this application&#8217;s console in the context of the Internet Explorer 9 browser.</p><p><a
href="http://www.sitepoint.com/wp-content/uploads/1/files/2012/05/figure2.jpg"><img
src="http://www.sitepoint.com/wp-content/uploads/1/files/2012/05/figure2.jpg" alt="" title="figure2" width="848" height="680" class="alignleft size-full wp-image-54250" /></a></p><p><strong>Figure 2:</strong> The browser shell currently supports four commands.</p><p>Figure 2 reveals an interesting anomaly: geolocation information is not immediately displayed. Instead, latitude and longitude data is often presented multiple lines later in the browser. You will learn the reason while exploring Listing 2.</p><pre>&lt;html&gt;
   &lt;head&gt;
      &lt;title&gt;
         Browser Shell
      &lt;/title&gt;
      &lt;meta http-equiv="X-UA-Compatible" content="IE=Edge"/&gt;
      &lt;script src="../Console/Console.js"&gt;
      &lt;/script&gt;
   &lt;/head&gt;
   &lt;body style="text-align: center"&gt;
      &lt;p&gt;
      &lt;h2&gt;
        Browser Shell
      &lt;/h2&gt;
      &lt;canvas id="mycanvas"&gt;
      HTML5 canvas element not supported by this browser.
      &lt;/canvas&gt;
      &lt;p&gt;
      You might have to press the Tab key or click the canvas to give it keyboard focus.
      &lt;/p&gt;
      &lt;script&gt;
         Console.init("mycanvas", 64, 22);
         Console.echo("Browser Shell 1.0\n\n");
         Console.echo("Type 'help' (without the quotes) to obtain help\n\n");
         Console.echo("&gt;");
         var geo = "";
         function callback()
         {
            if (geo == "")
               return;
            Console.echo(geo+"\n");
            Console.echo("&gt;");
            geo = "";
         }
         function tick()
         {
            var line = Console.getLine(callback);
            if (line != null)
            {
               line = line.trim();
               if (line == "browser")
                  Console.echo(navigator.<wbr>userAgent+"\n\n"); else if (line == "cls") Console.clear(); else if (line == "geo") { Console.echo("querying location info...may take a few moments\n\n"); function report_error(error) { geo = error.message; if (geo == "") // geo is "" on Safari geo = "unknown error"; } function report_geolocation_query(</wbr><wbr>position) { geo = "Lat: "+position.coords.latitude+", Lon: "+position.coords.latitude; } navigator.geolocation.</wbr><wbr>getCurrentPosition(report_</wbr><wbr>geolocation_query, report_error); } else if (line == "help") { Console.echo("Available commands...\n"); Console.echo("browser -- display current browser info\n"); Console.echo("cls -- clear screen\n"); Console.echo("geo -- obtain geolocation information\n"); Console.echo("help -- display this help text\n\n"); } else if (line != "") Console.echo("bad command\n"); Console.echo("&gt;"); } } setInterval("tick()", 50); // Invoke tick() every 50 milliseconds. &lt;/script&gt; &lt;/body&gt; &lt;/html&gt;</wbr></pre><p><strong>Listing 2:</strong> Interpreting and executing commands</p><p>Listing 2 presents <code>BrowserShell.html</code>. This listing has a similar layout to Listing 1 and should be fairly easy to follow. After initializing and echoing preliminary text to the console, the <code>tick()</code>function is repeatedly executed to get the next line of input, trim whitespace from both ends, check for one of four possible commands, and execute the command. If an invalid command is entered, <code>bad command</code> is echoed to the console. Regardless, the user is then prompted to enter the next command.</p><p>The <code>geo</code> command is the most complex to implement. It obtains geolocation information about the user via the <a
href="http://www.w3.org/TR/geolocation-API/" target="_blank">Geolocation API</a>, which is asynchronous to avoid blocking the JavaScript thread.<code>navigator.geolocation.<wbr>getCurrentPosition(report_</wbr><wbr>geolocation_query, report_error)</wbr></code> queries the user to grant permission to obtain geolocation information, proceeds to get that information when the user accepts, and then invokes one of two callback functions:</p><ul></ul><ul><li><code>report_geolocation_query(<wbr>position)</wbr></code> is invoked (upon success) with a <code>Position</code> argument that stores the geolocation data via its <code>coords</code> member, of Document Object Model type<code>Coordinates</code>. This DOM interface includes <code>latitude</code> and <code>longitude</code> fields of DOM type <code>double</code>.</li></ul><ul></ul><ul><li><code>report_error(error)</code> is invoked (upon failure) with a <code>PositionError</code> argument that stores the reason for failure via its <code>message</code> member, of DOM type <code>DOMString</code>, and its <code>code</code> member, of DOM type <code>unsigned short</code>.</li></ul><p>Each of these callbacks extracts information from its passed argument and builds a string that it assigns to the <code>geo</code> variable. During testing on Safari, I discovered that this browser wouldn&#8217;t let me obtain geolocation information. Furthermore, it assigned the empty string to <code>message</code>. To address this situation, I coded <code>report_error(error)</code> to assign <code>"unknown error"</code> to <code>message</code>. (I could have output a message based on <code>error.code</code> whose value was 2 &#8212; the position is unavailable. I leave making this change with you as an exercise.)</p><p>Listing 2 declares a <code>callback()</code> function that it passes as an argument to <code>getLine(callback)</code>. This function is invoked each time <code>getLine(callback)</code> detects that there is no input. After verifying that something has been assigned to <code>geo</code>, <code>callback()</code> echoes this variable&#8217;s value followed by a <code>&gt;</code> prompt to the console, and then assigns the empty string to this variable (to avoid having <code>geo</code>&#8216;s value repeatedly output).</p><p>Why don&#8217;t I echo <code>geo</code>&#8216;s value within <code>report_geolocation_query(<wbr>position)</wbr></code> and <code>report_error(error)</code> (and then I wouldn&#8217;t need <code>geo</code> but could use a local variable) instead of going to the trouble of passing a callback function to <code>getLine(callback)</code>? If I did so, that navigation data could be output in the midst of entering a command, resulting in a mess. For example, while entering <code>help</code> I might end up with the following intermixed output:</p><pre>&gt;helLat: 49.88, Lon: 49.88
&gt;p</pre><h2>Conclusion</h2><p>Console is a useful tool for embedding a simple console into web pages. The previous browser shell application gives you an idea of what&#8217;s possible. You might want to extend this application with additional commands, such as a <code>dir</code> command for obtaining a directory listing of <a
href="http://www.w3.org/TR/webstorage/" target="_blank">web storage</a>. However, you first need to understand how this library works, and that is the subject of Part 2.</p><table
width="60%" border="1" align="center"><tbody><tr><th
bgcolor="#0000c0"><span
style="color: #ffffff;">Note</span></th></tr><tr><td>All files pertaining to this article are located in <a
href="http://www.sitepoint.com/wp-content/uploads/1/files/2012/05/code.zip" target="_blank">code.zip</a>.</td></tr></tbody></table> <span
id="pty_trigger"></span><div
style='padding:20px 0px 50px 0px;'><div
style='float:left;padding-left:40px;'><div
id='div-gpt-ad-1335489406190-0' style='width:300px; height:100px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1335489406190-0'); });</script> </div></div><div
style='float:right;padding-right:40px;'><div
id='div-gpt-ad-1335489406190-1' style='width:300px; height:100px;'> <script type='text/javascript'>googletag.cmd.push(function() { googletag.display('div-gpt-ad-1335489406190-1'); });</script> </div></div><div
style='clear:both'></div></div><div
style='clear:both'></div>]]></content:encoded> <wfw:commentRss>http://www.sitepoint.com/add-a-web-console-to-your-toolbox-part-1/feed/</wfw:commentRss> <slash:comments>8</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using memcached
Database Caching 55/65 queries in 0.057 seconds using memcached
Object Caching 2940/2942 objects using memcached

Served from: www.sitepoint.com @ 2012-05-27 10:16:49 -->
