- In Android Virtual Device Manager create an AVD with target "Android 2.3.3 - API Level 10" emulator -avd name_of_avd
- adb pull /system/etc/permissions/com.google.android.maps.xml
- adb pull /system/framework/com.google.android.maps.jar
- (optional) Remove the create AVD in Android Virtual Device Manager
- In Android Virtual Device Manager create an AVD with target "Intel Atom x86 system Image (Intel Corporation) - API Level 10"
- emulator -avd name_of_avd
- adb remount rw
- adb push com.google.android.maps.xml /system/etc/permissions
- adb push com.google.android.maps.jar /system/framework
- Download mkfs.yaffs2.x86
- adb push mkfs.yaffs2.x86 /data
- adb shell
- cd /data
- chmod 777 mkfs.yaffs2.x86
- ./mkfs.yaffs2.x86 /system system.img
- exit
- adb pull /data/system.img (...be patient)
- Copy system.img into avd directory
- Reboot emulator
неделя, 20 май 2012 г.
How to use Google Maps API in Android emulator SDK version 17
понеделник, 31 май 2010 г.
How to Set Up PuTTY SSH Keys
1. Start up PuTTYgen.exe. The defaults of SSH-2 RSA and 1024 bit key should be fine.
2. Click Generate to make the key (moving mouse randomly over blank area).
3. Fill in the comment (me at example.com). Enter a passphrase. A passphrase is more secure, but you'll be prompted for it on every access (unless you use keychain or others).
4. Use PuTTYGen's button to save the public key on your PC (ex. c:\putty\keys\me-at-example.txt).
5. Use button to save the private key. You must use .ppk extension (ex. c:\putty\keys\me-at-example.ppk).
6. Copy the public key from the PuTTYGen text box and place it in ~/.ssh/authorized_keys2. This authorized key file must have 600 permissions. Paste it all in one line.
7. Attach the private key to the PuTTY profile by going to Connection -> SSH -> Auth in PuTTY. Use the Browse button to navigate to the .ppk private key you just made.
8. Enter your username into the PuTTY connection at Connection -> Login Details.
9. Save your PuTTY connection. Now you can open that PuTTY connection and be logged directly into the computer (you must supply a passphrase if you used one).
Details on this procedure can be found here :
If you need to troubleshoot the connection, you can use PuTTY's plink.exe with the -v option to see what's going on :
C:\putty>plink -v -i keys\me-at-example-pvt.ppk me@192.168.1.1
Looking up host "192.168.1.1"
Connecting to 192.168.1.1 port 22
Server version: SSH-2.0-OpenSSH_3.9p1
We claim version: SSH-2.0-PuTTY_Release_0.60
Using SSH protocol version 2
Doing Diffie-Hellman group exchange
Doing Diffie-Hellman key exchange with hash SHA-1
Host key fingerprint is:
ssh-rsa 1024 f1:df:5b:8d:56:d8:73:90:5c:fe:b2:a8:16:f1:30:d7
Initialised AES-256 CBC client->server encryption
Initialised HMAC-SHA1 client->server MAC algorithm
Initialised AES-256 CBC server->client encryption
Initialised HMAC-SHA1 server->client MAC algorithm
Reading private key file "keys\me-at-example-pvt.ppk"
Using username "me".
Offered public key
Offer of public key accepted
Authenticating with public key "me-at-example-2009-06-15"
Access granted
Opened channel for session
Allocated pty (ospeed 38400bps, ispeed 38400bps)
Started a shell/command
$
сряда, 28 май 2008 г.
jQuery Equal Columns Plugin
/**
*
* Copyright (c) 2007 Tom Deater (http://www.tomdeater.com)
* Licensed under the MIT License:
* http://www.opensource.org/licenses/mit-license.php
*
*/
(function($) {
/**
* equalizes the heights of all elements in a jQuery collection
* thanks to John Resig for optimizing this!
* usage: $("#col1, #col2, #col3").equalizeCols();
*/
$.fn.equalizeCols = function(){
var height = 0;
return this
.css("height", "auto")
.each(function() {
height = Math.max(height, this.offsetHeight);
})
.css("height", height)
.each(function() {
var h = this.offsetHeight;
if (h > height) {
$(this).css("height", height - (h - height));
};
});
};
})(jQuery);
вторник, 27 май 2008 г.
Preloading Content With jQuery
Preloading Images
For some time there has been a snippet of code floating around the Internet that provides image preloading. To use it add the following function to your site (usually in a separate javascript file):
jQuery.preloadImages = function()
{
for(var i = 0; i < arguments.length; i++)
{
jQuery("<img>").attr("src", arguments[i]);
}
}
To take advantage of this plugin use it in a form like:
$.preloadImages("image1.gif", "/path/to/image2.png", "some/image3.jpg");
Each argument to the function in this comma separated list should be a url to an image to load. It's that easy.
Preloading Content
Let's take this a step further. What if you received some content via AHAH and want to preload the media in that content before presenting it? This is a common use case for images. If this is your case here is a little trick that works. It's a modification of the code above.
First, the plugin code:
jQuery.preloadContent = function(){
for(var i = 0; i < arguments.length; i++)
{
jQuery("<div>").html(arguments[i]);
}
}
Notice the change in the code here? Instead of placing an image path as an src element on an image tag we are taking the content and placing it as html on a div. This will preload the content and, just like with the image plugin, the content will not display at this point.
To use the code do something like:
$.preloadContent(myvar1, myvar2);
In these cases myvar1 and myvar2 are javascript variables that contain the html that needs to be preloaded.
After preloading your content will be cached in the browser and right at your fingertips to use.
четвъртък, 15 май 2008 г.
How to submit multiple form elements having the same name in PHP
<input name="hoho[]" value="first element" type="text">
<input name="hoho[]" value="second element" type="text">
<input name="hoho[]" value="third element" type="text">
At the processing PHP, the values of the submitted element can be retrieved as an array via:
$myarray = $_POST['hoho']; // Note that the name does not end with "[]" when retrieving
echo $myarray[0];
echo $myarray[1];
echo $myarray[2];
неделя, 11 май 2008 г.
(Re)Introducing Javascript And Hidden Applets (JAHA)
Java applets are so late 90's and so web 1.0, so what place do that have (if any) in the web 2.0 craze?
You can fairly easily today create an attractive web page using (X)HTML and CSS, but the moment you throw a Java applet into the mix you are asking for trouble. There is a jarring disconnect between the design of your page and the design of your applet. This has never been truer that today, where rounded corners, gradients and fake reflections are all the web 2.0 rage.
The standard look and feel for an applet is driven primarily by the AWT and Swing toolkits and let's face it, they're damn ugly. I don't know of anybody who has praised Java for it's beautiful UIs (those people may exist, but then again there is always people on the net with strange fetishes). It is possible using customised widgets to create applets with the same look and feel as a modern web page, but unless you implement some sort of CSS parser in your applet (let's not go there) any changes to your design will result in a duplicated effort within your applet. With an applet that is heavily tailored to the look and feel of your site, your applet's re-usability on other sites is basically nil. An option that seams to have been overlooked is hidden Java applets. A hidden Java applet is an applet that provides no user interface (UI) and is not visible on the web page. Without a UI the applet no longer creates a blemish on your page, is no longer affected by changes to your page's design and is portable between sites. Interaction with a hidden applet is possible using Javascript and LiveConnect. LiveConnect provides a bridge to access Java from within Javascript and visa-versa. This means you can create your page in normal (X)HTML and CSS, add logic within a hidden applet and use Javascript to capture events to invoke methods on the applet.
The addition of hidden applets to your site allows to provide client side functionality that may not be possible or feasible to implement in Javascript. You may simply want to re-uses an existing library rather than re-implement it in Javascript or you may need more complex IO than is allowed by Javascript. For instance, you may want a page that displays live updating stock prices. Using AJAX you would need to periodically poll the server for updates. Using a hidden applet, you could have an open connection to the server, which it would send updates to as they occur. The applet would simply block on the socket waiting for data and update the page via LiveConnect and Javascript when data was received. Another example would be an applet for uploading a file (such as infomentum's File Upload applet) that additionally (say for performance reasons) compresses the file before it uploads it. Such functionality would very difficult (if not impossible) to implement via Javascript.
Hidden applets are nothing new, but once again we find that an existing technique (combining Javascript and hidden applets) is lacking a name, something that developers can use to know immediately what they talking about. So, in the vain of AJAX and Comet, and similarly lacking a better term, I would like to name the combination of Javascript And Hidden Applets JAHA.
How it's done
- IE 6.0
- Firefox 1.5.0.6
- Opera 9.01
- If an applet is hidden by using the CSS "display: none;" then it's init and start methods will not be called in Firefox, IE and Opera. Using "width: 0; height: 0;" to hide the applet causes the init and start methods not to be called in IE.
- If you use Javascript to set the style of the applet to "display: none;" then it's stop and destroy methods will be called in Firefox and Opera. Setting "width: 0; height: 0;" will hide the applet in Firefox, IE and Opera and the stop and destroy methods not to be called.
- The applet tag has been deprecated in favour of the object tag, yet creating an applet via the object tag quite different in IE compared to other browsers.
- Creating an applet dynamically by using Javascript to insert an applet element into the DOM, works in IE but not Firefox or Opera.
- Creating an applet dynamically by using Javascript to insert an object element into the DOM, works in Firefox but not IE or Opera.
- Adding an applet dynamically using Javascript and document.write apparently works (I didn't bother testing that technique as I don't see much benefit compared to just using the appropriate (X)HTML in your document).
<applet id="applet_name" code="path_to_applet_class/class_name" style="width: 1px; height: 1px; float: left;" mayscript> </applet>
Attribute |
Description
|
id
|
A normal element ID.
|
code
|
The location and class name of your applet (do not use a .class or .java suffix)
|
style
|
Used to make the applet initially as discreet as possible (we'll make it less visible later)
|
mayscript
|
Allows the applet to call out to Javascript.
|
The equivalent in XHTML is a mess.Sun actually recommends using the applet tag despite it being deprecated and you can see why with the following mess:
<!--[if !IE]> <object id="applet_name" classid="java:path_to_applet_class/class_name.class" type="application/x-java-applet" style="width: 0px; height: 0px; float: left;"> <param name="mayscript" value="true"/> <![endif]–-> <object id="ie_applet_name" classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" codebase="http://java.sun.com/update/1.5.0/jinstall-1_5_0-windows-i586.cab" style="width: 1px; height: 1px; float: left;"> <param name="code" value="path_to_applet_class/class_name" /> <param name="mayscript" value="true" /> <param name="id" value="ie_applet_name" /> </object> <!–-[if !IE]> </object> <![endif]–->The XHTML 2.0 Working Draft is a lot more specific about how the object tag should be used, so hopefully this issue will disappear in the future though I'm not holding my breath.
In Firefox and Opera the attributes have the following meaning:
Attribute |
Description
|
id
|
A normal element ID.
|
classid
|
The location and class name of your applet, prefixed with java: and including the .class suffix
|
style
|
Used to hide the applet
|
type
|
Tells the browser that the object is a java applet.
|
Attribute |
Description
|
id
|
A normal element ID. To be valid XHTML, this has to be different from the ID used in the outer object.
|
classid
|
WTF? Apparently the value above tells IE to use the latest version of the Java plugin. Obviously.
|
codebase
|
Tells IE where to find the Java plugin if it is not currently installed.
|
style
|
Used to make the applet initially as discreet as possible (we'll hide it properly later)
|
The parameters have the following meaning:
Parameter |
Description
|
mayscript
|
Allows the applet to call out to Javascript
|
code
|
The location and class name of your applet (do not use a .class or .java suffix)
|
id
|
Allows applet running under IE to access the ID of the applet with getParameter("id"). Firefox and Opera automatically pass the ID to the applet as a parameter.
|
Accessing the Applet from Javascript
var your_applet = null;
function appletLoaded(applet) { your_applet = applet; … }and in your applet I have something like:
public void start() { Object[] args = { this }; JSObject.getWindow(this).call("appletLoaded", args ); }Not only does this make it easier for you to access your applet (no branching logic in your Javascript), it also guarantees that within appletLoaded or if your_applet != null your applet has been initialised; i.e. it's safe to call it's methods.
From within a Java, the simplest way to communicate with Javascript is via your methods' return values. While this may be sufficient for simple cases, more complex behaviour is available via the netscape.javascript.JSObject class. This class allows you to execute Javascript via:
netscape.javascript.JSObject.call(String jsfuncname, Object[] args);
netscape.javascript.JSObject.eval(String js);
var your_applet = null;
function appletLoaded( applet ) { your_applet = applet; document.getElementById( your_applet.getParameter("id") ).style.width='0'; document.getElementById( your_applet.getParameter("id") ).style.height='0'; … }