tag:blogger.com,1999:blog-28101202004490164772024-03-12T23:13:21.635+00:00World of LinuxMy blog about everything Linux, and maybe some other computer-related articles.Anonymoushttp://www.blogger.com/profile/07644067784187311179noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-2810120200449016477.post-16559634912449723702014-09-14T12:15:00.001+01:002014-09-14T12:16:36.995+01:00[Websites] How to use XHTML with HTML 5XHTML. Nowadays, whenever you tend to hear about it, it's just people complaining and recommending that you never should use it, since it's old. It's not. If it was so outdated, then why would <a href="http://w3.org/">w3.org</a> be using it on their webpages?<br />
<br />
People only think it's outdated because it's more similar to HTML 4, and because it's not commonly used any more. But if you know how to write it, you probably will be writing much better code than most HTML5 developers.<br />
<br />
But, the thing is, it's still more like HTML 4 than HTML 5 in terms of features. That's a bit of a problem if you want to use new HTML 5 features and elements, right? The thing is, and not many people realise - you <i>can</i> use HTML 5 with the "betterness" of XHTML.<br />
<br />
It's simple! All you have to do to use HTML 5 with XHTML is this:<br />
<br />
<code><?xml version="1.0" encoding="utf-8" ?><br />
<!DOCTYPE html><br />
<html xmlns="http://www.w3.org/1999/xhtml"><br />
...</code><br />
<br />
Now, what does all this do? Firstly, we have the XML metadata tag. This tells the browser which version of XML we want to use, and the encoding of the document. (In HTML, you would normally specify encoding using <code><meta charset="utf-8" /></code>.)<br />
<br />
The next bit is the DOCTYPE. We want HTML 5, and as you probably know, the doctype for HTML 5 is simply "html". Easy.<br />
<br />
Now, you just have to remember the one thing: specify the XML namespace of XHTML in the root element - in this case, HTML. You always must do this, or you can face problems.<br />
<br />
Now, you can do everything the proper way of XML! Self-closing script tags:<br />
<br />
<code><script src="script.js" /></code><br />
<br />
Proper BR tags, not silly auto-closing magic:<br />
<br />
<code><br /></code><br />
<br />
And, 'cause it's XML, it'll render faster and on more platforms! But... there's one problem. Will my hacky XHTML 5 validate? The answer is... somehow yes! You can do this and it will validate perfectly. To show you what I mean, here's an example:<br />
<br />
<code><?xml version="1.0" encoding="utf-8" ?><br />
<!DOCTYPE html><br />
<html xmlns="http://www.w3.org/1999/xhtml"></code><br />
<code> <head></code><br />
<code> <title>Hello, World!</title></code><br />
<code> </head></code><br />
<code> <body></code><br />
<code> <nav></code><br />
<code> <a id="picturebtn1" href="page1.html" /></code><br />
<code> </code><code><a id="picturebtn2" href="page2.html" /></code><br />
<code> <div id="decoration" /></code><br />
<code> </nav></code><br />
<code> <main></code><br />
<code> <h1>Hello, World!</h1></code><br />
<code> <hr /></code><br />
<code> </main></code><br />
<code> </body></code><br />
<code></html> </code><br />
<br />
Now, you might not have noticed, but I purposely did two things. Firstly, I used self-closing tags that would be invalid in non-XML, HTML 5. Secondly, I used two new HTML 5 elements. I could not have done both of these things - only one - if the page was not HTML 5 <i>and</i> XHTML.<br />
<br />
Try pasting that into <a href="http://validator.w3.org/#validate_by_input">W3's validator</a>. You'll get two warnings: one says that the HTML 5 validator is experimental, and the other says that we didn't need to give the encoding since we were directly inputting the code rather than uploading a file.<br />
<br />
To prove that you can't do both these things without XHTML 5, get rid of the xmlns attribute of the head tag and get rid of the XML metadata tag. You'll end up with this:<br />
<br />
<code>
<!DOCTYPE html><br />
<html></code><br />
<code> <head></code><br />
<code> <title>Hello, World!</title></code><br />
<code> </head></code><br />
<code> <body></code><br />
<code> <nav></code><br />
<code> <a id="picturebtn1" href="page1.html" /></code><br />
<code> </code><code><a id="picturebtn2" href="page2.html" /></code><br />
<code> <div id="decoration" /></code><br />
<code> </nav></code><br />
<code> <main></code><br />
<code> <h1>Hello, World!</h1></code><br />
<code> <hr /></code><br />
<code> </main></code><br />
<code> </body></code><br />
<code></html></code><br />
<br />
Now if you try to validate <i>this</i>, you'll get some errors. What they're all saying is that you can't use the XML self-closing syntax on any element you want - only the <i>"chosen ones"</i> will validate if you close them like that.<br />
<br />
What if we try to validate it as XHTML strict?<br />
<br />
<code><?xml version="1.0" encoding="utf-8" ?> </code><br />
<code><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><br />
<html xmlns="http://www.w3.org/1999/xhtml"></code><br />
<code> <head></code><br />
<code> <title>Hello, World!</title></code><br />
<code> </head></code><br />
<code> <body></code><br />
<code> <nav></code><br />
<code> <a id="picturebtn1" href="page1.html" /></code><br />
<code> </code><code><a id="picturebtn2" href="page2.html" /></code><br />
<code> <div id="decoration" /></code><br />
<code> </nav></code><br />
<code> <main></code><br />
<code> <h1>Hello, World!</h1></code><br />
<code> <hr /></code><br />
<code> </main></code><br />
<code> </body></code><br />
<code></html></code><br />
<br />
Put that into the validator again. Now, what are the errors this time? It tells us we can't use the elements nav or main because they don't exist in (X)HTML 4. And who wants to use HTML 4?<br />
<br />
I hope after reading this you'll consider using a combination of XHTML and HTML 5 in your webpages, rather than "vanilla" HTML 5. Please feel free to leave a comment on what you think about my idea!Anonymoushttp://www.blogger.com/profile/07644067784187311179noreply@blogger.com0tag:blogger.com,1999:blog-2810120200449016477.post-91904131935365579492014-08-03T11:33:00.000+01:002014-08-04T19:44:35.538+01:00[Tutorial] Kernel.org Kernel Build for UbuntuThis article is available under <a href="http://creativecommons.org/licenses/by-sa/4.0/">Creative Commons Attribution-ShareAlike 4.0</a>. Adapted from <a href="https://wiki.ubuntu.com/KernelTeam/GitKernelBuild">KernelTeam/GitKernelBuild</a> - click <a href="https://wiki.ubuntu.com/KernelTeam/GitKernelBuild?action=info">here for the original authors</a>.<br />
<br />
The following document should help users build their own kernel from the latest stable kernel from kernel.org. Please note that the following steps are targeted towards Ubuntu users, though they will also work on Ubuntu deratives (including Mint, Elementary, Deepin etc.) and may also work on Debian and non-Ubuntu, Debian deratives.<br />
<h2 id="prerequisites">
Prerequisites</h2>
There are a few tools that are necessary in order to build your own kernel(s). The ‘kernel-package’ provides the make-kpkg utility which automatically build your kernel and generate the linux-image and linux-header .deb files which can be installed. You will need to install the following packages:<br />
<pre class="prettyprint prettyprinted"><code><span class="pln">sudo apt</span><span class="pun">-</span><span class="kwd">get</span><span class="pln"> install build</span><span class="pun">-</span><span class="pln">essential kernel</span><span class="pun">-</span><span class="kwd">package</span><span class="pln"> fakeroot libncurses5</span><span class="pun">-</span><span class="pln">dev</span></code></pre>
<div class="se-section-delimiter">
</div>
<h2 id="kernel-build-and-installation">
Kernel Build and Installation</h2>
<ol>
<li>Change to the directory where you want to download the kernel source. In this example we will use ~/src:<br />
<pre class="prettyprint prettyprinted"><code><span class="pln">cd </span><span class="pun">~/</span><span class="pln">src</span></code></pre>
</li>
<li>Download the kernel:<br />
<pre class="prettyprint prettyprinted"><code><span class="pln">wget </span><span class="str">'https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.15.8.tar.xz'</span></code></pre>
Replace <code>v3.x/linux-3.15.8.tar.xz</code> with the kernel version you want to download. 3.15.8 was the latest stable version at the time of writing.</li>
<li>Extract the files:<br />
<pre class="prettyprint prettyprinted"><code><span class="pln">tar xf linux</span><span class="pun">-</span><span class="lit">3.15</span><span class="pun">.</span><span class="lit">8.tar</span><span class="pun">.</span><span class="pln">xz</span></code></pre>
Again, make sure to change the filename to be the same as the file you downloaded. You can also remove the original tar.xz file once all the files have been extracted.</li>
<li>Change the directory:<br />
<pre class="prettyprint prettyprinted"><code><span class="pln">cd linux</span><span class="pun">-</span><span class="lit">3.15</span><span class="pun">.</span><span class="lit">8</span></code></pre>
The directory name will be the same as the filename of the tar.xz you downloaded, except without the <code>.tar.xz</code>.</li>
<li>Copy the kernel config file from your existing system to the kernel tree:<br />
<pre class="prettyprint prettyprinted"><code><span class="pln">cp </span><span class="pun">/</span><span class="pln">boot</span><span class="pun">/</span><span class="pln">config</span><span class="pun">-</span><span class="str">`uname -r`</span><span class="pln"> </span><span class="pun">.</span><span class="pln">config</span></code></pre>
</li>
<li>Bring the config file up to date. In cases where your kernel source is significantly newer than the existing config file, you’ll be presented with all of the new config options for which there is no existing config file setting. You can either sit there and keep hitting Enter to take the default (generally safe), or you can just run:<br />
<pre class="prettyprint prettyprinted"><code><span class="pln">yes </span><span class="str">''</span><span class="pln"> </span><span class="pun">|</span><span class="pln"> make oldconfig</span></code></pre>
which emulates exactly the same thing and saves you all that time. Otherwise, run:<br />
<pre class="prettyprint prettyprinted"><code><span class="pln">make oldconfig</span></code></pre>
</li>
<li>(optional) If you need to make any kernel config changes, do the following and save your changes when prompted:<br />
<pre class="prettyprint prettyprinted"><code><span class="pln">make menuconfig</span></code></pre>
</li>
<li>Clean the kernel source directory:<br />
<pre class="prettyprint prettyprinted"><code><span class="pln">make clean</span></code></pre>
</li>
<li>Build the linux-image and linux-header .deb files using a thread per core + 1. This process can take a lot of time - it took about 17 hours on my old laptop with a Celeron processor, but it should take between 20 minutes and 3 hours on a modern computer:<br />
<pre class="prettyprint prettyprinted"><code><span class="pln">make </span><span class="pun">-</span><span class="pln">j </span><span class="str">`getconf _NPROCESSORS_ONLN`</span><span class="pln"> deb</span><span class="pun">-</span><span class="pln">pkg LOCALVERSION</span><span class="pun">=-</span><span class="pln">custom</span></code></pre>
With this command the package names will be something like linux-image-3.15.8-custom and linux-headers-3.15.8-custom, and in that case the version will be 3.15.8-custom-10.00.Custom. You may change the string “custom” into something else by changing the LOCALVERSION option.</li>
<li>Change to one directory level up (this is where the linux-image and linux-header .deb files were put):<br />
<pre class="prettyprint prettyprinted"><code><span class="pln">cd </span><span class="pun">../</span></code></pre>
</li>
<li>Now install the .deb files. Replace the filenames in this example to match your filenames:
<pre class="prettyprint prettyprinted"><code><span class="pln">sudo dpkg </span><span class="pun">-</span><span class="pln">i linux</span><span class="pun">-firmware-</span><span class="pln">image</span><span class="pun">-</span><span class="lit">3.15</span><span class="pun">.</span><span class="lit">8</span><span class="pun">-</span><span class="pln">custom_3</span><span class="pun">.</span><span class="lit">15.8</span><span class="pun">-</span><span class="pln">custom</span><span class="pun">-</span><span class="lit">1</span><span class="typ">_i386</span><span class="pun">.</span><span class="pln">deb </span></code></pre>
<pre class="prettyprint prettyprinted"><code><span class="pln">sudo dpkg </span><span class="pun">-</span><span class="pln">i linux</span><span class="pun">-</span><span class="pln">headers</span><span class="pun">-</span><span class="lit">3.15</span><span class="pun">.</span><span class="lit">8</span><span class="pun">-</span><span class="pln">custom_3</span><span class="pun">.</span><span class="lit">15.8</span><span class="pun">-</span><span class="pln">custom</span><span class="pun">-</span><span class="lit">1</span><span class="typ">_i386</span><span class="pun">.</span><span class="pln">deb </span></code></pre>
<pre class="prettyprint prettyprinted"><code><span class="pln">sudo dpkg -i linux-image-3.15.8-custom_3.15.8-custom-1_i386.deb </span></code></pre>
<pre class="prettyprint prettyprinted"><code><span class="pln">sudo dpkg -i linux-image-3.15.8-custom-dbg_3.15.8-custom-1_i386.deb </span></code></pre>
<pre class="prettyprint prettyprinted"><code><span class="pln">sudo dpkg -i linux-libc-dev_3.15.8-custom-1_i386.deb</span></code></pre>
</li>
<li>Reboot to your new kernel! Just make sure you select it when you boot:<br />
<pre class="prettyprint prettyprinted"><code><span class="pln">sudo reboot</span></code></pre>
</li>
</ol>
This article was updated on the third of August after following these instructions myself to check everything worked.Anonymoushttp://www.blogger.com/profile/07644067784187311179noreply@blogger.com0