<?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>Mike Plate</title>
	<atom:link href="http://www.mikeplate.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mikeplate.com</link>
	<description>Freelance web and mobile developer</description>
	<lastBuildDate>Thu, 24 Nov 2011 15:43:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Creating a closure in JavaScript</title>
		<link>http://www.mikeplate.com/2011/11/24/creating-a-closure-in-javascript/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=creating-a-closure-in-javascript</link>
		<comments>http://www.mikeplate.com/2011/11/24/creating-a-closure-in-javascript/#comments</comments>
		<pubDate>Thu, 24 Nov 2011 15:34:31 +0000</pubDate>
		<dc:creator>mikeplate</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.mikeplate.com/?p=526</guid>
		<description><![CDATA[I thought that I knew how closures worked in JavaScript, but then I was bitten by a bug that made me realize I had some more learning to do. This article is the result of that learning. It describes one particular situation where you need to explicitly create a closure  in JavaScript, but I also [...]]]></description>
			<content:encoded><![CDATA[<p>I thought that I knew how closures worked in JavaScript, but then I was bitten by a bug that made me realize I had some more learning to do. This article is the result of that learning. It describes one particular situation where you need to explicitly create a closure  in JavaScript, but I also think it illustrates closures in general.<span id="more-526"></span></p>
<h2>The problem</h2>
<p>Take a very simple html page with three elements, like these:</p>
<blockquote>
<pre>&lt;h1&gt;A&lt;/h1&gt;
&lt;h1&gt;B&lt;/h1&gt;
&lt;h1&gt;C&lt;/h1&gt;</pre>
</blockquote>
<p>Now assume you would like to bind the click event to all of the h1-elements on the page. To prove that something happens, I will just add a word to the contents of the h1 element when it is clicked. The code looks like this:</p>
<blockquote>
<pre>var elements = document.getElementsByTagName("h1");
for (var i = 0; i&lt;elements.length; i++) {
	var el = elements[i];
	el.addEventListener("click", function() {
		el.innerHTML += ", clicked";
	}, false);
}</pre>
</blockquote>
<p>I thought this would work. Turns out it doesn&#8217;t. If you run it, all clicks will add the word to the last element. Even when you click the A, the word will be added to the end of the last element with a C.</p>
<p>You can try it out using jsFiddle <a title="jsFiddle example" href="http://jsfiddle.net/mikeplate/UVDUH/1/">here</a>.</p>
<p>My mistake was assuming that a closure was made inside of my function doing the &#8220;el.innerHTML&#8221; assignment, making sure that the &#8220;el&#8221; variable was frozen it time and would always refer to the value/element I had when the code was executed. But that is not so. The rule here is that no matter where you declare a variable in JavaScript with the &#8220;var&#8221; keyword, it will always act as though it was declared at the beginning of the innermost function anyway.</p>
<p>As a side example, these two code sections are the same when it comes to the scope of the &#8220;str&#8221; variable.</p>
<blockquote>
<pre>function my() {
    for (var i = 0; i&lt;10; i++) {
        var str = i.toString();
    }
}</pre>
</blockquote>
<blockquote>
<pre>function my() {
    var str;
    for (var i = 0; i&lt;10; i++) {
        str = i.toString();
    }
}</pre>
</blockquote>
<h2>The solution</h2>
<p>The way to freeze the &#8220;el&#8221; variable at the time of calling addEventLister, is to explicitly create a closure. A closure is a JavaScript function. The function is the only container that will freeze a variable at the time of execution, which is what a closure is, really.</p>
<p>This is one way of ensuring that the code works as expected:</p>
<blockquote>
<pre>var elements = document.getElementsByTagName("h1");
for (var i = 0; i&lt;elements.length; i++) {
    (function(el) {
        el.addEventListener("click", function() {
            el.innerHTML += ", clicked";
        }, false);
    })(elements[i]);
}</pre>
</blockquote>
<p>Notice how the call to addEventListener is now wrapped in an anonymous function, and how that anonymous function is also called in the same statement, by putting the &#8220;(elements[i])&#8221; at the end.</p>
<p>You can verify that the solution works at jsFiddle <a title="jsFiddle example, the solution" href="http://jsfiddle.net/mikeplate/UVDUH/2/">here</a>.</p>
<p>If you like, you can also extract the closure part into a separate function, which may improve the readability of the code. One such alternative solutions would be:</p>
<blockquote>
<pre>function handleClick(el, func) {
    el.addEventListener("click", function(ev) { func(el); }, false);
}

var elements = document.getElementsByTagName("h1");
for (var i = 0; i&lt;elements.length; i++) {
    handleClick(elements[i], function(el) {
        el.innerHTML += ", clicked";
    });
}</pre>
</blockquote>
<p>Or even slightly more generic and succinct:</p>
<blockquote>
<pre>function createHandler(el) { return function(ev) { el.innerHTML += ", clicked"; }; };
var elements = document.getElementsByTagName("h1");
for (var i = 0; i&lt;elements.length; i++) {
	var el = elements[i];
	el.addEventListener("click", createHandler(el), false);
}</pre>
</blockquote>
<p>One difference in the last example is that the closure encloses less of the code (only the assignment of innerHTML). Also note that the function &#8220;createHandler&#8221; is return an anonymous function in itself. It could be called a &#8220;factory&#8221; since it doesn&#8217;t execute any code, but just returns created functions that will be called later.</p>
<p>I guess what solution you use is dependent on what you are trying to do.</p>
<p>&nbsp;</p>
 <p><a href="http://www.mikeplate.com/?flattrss_redirect&amp;id=526&amp;md5=066e15b57e007dc38b810dafda912638" title="Flattr" target="_blank"><img src="http://www.mikeplate.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.mikeplate.com/2011/11/24/creating-a-closure-in-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux file permissions to only delete owned files</title>
		<link>http://www.mikeplate.com/2011/11/18/linux-file-permissions-to-only-delete-owned-files/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=linux-file-permissions-to-only-delete-owned-files</link>
		<comments>http://www.mikeplate.com/2011/11/18/linux-file-permissions-to-only-delete-owned-files/#comments</comments>
		<pubDate>Fri, 18 Nov 2011 16:36:42 +0000</pubDate>
		<dc:creator>mikeplate</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.mikeplate.com/?p=510</guid>
		<description><![CDATA[Coming from a Windows background, I was surprised to find out that when it comes to Linux file permissions, a user can delete a file that they don&#8217;t own and have no write permissions to. Well, that is the default behavior if you don&#8217;t set up your ownership and permissions exactly correct. Find out how [...]]]></description>
			<content:encoded><![CDATA[<p>Coming from a Windows background, I was surprised to find out that when it comes to Linux file permissions, a user can delete a file that they don&#8217;t own and have no write permissions to. Well, that is the default behavior if you don&#8217;t set up your ownership and permissions exactly correct. Find out how here.<span id="more-510"></span></p>
<h2>The goal</h2>
<p>This is what I want for a specific directory:</p>
<ul>
<li>The user can create new directories and files</li>
<li>The user can delete directories and files that the user has created (and thereby is owner of)</li>
<li>The user cannot write to or delete specific pre-existing protected files and directories</li>
</ul>
<p>My practical use case was an ftp+web server where I wanted users to upload and create directories all they want, but protect a readme.txt in the root and a pre-made sample in the demo directory.</p>
<p>First of all, removing write permissions and thereby blocking any updates is easy. That follows what I consider normal logic. By setting myself as owner and removing write permission for others, that was no problem. However, to my surprise, the user could still delete the now write-protected file and directory!</p>
<p>The problem is that on Linux, if you have write permissions to the directory where the files reside (or owns the directory), you always have permission to delete anything in there, regardless of anything else. And you need to give the user write permissions to the directory in order for them to create new files and update the files they have created.</p>
<h2>The solution</h2>
<p>There are two things you need to do besides setting the right permissions of the actual file or directory that you want to protect. Make sure that you:</p>
<ul>
<li>Set the <a title="Sticky bit reference" href="http://en.wikipedia.org/wiki/Sticky_bit">sticky bit</a> of the directory</li>
<li>Set the owner of the directory to yourself (or any other higher authority)</li>
</ul>
<p>So let&#8217;s make a few assumptions in order to show you the commands:</p>
<ul>
<li>The file to protect in the directory is named &#8220;readme.txt&#8221;</li>
<li>The user that should have access to the directory is named &#8220;www-data&#8221;</li>
<li>I&#8217;m an administrator on the machine and my user name is &#8220;mikael&#8221;</li>
</ul>
<p>Having changed to the directory in question, I do the following as root:</p>
<blockquote><p>chmod 1775 .<br />
chown mikael:www-data .<br />
chown mikael:www-data readme.txt</p></blockquote>
<p>Note that the &#8220;1&#8243; in the chmod command is what sets the sticky bit.</p>
<p>With the user having uploaded an image and created a directory named &#8220;test&#8221;, a listing should look like this:</p>
<blockquote>
<pre>drwxrwxr-t 3 mikael   www-data  4096 2011-11-16 04:43 .
drwxrwxr-x 5 mikael   mikael    4096 2011-11-08 16:13 ..
-rw-r--r-- 1 www-data www-data 79383 2011-11-16 03:51 logo.jpg
-rw-r--r-- 1 mikael   www-data    15 2011-11-16 04:11 readme.txt
drwx---r-x 2 www-data www-data  4096 2011-11-15 17:55 test</pre>
</blockquote>
<p>This works just the way I want. The ftp server runs as user &#8220;www-data&#8221; and the users logging in can upload files and create directories all they want but they can&#8217;t delete &#8220;readme.txt&#8221;.</p>
<p>I was looking at installing and configure ACLs on Linux (Access Control Lists) to solve the problem, but since this works I didn&#8217;t have to do that.</p>
<p>&nbsp;</p>
 <p><a href="http://www.mikeplate.com/?flattrss_redirect&amp;id=510&amp;md5=d24d8f0cfa2ae8efb6d15cedfee47d6a" title="Flattr" target="_blank"><img src="http://www.mikeplate.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.mikeplate.com/2011/11/18/linux-file-permissions-to-only-delete-owned-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Making web site certificate work for Android</title>
		<link>http://www.mikeplate.com/2011/11/16/making-web-site-certificate-work-for-android/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=making-web-site-certificate-work-for-android</link>
		<comments>http://www.mikeplate.com/2011/11/16/making-web-site-certificate-work-for-android/#comments</comments>
		<pubDate>Wed, 16 Nov 2011 21:10:00 +0000</pubDate>
		<dc:creator>mikeplate</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[ssl]]></category>

		<guid isPermaLink="false">http://www.mikeplate.com/?p=515</guid>
		<description><![CDATA[I installed a web site certificate called GeoTrust QuickSSL from http://cheapssls.com on a site of mine. That wasn&#8217;t too hard I think. Everything looked fine when I tested it on my desktop browsers. However inside of the Android emulator (version 2.1 and others) and also on my newest Android device (running 2.3.5) I got a [...]]]></description>
			<content:encoded><![CDATA[<p>I installed a web site certificate called GeoTrust QuickSSL from <a title="CheapSSLs" href="http://cheapssls.com">http://cheapssls.com</a> on a site of mine. That wasn&#8217;t too hard I think. Everything looked fine when I tested it on my desktop browsers. However inside of the Android emulator (version 2.1 and others) and also on my newest Android device (running 2.3.5) I got a warning that the certificate wasn&#8217;t trusted.<span id="more-515"></span></p>
<p>Turns out I had some more learning to do regarding SSL and certificates. At first, I thought that maybe the root certificate for this GeoTrust QuickSSL simply wasn&#8217;t available on Android. The sites explaining mobile browser support are pretty vague on where they will work. However, that was not the case. It was actually not that hard to fix once I found the correct information. The online chat support at CheapSSLs pointed me in the right direction, although it took some further investigation.</p>
<h2>The solution</h2>
<p>Two things need to be fixed for older Android versions, like 2.1. (The first one was sufficient for my newest version of 2.3.5.)</p>
<ul>
<li>Add GeoTrust intermediate certificate data to the end of your web site certificate</li>
<li>Add GeoTrust CA certificate data to the end of previous step</li>
</ul>
<p>Both of these certificate&#8217;s data are plain text that can be added to the end of your current web site certificate, probably named &#8220;.pem&#8221; or &#8220;.crt&#8221;. The GeoTrust intermediate certificate data (at time of writing) is:</p>
<blockquote>
<pre>-----BEGIN CERTIFICATE-----
MIID+jCCAuKgAwIBAgIDAjbSMA0GCSqGSIb3DQEBBQUAMEIxCzAJBgNVBAYTAlVT
MRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMRswGQYDVQQDExJHZW9UcnVzdCBHbG9i
YWwgQ0EwHhcNMTAwMjI2MjEzMjMxWhcNMjAwMjI1MjEzMjMxWjBhMQswCQYDVQQG
EwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEdMBsGA1UECxMURG9tYWluIFZh
bGlkYXRlZCBTU0wxGzAZBgNVBAMTEkdlb1RydXN0IERWIFNTTCBDQTCCASIwDQYJ
KoZIhvcNAQEBBQADggEPADCCAQoCggEBAKa7jnrNpJxiV9RRMEJ7ixqy0ogGrTs8
KRMMMbxp+Z9alNoGuqwkBJ7O1KrESGAA+DSuoZOv3gR+zfhcIlINVlPrqZTP+3RE
60OUpJd6QFc1tqRi2tVI+Hrx7JC1Xzn+Y3JwyBKF0KUuhhNAbOtsTdJU/V8+Jh9m
cajAuIWe9fV1j9qRTonjynh0MF8VCpmnyoM6djVI0NyLGiJOhaRO+kltK3C+jgwh
w2LMpNGtFmuae8tk/426QsMmqhV4aJzs9mvIDFcN5TgH02pXA50gDkvEe4GwKhz1
SupKmEn+Als9AxSQKH6a9HjQMYRX5Uw4ekIR4vUoUQNLIBW7Ihq28BUCAwEAAaOB
2TCB1jAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFIz02ZMKR7wAoErOS3VuoLaw
sn78MB8GA1UdIwQYMBaAFMB6mGiNifurBWQMEX2qfWW4ysxOMBIGA1UdEwEB/wQI
MAYBAf8CAQAwOgYDVR0fBDMwMTAvoC2gK4YpaHR0cDovL2NybC5nZW90cnVzdC5j
b20vY3Jscy9ndGdsb2JhbC5jcmwwNAYIKwYBBQUHAQEEKDAmMCQGCCsGAQUFBzAB
hhhodHRwOi8vb2NzcC5nZW90cnVzdC5jb20wDQYJKoZIhvcNAQEFBQADggEBADOR
NxHbQPnejLICiHevYyHBrbAN+qB4VqOC/btJXxRtyNxflNoRZnwekcW22G1PqvK/
ISh+UqKSeAhhaSH+LeyCGIT0043FiruKzF3mo7bMbq1vsw5h7onOEzRPSVX1ObuZ
lvD16lo8nBa9AlPwKg5BbuvvnvdwNs2AKnbIh+PrI7OWLOYdlF8cpOLNJDErBjgy
YWE5XIlMSB1CyWee0r9Y9/k3MbBn3Y0mNhp4GgkZPJMHcCrhfCn13mZXCxJeFu1e
vTezMGnGkqX2Gdgd+DYSuUuVlZzQzmwwpxb79k1ktl8qFJymyFWOIPllByTMOAVM
IIi0tWeUz12OYjf+xLQ=
-----END CERTIFICATE-----</pre>
</blockquote>
<p>The GeoTurst CA certificate data (at the time of writing) is:</p>
<blockquote>
<pre>-----BEGIN CERTIFICATE-----
MIIDfTCCAuagAwIBAgIDErvmMA0GCSqGSIb3DQEBBQUAME4xCzAJBgNVBAYTAlVT
MRAwDgYDVQQKEwdFcXVpZmF4MS0wKwYDVQQLEyRFcXVpZmF4IFNlY3VyZSBDZXJ0
aWZpY2F0ZSBBdXRob3JpdHkwHhcNMDIwNTIxMDQwMDAwWhcNMTgwODIxMDQwMDAw
WjBCMQswCQYDVQQGEwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEbMBkGA1UE
AxMSR2VvVHJ1c3QgR2xvYmFsIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
CgKCAQEA2swYYzD99BcjGlZ+W988bDjkcbd4kdS8odhM+KhDtgPpTSEHCIjaWC9m
OSm9BXiLnTjoBbdqfnGk5sRgprDvgOSJKA+eJdbtg/OtppHHmMlCGDUUna2YRpIu
T8rxh0PBFpVXLVDviS2Aelet8u5fa9IAjbkU+BQVNdnARqN7csiRv8lVK83Qlz6c
JmTM386DGXHKTubU1XupGc1V3sjs0l44U+VcT4wt/lAjNvxm5suOpDkZALeVAjmR
Cw7+OC7RHQWa9k0+bw8HHa8sHo9gOeL6NlMTOdReJivbPagUvTLrGAMoUgRx5asz
PeE4uwc2hGKceeoWMPRfwCvocWvk+QIDAQABo4HwMIHtMB8GA1UdIwQYMBaAFEjm
aPkr0rKV10fYIyAQTzOYkJ/UMB0GA1UdDgQWBBTAephojYn7qwVkDBF9qn1luMrM
TjAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjA6BgNVHR8EMzAxMC+g
LaArhilodHRwOi8vY3JsLmdlb3RydXN0LmNvbS9jcmxzL3NlY3VyZWNhLmNybDBO
BgNVHSAERzBFMEMGBFUdIAAwOzA5BggrBgEFBQcCARYtaHR0cHM6Ly93d3cuZ2Vv
dHJ1c3QuY29tL3Jlc291cmNlcy9yZXBvc2l0b3J5MA0GCSqGSIb3DQEBBQUAA4GB
AHbhEm5OSxYShjAGsoEIz/AIx8dxfmbuwu3UOx//8PDITtZDOLC5MH0Y0FWDomrL
NhGc6Ehmo21/uBPUR/6LWlxz/K7ZGzIZOKuXNBSqltLroxwUCEm2u+WR74M26x1W
b8ravHNjkOR/ez4iyz0H7V84dJzjA1BOoa+Y7mHyhD8S
-----END CERTIFICATE-----</pre>
</blockquote>
<p>(<a title="Reference" href="https://knowledge.geotrust.com/support/knowledge-base/index?page=content&amp;id=AR1426&amp;actp=search&amp;viewlocale=en_US&amp;searchid=1283360269668">Reference</a>)</p>
<p>So now your pem or crt file should have 3 certificate sections in it. You need to reload you configuration to pick up the new certificate (nginx). I&#8217;m sure this can be applied for other certificate authorities too, just with other data that you&#8217;ll have to find for yourself.</p>
<h2>Background</h2>
<p>Evidently, desktop browsers, can find and download the intermediate certificate by their own and so it worked there from the start. I don&#8217;t know what the status of this issue is on iOS or other devices.</p>
<p>If I look at the properties of my web site certificate when I visit the site in a desktop browser I can clearly see that there are two parents to my certficiate. The first one being the &#8220;intermediate&#8221; certificate. And since they don&#8217;t seem to be found any other way by Android, it need to be added to the web site certificate as per the solution above.</p>
<p>This tool also helped me verify what I was missing from the start: <a title="SSL Checker" href="http://www.sslshopper.com/ssl-checker.html">http://www.sslshopper.com/ssl-checker.html</a></p>
<p>For the GeoTrust CA certificate (the root, the parent of the intermediate certificate) it seems it was changed 2010-12-09 which I guess is the reason why it was already available on Android 2.3.5 but not on 2.1 (at least not in the emulator). However, the new CA certificate can be chained in its turn to the &#8220;Equifax Secure Certificate Authority Root CA&#8221; which IS available on older Android versions like 2.1 and therefore it will work if you just add it to the end of your other two certificates. At least, this is how I assume it can be explained.</p>
<p>So now I can visit my site over https and not get any warnings neither on Android 2.3.5 or Android 2.1. And more importantly, my visitors can too! Happy days.</p>
<h2>But no SNI, so not multiple certificates with same ip</h2>
<p>Well, not perfect still, unfortunately. On my nginx box I have managed to install multiple certificates for the same ip address. I only have one single ip address on that virtual server (for the time being anyway). It has worked fine with desktop browsers, but while investigating the issue above, I also came across information about how this actually works. And why it doesn&#8217;t work on Android until version 4.0, of which we have no devices yet (at time of writing).</p>
<p>This works thanks to an extension called Server Name Indication, explained here <a href="http://en.wikipedia.org/wiki/Server_Name_Indication">http://en.wikipedia.org/wiki/Server_Name_Indication</a>. This makes it possible for the browser to send the server name (host name / domain name of site) before the actual protection begins. And therefore it is possible for the web server to disinguish between sites and certificates on the same server and ip.</p>
<p>The bad news is that SNI has been slow to be incorporated in the Android OS and is simply not available on older versions than 4.0. At least it should be included in version 4.0 now.</p>
<p>What will happen when an pre-4.0 Android browser connects to the server, is that the browser will always only see the first/default certificate (however you might configure it in the web server). So it will still work for one https site, but for the others the user will get a warning that the certificate doesn&#8217;t correspond to the domain name.</p>
<p>&nbsp;</p>
 <p><a href="http://www.mikeplate.com/?flattrss_redirect&amp;id=515&amp;md5=9745ab6d0a70e2f1df61e885fdd1ac63" title="Flattr" target="_blank"><img src="http://www.mikeplate.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.mikeplate.com/2011/11/16/making-web-site-certificate-work-for-android/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Change virtual console resolution on Ubuntu</title>
		<link>http://www.mikeplate.com/2011/11/08/change-virtual-console-resolution-on-ubuntu/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=change-virtual-console-resolution-on-ubuntu</link>
		<comments>http://www.mikeplate.com/2011/11/08/change-virtual-console-resolution-on-ubuntu/#comments</comments>
		<pubDate>Tue, 08 Nov 2011 09:23:13 +0000</pubDate>
		<dc:creator>mikeplate</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.mikeplate.com/?p=506</guid>
		<description><![CDATA[When installing Ubuntu Server 11.10 on my Windows-hosted VirtualBox the default console resolution is very small (640&#215;480 I think). But changing it is very easy. The solution In the Ubuntu console window, open the following file in your editor of choice: sudo vim /etc/default/grub Uncomment the following line and set another resolution for it, for [...]]]></description>
			<content:encoded><![CDATA[<p>When installing Ubuntu Server 11.10 on my Windows-hosted VirtualBox the default console resolution is very small (640&#215;480 I think). But changing it is very easy.<span id="more-506"></span></p>
<h2>The solution</h2>
<p>In the Ubuntu console window, open the following file in your editor of choice:</p>
<blockquote><p>sudo vim /etc/default/grub</p></blockquote>
<p>Uncomment the following line and set another resolution for it, for instance 1024&#215;768:</p>
<blockquote><p>GRUB_GFXMODE=1024&#215;768</p></blockquote>
<p>Next, write this new information for the next boot with the command:</p>
<blockquote><p>sudo update-grub2</p></blockquote>
<p>And then reboot to see the effect:</p>
<blockquote><p>sudo shutdown -r 0</p></blockquote>
<p>&nbsp;</p>
 <p><a href="http://www.mikeplate.com/?flattrss_redirect&amp;id=506&amp;md5=a5e56ce886c14999a360ce75607722df" title="Flattr" target="_blank"><img src="http://www.mikeplate.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.mikeplate.com/2011/11/08/change-virtual-console-resolution-on-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Stop http.sys from listening on port 80 in Windows</title>
		<link>http://www.mikeplate.com/2011/11/06/stop-http-sys-from-listening-on-port-80-in-windows/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=stop-http-sys-from-listening-on-port-80-in-windows</link>
		<comments>http://www.mikeplate.com/2011/11/06/stop-http-sys-from-listening-on-port-80-in-windows/#comments</comments>
		<pubDate>Sun, 06 Nov 2011 14:10:03 +0000</pubDate>
		<dc:creator>mikeplate</dc:creator>
				<category><![CDATA[Windows]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.mikeplate.com/?p=500</guid>
		<description><![CDATA[On Windows 7 there is a system service called http.sys that listens on port 80. That makes it impossible to run applications and services that haven&#8217;t been integrated with this feature to also listen on port 80, like Apache HTTP Server or Nginx. Here is one way to solve that problem. Background information First of [...]]]></description>
			<content:encoded><![CDATA[<p>On Windows 7 there is a system service called http.sys that listens on port 80. That makes it impossible to run applications and services that haven&#8217;t been integrated with this feature to also listen on port 80, like Apache HTTP Server or Nginx. Here is one way to solve that problem.<span id="more-500"></span></p>
<h2>Background information</h2>
<p>First of all, the way http.sys works on newer Windows versions is a very useful feature. The reason behind http.sys is to have a single system service that listens on the all-important port 80 and be a mediator to different applications and services in the system that might like to handle incoming requests on port 80 but for different urls. What an integrated Windows application does, is use a Windows API for registering its own urls and then have them directed to itself. At the same time, there can be other applications also getting incoming requests to port 80 but for different registered urls.</p>
<h2>The problem</h2>
<p>The problem is that some (many?) open source project that have been compiled for Windows, does not use this http.sys API. Therefore, when they start up and try to bind to port 80, they will fail since it is occupied by http.sys. And I have to admit that I have no idea how easy or hard it would be to patch such a project to make that call on Windows and get the tcp/ip network stack to work with it.</p>
<p>Examples of such projects are:</p>
<ul>
<li>Apache HTTP Server</li>
<li>Nginx</li>
</ul>
<p>(Haven&#8217;t looked at how nodejs does it.)</p>
<h2>The solution</h2>
<p>Some solutions I&#8217;ve found suggests disabling http.sys, but that only works if you are sure you won&#8217;t have any use for Windows applications that do know about http.sys. I didn&#8217;t want to do that.</p>
<p>My suggested solution is instead to tell http.sys to bind to a specific ip-address, and then use any other ip-addresses on your system for Nginx (or whatever you are looking to install). It turns out this is possible via the netsh command line configuration tool in Windows (from version 7 anyway).</p>
<p>So, one way would be to add an extra ip address to your network configuration. But I chose instead to use the fact that every system nowadays has both an ipv4 and an ipv6 address. My solution is to bind http.sys to the ipv6 general address (named &#8220;::&#8221;) and thereby free up the local general ipv4 address (named &#8220;127.0.0.1&#8243;) for my Nginx server.</p>
<p>Telling http.sys to bind to the ipv6 general address is easy. Just run the follow command from a command prompt window as Administrator:</p>
<blockquote><p>netsh http add iplisten ipaddress=::</p></blockquote>
<p>It seems that the name &#8220;localhost&#8221; binds to the ipv6 address, actually &#8220;::1&#8243;, so from now on you can still get the http.sys applications and services via &#8220;http://localhost&#8221;. And if you install and run Nginx on port 80 it should start fine and be available at &#8220;http://127.0.0.1&#8243;. Or you could even edit your &#8220;C:\Windows\System32\drivers\etc\hosts&#8221; file and add the line:</p>
<blockquote><p>127.0.0.1 local</p></blockquote>
<p>Now having &#8220;localhost&#8221; for ipv6/http.sys and &#8220;local&#8221; for ipv4/Nginx.</p>
<p>&nbsp;</p>
 <p><a href="http://www.mikeplate.com/?flattrss_redirect&amp;id=500&amp;md5=4ffabcf6829a9935f96ca9cb2c9ead23" title="Flattr" target="_blank"><img src="http://www.mikeplate.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.mikeplate.com/2011/11/06/stop-http-sys-from-listening-on-port-80-in-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reorganizing commits in Git branches</title>
		<link>http://www.mikeplate.com/2011/04/13/reorganizing-commits-in-git-branches/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=reorganizing-commits-in-git-branches</link>
		<comments>http://www.mikeplate.com/2011/04/13/reorganizing-commits-in-git-branches/#comments</comments>
		<pubDate>Wed, 13 Apr 2011 08:29:25 +0000</pubDate>
		<dc:creator>mikeplate</dc:creator>
				<category><![CDATA[Source Control]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[sourcecontrol]]></category>

		<guid isPermaLink="false">http://www2.mikeplate.com/?p=460</guid>
		<description><![CDATA[It may take some time digging around the Git commands to do exactly what you want. I had a situation where I&#8217;ve gone too far in a version branch and needed some reorganization. This is a short description of what commands I ended up running. My situation was pretty basic and maybe typical of a [...]]]></description>
			<content:encoded><![CDATA[<p>It may take some time digging around the Git commands to do exactly what you want. I had a situation where I&#8217;ve gone too far in a version branch and needed some reorganization. This is a short description of what commands I ended up running.<span id="more-460"></span></p>
<p>My situation was pretty basic and maybe typical of a beginner in Git land. I had created a single extra branch from my master branch, named after the version I was working on. &#8220;3.1&#8243; in this case. I had like 40 commits to the &#8220;3.1&#8243; branch and no changes/commits to the master branch. The problem was that the version 3.1 had been released several commits ago. I had forgotten how to work with branches and continued to commit changes in the 3.1 branch, even though they belonged to the next 3.2 version.</p>
<p>So here are a few commands I ended up running to fix this. My goal was to get the master branch up to date, remove the commits from 3.1 branch that actually belonged to the next version and create the new 3.2 branch with those commits.</p>
<h2>Merging branches</h2>
<p>First step was to get the master branch up to date with all changes currently made to 3.1 branch. This is easy:</p>
<ul>
<li><a title="git checkout reference" href="http://www.kernel.org/pub/software/scm/git/docs/git-checkout.html">git checkout</a> master</li>
<li><a title="git merge reference" href="http://www.kernel.org/pub/software/scm/git/docs/git-merge.html">git merge</a> 3.1</li>
</ul>
<p>Note that you first change to the branch that should be updated and then tell Git to merge in the commits from another branch, in this case named &#8220;3.1&#8243;.</p>
<p>Also, since I hadn&#8217;t made any commits to the master branch, the merge is also called &#8220;fast-forward&#8221; since all changes can just be copied onto the master branch.</p>
<h2>Listing commits and find a specific date</h2>
<p>Next question was where I actually released version 3.1 and thereby where the 3.1 branch should be &#8220;cut&#8221;. For this I did:</p>
<ul>
<li><a title="git show-branch reference" href="http://www.kernel.org/pub/software/scm/git/docs/git-show-branch.html">git show-branch</a> --more=20 3.1</li>
<li>git checkout 3.1</li>
<li><a title="git log reference" href="http://www.kernel.org/pub/software/scm/git/docs/git-log.html">git log</a> --pretty=&#8221;format:%ci %h %s&#8221; -20</li>
</ul>
<p>Actually, the &#8220;git show-branch&#8221; didn&#8217;t help as much as &#8220;git log&#8221;, but I kept them both here for reference. I find that Git is sometimes a bit inconsistent, like specifying the number of commits to show as &#8220;--more=20&#8243; in one case and &#8220;-20&#8243; in another case.</p>
<p>Using &#8220;git log&#8221; and the format specifier I found the last commit that truly belonged to 3.1. I then used the short commit name from the output (code %h, 7 hex digits) for the next step.</p>
<h2>Removing commits from a branch</h2>
<p>Note that I already have copied all of my commits, both before and after the release of 3.1, onto the master branch. Therefore I will not remove anything important in this step. However, in other situations I am permanently removing code changes from a branch with this command so be careful when you do it yourself.</p>
<p>Using the commit shortname from the previous step, the removal of all commits after a specific one can be done in a single command.</p>
<ul>
<li><a title="git reset reference" href="http://www.kernel.org/pub/software/scm/git/docs/git-reset.html">git reset</a> --hard 08d99c4</li>
</ul>
<p>Also note that there will be no trace of the commits now removed. This was exactly what I wanted in this case. There is the &#8220;git revert&#8221; command for other scenarios (I think) where the actual change in the commit tree itself will be logged as a commit.</p>
<p>Since this repository is also hosted on a private server, there was an issue with pushing these changes to that server. The now changed branch (3.1) refused to be pushed. I guess this is to stop you from destroying other peoples work in that branch. Anyway, since I knew it was ok, I forced the push like:</p>
<ul>
<li><a title="git push reference" href="file:///C:/Users/Mikael/Applications/PortableGit/doc/git/html/git-push.html">git push</a> --all --force origin</li>
</ul>
<h2>Create a new version branch from master</h2>
<p>This step I had done before, but for completeness my last commands were:</p>
<ul>
<li>git checkout master</li>
<li><a title="git branch reference" href="http://www.kernel.org/pub/software/scm/git/docs/git-branch.html">git branch</a> 3.2</li>
</ul>
<p>And off I went to continue development on the 3.2 branch.</p>
<p>Side note: I&#8217;m not really sure what the best practice is here regarding &#8220;leaving the master branch behind&#8221; when moving on with the 3.2 branch. Of course, once I release 3.2 I&#8217;ll repeat updating master with all 3.2 changes, but during the development the master branch is left alone in my scenario. Maybe is should be moved forward too? Something to investigate for me, or for the initiated reader to add as a comment.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mikeplate.com/2011/04/13/reorganizing-commits-in-git-branches/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Beauty of Vim key combinations</title>
		<link>http://www.mikeplate.com/2011/01/23/beauty-of-vim-key-combinations/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=beauty-of-vim-key-combinations</link>
		<comments>http://www.mikeplate.com/2011/01/23/beauty-of-vim-key-combinations/#comments</comments>
		<pubDate>Sun, 23 Jan 2011 14:29:41 +0000</pubDate>
		<dc:creator>mikeplate</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[editor]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://www2.mikeplate.com/?p=19</guid>
		<description><![CDATA[I can&#8217;t yet say that I prefer Vim for editing text files in all situations. But I can say that I like it enough this far to continue on improving my Vim skills. One of the beautiful aspects of Vim is how keyboard shortcuts can be combined and this article describes some of those combinations. [...]]]></description>
			<content:encoded><![CDATA[<p>I can&#8217;t yet say that I prefer Vim for editing text files in all situations. But I can say that I like it enough this far to continue on improving my Vim skills. One of the beautiful aspects of Vim is how keyboard shortcuts can be combined and this article describes some of those combinations.<span id="more-19"></span></p>
<p>Lets look at a few actions that can be performed in Vim:</p>
<ul>
<li>d to delete</li>
<li>c to change (meaning delete followed by going into insert mode)</li>
<li>v to select</li>
<li>y to yank (meaning copy)</li>
</ul>
<p>Lets then look at a few movements that can be performed in Vim:</p>
<ul>
<li>w for next word</li>
<li>j for next line (or down arrow)</li>
<li>f followed by single character for next occurrence on the current line, including the character</li>
<li>t followed by single character for next occurrence on the current line, excluding the character</li>
<li>0 (zero) for start of current line (or home key)</li>
<li>$ for end of current line (or end key)</li>
</ul>
<p>Now consider that every action can be combined with every movement. So for every action, you can use any movement, and perform that action on the content covered by the movement.</p>
<p>A few examples:</p>
<ul>
<li>dw to delete the next word</li>
<li>vt) to select everything until the next closing parenthesis on the current line</li>
<li>c0 to change everything from the start of the current line to the cursor position</li>
<li>yj to copy the rest of the current line and the beginning of the next line up to the cursor position</li>
</ul>
<p>Also, every movement can be repeated by prefixing the movement with a number, describing the movement count. Note that some movements make no sense in repeating, like the start and end of the current line (the count will not have any extra effect). A few examples:</p>
<ul>
<li>d3w to delete the next three words</li>
<li>v2t) to select everything until the second closing parenthesis on the current line</li>
</ul>
<p>Isn&#8217;t it beautiful? So even though the chosen keyboard shortcuts, and their combinations, might seem strange in a single case, there is order and thought to how they was constructed. And this is also what makes vim kind of fun to use. You can always find new combinations to enhance your editing, combinations you&#8217;ve not thought of before. Constant room for improving your skills.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mikeplate.com/2011/01/23/beauty-of-vim-key-combinations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bash script to copy permissions</title>
		<link>http://www.mikeplate.com/2010/12/04/bash-script-to-copy-permissions/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=bash-script-to-copy-permissions</link>
		<comments>http://www.mikeplate.com/2010/12/04/bash-script-to-copy-permissions/#comments</comments>
		<pubDate>Sat, 04 Dec 2010 21:31:29 +0000</pubDate>
		<dc:creator>mikeplate</dc:creator>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[bashscript]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www2.mikeplate.com/?p=5</guid>
		<description><![CDATA[This is a bash script that I&#8217;ve used on Ubuntu in order to copy the permissions from a file or directory, onto the whole structure of another directory. I&#8217;ve found that this is something I like to do quite often and wanted some automation for this operation. First of all I needed a few commands [...]]]></description>
			<content:encoded><![CDATA[<p>This is a bash script that I&#8217;ve used on Ubuntu in order to copy the permissions from a file or directory, onto the whole structure of another directory. I&#8217;ve found that this is something I like to do quite often and wanted some automation for this operation.<span id="more-5"></span></p>
<p>First of all I needed a few commands for my script. They were:</p>
<pre>chown -R username:groupname dirname
chmod -R flags dirname</pre>
<p>Where</p>
<ul>
<li>dirname is the name of the destination directory</li>
<li>username is the name of the owner that will own the directory</li>
<li>groupname is the name of the group that will own the directory</li>
<li>flags is the numerical value for the permissions of the directory</li>
<li>-R specifies that the operation will occur recursively for all children of the directory</li>
</ul>
<p>Next step was to retrieve the current values for an existing file or directory that I know I wanted to copy the permissons from. For that, I can use the stat command with a format string:</p>
<pre>stat -c%u:%g filename
stat -c%a filename</pre>
<p>Where</p>
<ul>
<li>filename is the existing file (or directory)</li>
<li>-c specifices that the output of the command should include and be formatted according to the following format</li>
<li>%u means the id of the user that owns the file</li>
<li>%g means the id of the group that owns the file</li>
<li>%a means the numerical value for the permissions of the file</li>
</ul>
<p>Next, I needed to provide the output of the stat commands as input (or part of the input) to the chown and chmod commands. This is done with Bash using the following notation:</p>
<pre>command $(command-with-output)</pre>
<p>This led me to the following commands:</p>
<pre>chown -R $(stat -c%u:%g source) destination
chmod -R $(stat -c%a source) destination</pre>
<p>If you specify your own source and destination, these commands can be run from the Bash prompt. But I also wanted to put them inside a Bash script so I didn&#8217;t have to do all this typing. I also added some validation and came up with the following script:</p>
<pre>#!/bin/bash
if [ -z $1 ] || ([ ! -d $1 ] &amp;&amp; [ ! -f $1 ]); then
  echo "Not a file or directory as first argument"
  exit 0
fi
if [ -z $2 ] || [ ! -d $2 ]; then
  echo "Not a directory as second argument"
  exit 0
fi
chown -R $(stat -c%u:%g $1) $2
chmod -R $(stat -c%a $1) $2</pre>
<p>Some things to note from the script:</p>
<ul>
<li>-z is true if the following variable is empty (zero length)</li>
<li>-d is true if the following variable is a directory</li>
<li>-f is true if the following variable is a directory</li>
<li>! negates the condition</li>
<li>|| means &#8220;or&#8221; and &amp;&amp; means &#8220;and&#8221;</li>
<li>The semicolon before &#8220;then&#8221; is important, but can be omitted if &#8220;then&#8221; is moved to a line of its own</li>
</ul>
<p>This script has served me well. I hope you&#8217;ll find it useful too.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mikeplate.com/2010/12/04/bash-script-to-copy-permissions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Install Android development environment on Windows 7</title>
		<link>http://www.mikeplate.com/2010/11/01/install-android-development-environment-on-windows-7/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=install-android-development-environment-on-windows-7</link>
		<comments>http://www.mikeplate.com/2010/11/01/install-android-development-environment-on-windows-7/#comments</comments>
		<pubDate>Mon, 01 Nov 2010 20:37:25 +0000</pubDate>
		<dc:creator>mikeplate</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.mikeplate.com/?p=367</guid>
		<description><![CDATA[About a year ago I wrote a blog post about how to get started with Android development on Windows. At lot of new versions has been released since then, even though the basic packages needed are the same. This is a recap of what to download and how to set it up in order to [...]]]></description>
			<content:encoded><![CDATA[<p>About a year ago I wrote a blog post about how to get started with Android development on Windows. At lot of new versions has been released since then, even though the basic packages needed are the same. This is a recap of what to download and how to set it up in order to develop Android applications on Windows 7 (64-bit).<span id="more-367"></span></p>
<p>My background is primarily in Microsoft.NET and Microsoft Visual Studio, so it did feel a little different when I first entered the world of Java and Android development. But once you get past those initial hurdles, it isn&#8217;t as different as you first might have thought.</p>
<p>These are the steps to get started with Android development on Windows. Should work on any Windows version, but I&#8217;m using Windows 7 64-bit.</p>
<ol>
<li>Download and install Java SDK.</li>
<li>Download and unzip Android SDK.</li>
<li>Run &#8220;SDK Manager&#8221; from Android SDK to download the platform versions.</li>
<li>Download and unzip Eclipse.</li>
<li>Install the Android plugin for Eclipse and point to the Android SDK.</li>
</ol>
<p>You can read the instructions here, or watch a screencast I made describing the same procedure:</p>
<p><a href="http://vimeo.com/16392228">http://vimeo.com/16392228</a></p>
<h3>Download and install Java SDK</h3>
<p>You&#8217;ll find the Java SDK here:</p>
<p><a href="http://www.oracle.com/technetwork/java/javase/downloads/index.html">http://www.oracle.com/technetwork/java/javase/downloads/index.html</a></p>
<p>Click the &#8220;Download JDK&#8221; button and choose the Windows version you have from the Platform combobox. You don&#8217;t have to register to download. I ended up downloading a file called &#8220;jdk-6u22-windows-x64.exe&#8221;. Run it and accept all defaults to complete the installation.</p>
<h3>Download and unzip Android SDK</h3>
<p>The Android SDK doesn&#8217;t have an install executable, but rather a zip file and a utility called &#8220;SDK Manager.exe&#8221;. Begin by downloading the sdk from here:</p>
<p><a href="http://developer.android.com/sdk/index.html">http://developer.android.com/sdk/index.html</a></p>
<p>Unzip the file to any location you want. I put it in &#8220;C:\Android\SDK&#8221;. Inside that folder, you&#8217;ll find the executable &#8220;SDK Manager.exe&#8221;. Run it. Every time you run that application, it will look for updates to anything you&#8217;ve downloaded previously with the same tool. The first time it will default to download all platform versions of Android except the Google specific ones. I&#8217;d recommend selecting Cancel at this initial update dialog, and then download what you need from &#8220;Available packages&#8221; instead.</p>
<p>The Android platform has been released in several versions since its initial offering of version 1.0. Every Android application will require a specific version, but will of course work on all subsequent versions too (at least in a perfect world). Today, I recommend that you target version 2.1 as the least common denominator. But note that there might still be users and phones of at least version 1.6 that might be of interest to you. Anyway, this means that I would download version 2.1 and the latest version 2.2. They don&#8217;t really take up that much disk space (maybe ~100MB per version?), so it won&#8217;t hurt you too much to download them all either.</p>
<p>Also, every Android platform version comes in a &#8220;Android plain vanilla&#8221; variant and a &#8220;Google APIs&#8221; variant. The only differences between those two are that &#8220;Google APIs&#8221; variant will include the ability to use Google Maps component and some other Google specific APIs that some Android devices might not support. I found this naming to be a little strange at first, but note that &#8220;Google APIs&#8221; includes everything in &#8220;Android plain vanilla&#8221; too.</p>
<p>The point is that if your application doesn&#8217;t need things such as Google Map component, you will be targeting more devices if you choose to develop for &#8220;Android plain vanilla&#8221;. As far as I know, all commonly sold Android phones support the Google APIs and it is only simpler media players and maybe cheap tablets that might not have chosen to support Google APIs (since I assume the manufacturer pays licensing fees to Google for that).</p>
<h3>Run &#8220;SDK Manager&#8221; from Android SDK to download the platform versions</h3>
<p>So, running &#8220;SDK Manager&#8221;, cancelling on the first update dialog box, you&#8217;ll move on to &#8220;Available packages&#8221;. I recommend checking the following items and then click &#8220;Install selected&#8221;: (revision numbers can of course have changed since I wrote this)</p>
<ul>
<li>SDK Platform Android 2.2, API 8, revision 2</li>
<li>SDK Platform Android 2.1, API 7, revision 2</li>
<li>Samples for SDK API 8, revision 1</li>
<li>Google APIs by Google Inc., Android API 8, revision 2</li>
<li>Google APIs by Google Inc., Android API 7, revision 1</li>
<li>Usb Driver package, revision 3</li>
<li>Market Licensing package, revision 1</li>
</ul>
<p>You&#8217;ll need to &#8220;Accept all&#8221; licenses and then the download should start. You might get a question if it is ok to restart ADB at the end of the installation procedure, which it is!</p>
<h3>Download and unzip Eclipse</h3>
<p>You don&#8217;t have to use Eclipse. You could stop here and use a command line utility from the Android SDK to create project skeletons and edit the files with any text file editor. But I think you&#8217;ll enjoy the full development environment of Eclipse, even though it seems to have gotten its share of complaints over the years.</p>
<p>Download Eclipse from here:</p>
<p><a href="http://www.eclipse.org/downloads/">http://www.eclipse.org/downloads/</a></p>
<p>The first option of &#8220;Eclipse IDE for Java Developers&#8221; is what you want, and click the link to the right depending on what Windows version you&#8217;re on. I ended up downloading &#8220;eclipse-java-helios-SR1-win32-x86_64.zip&#8221;.</p>
<p>Eclipse doesn&#8217;t have an install at all. Just unzip the files into any folder you like and start the environment with &#8220;eclipse.exe&#8221;.</p>
<h3>Install the Android plugin for Eclipse and point to the Android SDK</h3>
<p>Inside Eclipse, you need to do a few things before you can create your first Android project. When you start Eclipse, you choose your &#8220;Workspace&#8221;. Just accept the default. This is the base folder where you will put all of your projects, and can of course be changed later on.</p>
<p>Now, do the following:</p>
<ol>
<li>Select Help menu</li>
<li>Install new software</li>
<li>Add</li>
<li>Type any Name, like &#8220;Android&#8221;</li>
<li>Paste this address in Location: https://dl-ssl.google.com/android/eclipse/</li>
<li>OK</li>
<li>After a few seconds, the list should contain &#8220;Developer Tools&#8221; and there you&#8217;ll find &#8220;Android DDMS&#8221; and &#8220;Android Development Tools&#8221;.</li>
<li>Select both and then Next</li>
<li>Continue with the download and install. You&#8217;ll be asked to restart Eclipse at the end. Do that.</li>
</ol>
<p>Back in Eclipse with the Android plugin now installed, you also need to:</p>
<ol>
<li>Select Window menu</li>
<li>Preferences</li>
<li>Android</li>
<li>Click Browse button next to &#8220;SDK Location&#8221;</li>
<li>Point to the folder where you unzipped the Android SDK previously. For me, that would be &#8220;C:\Android\SDK&#8221; (where the &#8220;SDK Manager.exe&#8221; is located)</li>
<li>OK</li>
<li>Apply</li>
<li>After a few seconds the list should fill with the Android platforms you chose to download with &#8220;SDK Manager&#8221; previously</li>
<li>OK</li>
</ol>
<p>That&#8217;s it!</p>
<h3>Create your first Android project</h3>
<p>Now you should be able to create your first Android project. Still in Eclipse:</p>
<ol>
<li>Select File menu</li>
<li>New</li>
<li>Project</li>
<li>Android, Android Project</li>
<li>Next</li>
<li>Project name: My first project</li>
<li>Build Target, Target Name: check any platform version you&#8217;d like to start with</li>
<li>Application name: MyFirstProject</li>
<li>Package name: com.myname.MyFirstProject</li>
<li>Create Activity: (checked) MainActivity</li>
<li>Min SDK Version: (can be left empty)</li>
<li>Next</li>
<li>Finish (no test project for your first attempt)</li>
</ol>
<p>Now, right-click the project name in the left pane and choose &#8220;Run as&#8221; and then &#8220;1 Android Application&#8221;. The emulator should start and after some time (it IS really slow to start), you&#8217;ll be running your first Android application. If the emulator starts, but not your application, just keep the emulator running and switch back to Eclipse and execute the &#8220;Run as&#8221; command again. Sometimes it fails on the first attempt.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mikeplate.com/2010/11/01/install-android-development-environment-on-windows-7/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>CSS3 Playground</title>
		<link>http://www.mikeplate.com/2010/07/28/css3-playground/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=css3-playground</link>
		<comments>http://www.mikeplate.com/2010/07/28/css3-playground/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 11:36:39 +0000</pubDate>
		<dc:creator>mikeplate</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[webapps]]></category>
		<category><![CDATA[webdesign]]></category>

		<guid isPermaLink="false">http://www.mikeplate.com/?p=322</guid>
		<description><![CDATA[After being excited about css3 and using some of its features in my web pages, I realized that I needed some simple tool (editor) for experimenting.]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://css3.mikeplate.com">CSS3 Playground</a> is a web application for experimenting with some new css3 capabilities. Primarily those than conform to the progressive enhancement philosophy, which means that the styles can be used on all sites without severely changing/limiting the experience on browsers that does not support them (=Internet Explorer 8.0 and older). But there are also styles that may need better replacements on Internet Explorer such as rotation, and I hope I will have the time to add more in the future.</p>
<p><span id="more-322"></span></p>
<p><a href="http://css3.mikeplate.com/"><img class="alignnone size-full wp-image-337 screendump" title="CSS3 Playground" src="http://www2.mikeplate.com/wp-content/uploads/2010/07/css3playground.png" alt="Screen dump of the site" width="547" height="395" /></a></p>
<h2>Inspiration</h2>
<p>I&#8217;m a developer and not a web designer, but that doesn&#8217;t keep me from learning and experimenting with html5 and css3 stuff. The inspiration for this web application came from some really good talks at <a href="http://futureofwebdesign.com/london-2010/">Future of Web Design in London 2010</a>. I wasn&#8217;t there, but purchased the recorded videos which I can recommend to all interested in web design (and web developers too, obviously). The recorded quality isn&#8217;t perhaps the best, but the speakers and the content made up for that. Especially <a href="http://simplebits.com/">Dan Cederholm</a> and <a href="http://denisejacobs.com/">Denise Jacobs</a>.</p>
<p>I wasn&#8217;t aware of the philosophies &#8220;Progressive enhancement&#8221; and/or &#8220;Graceful degradation&#8221; previously so this was a bit of a late awakening for me. Now I see what has been brewing in the web design and browser world for a while and why Microsoft finally was pushed to comply a lot better to all things css3 with Internet Explorer 9.</p>
<p>Then, of course, it&#8217;s another story that html5 and css3 are not standardized yet.</p>
<h2>Building</h2>
<p>Building this simple web application was also a good opportunity for me to really use a JavaScript user interface library since the application is client side only. I was choosing between <a href="http://jqueryui.com/">jQuery UI</a> and <a href="http://www.dojotoolkit.org/reference-guide/dijit/index.html">Dijit</a> (Dojo&#8217;s ui library) and what made to go for Dijit was the fact that the mouse scroll wheel can be used on slider controls. I thought that made a nice feature when moving shadows and testing other numbers based properties.</p>
<p>I have mostly looked at jQuery previously, but I will investigate <a href="http://dojotoolkit.org/">Dojo</a> even further now with the good experiences I&#8217;ve had buildning CSS3 Playground.</p>
<p>The best specification of all css3 properties and browser support that I&#8217;ve found is <a href="http://www.caniuse.com">Where can I use</a>. I used that specification and the linked samples and documentation to learn about the specifics of the css3 styles that I wanted to support in the web application.</p>
<h2>Use</h2>
<p>So I recommend you try it out. I hope it will be a better way to try out some color and shadow combinations than to type the css manually and use your ordinary tools and previews. It will of course be of most use to you who know css pretty well, but has not had the time to check out css3 yet.</p>
<p>Add more preview boxes with the <img class="alignnone" src="http://css3.mikeplate.com/add.png" alt="" width="16" height="16" /> button. When changing the styles, only the last box clicked will be affected. I didn&#8217;t want to distort the preview with a visual selection effect for the current box, so besides a small transparency animation when clicking other boxes, you won&#8217;t be able to see which box is actually the current one. Remove the current box with the <img class="alignnone" src="http://css3.mikeplate.com/delete.png" alt="" width="16" height="16" /> button.</p>
<p>Below the preview, you will see two collections of styles. The left one is the one you should use (copy and paste). It contains the styles for different browsers. The right one is read live from the browser of your choice and it might be interesting to see how different browsers actually chose to store the styles, but you should not copy and paste that part in your web pages and stylesheet files.</p>
<p>My favorite styles that I will start to use are the easy ones such as border radius and box shadow. Considering how easy they are, the difficulty will probably be not to overuse them.</p>
<p><a href="http://css3.mikeplate.com">http://css3.mikeplate.com</a></p>
<h2>Updates</h2>
<p>Web application was updated to version 1.1 on august 17 with the following:</p>
<ul>
<li>&#8220;Add&#8221;-button for adding as many boxes as you like and change their styles independently.</li>
<li>&#8220;Delete&#8221;-button for removing any extra added boxes.</li>
<li>Font selection. Either type the font(s) manually, or select from a few font stacks.</li>
<li>Bold and/or italic styles.</li>
<li>Bug fix where changing the contents removed the resizing capability.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.mikeplate.com/2010/07/28/css3-playground/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Served from: www.mikeplate.com @ 2012-02-06 04:27:55 -->
