2009年9月29日 星期二
Config the GuestOS's resolution in the VMware
To automatically fit the host os's resolution at full screen mode:
the vxm file to add the entries:
svga.maxWidth = "1280"
svga.maxHeight = "800"
2009年9月28日 星期一
Sorting maps in Java based on it’s values
public class MapValueSort {
/** inner class to do soring of the map **/
private static class ValueComparer implements Comparator {
private Map _data = null;
public ValueComparer (Map data){
super();
_data = data;
}
public int compare(Object o1, Object o2) {
String e1 = (String) _data.get(o1);
String e2 = (String) _data.get(o2);
return e1.compareTo(e2);
}
}
public static void main(String[] args){
Map unsortedData = new HashMap();
unsortedData.put("2", "DEF");
unsortedData.put("1", "ABC");
unsortedData.put("4", "ZXY");
unsortedData.put("3", "BCD");
SortedMap sortedData = new TreeMap(new MapValueSort.ValueComparer(unsortedData));
printMap(unsortedData);
sortedData.putAll(unsortedData);
System.out.println();
printMap(sortedData);
}
private static void printMap(Map data) {
for (Iterator iter = data.keySet().iterator(); iter.hasNext();) {
String key = (String) iter.next();
System.out.println("Value/key:"+data.get(key)+"/"+key);
}
}
} This should output something of the lines of:
Value/key:BCD/3
Value/key:DEF/2
Value/key:ZXY/4
Value/key:ABC/1
Value/key:ABC/1
Value/key:BCD/3
Value/key:DEF/2
Value/key:ZXY/4
Where the bottom last four lines obviously is sorted on the map’s values and not it’s keys.
Ref: http://paaloliver.wordpress.com/2006/01/24/sorting-maps-in-java/ by paaloliver
jQuery Floating Layer Plugin
It can fix one layer(div) at the fixed position on the page.
https://nettuts.s3.amazonaws.com/018_Floating_Menu/demo/dhtml_float_menu_final_nettut.html
http://www.phpletter.com/Demo/Jquery-Floating-Box-Plugin/
2009年9月23日 星期三
C# 中的Map: Dictionary 的使用
We can use the statement, DicObj[keyObj] = valObject, to set/get the value corresponding to the key.
using System;
using System.Collections.Generic;
public class Example
{
public static void Main()
{
// Create a new dictionary of strings, with string keys.
//
Dictionary<string, string> openWith =
new Dictionary<string, string>();
// Add some elements to the dictionary. There are no
// duplicate keys, but some of the values are duplicates.
openWith.Add("txt", "notepad.exe");
openWith.Add("bmp", "paint.exe");
openWith.Add("dib", "paint.exe");
openWith.Add("rtf", "wordpad.exe");
// The Add method throws an exception if the new key is
// already in the dictionary.
try
{
openWith.Add("txt", "winword.exe");
}
catch (ArgumentException)
{
Console.WriteLine("An element with Key = \"txt\" already exists.");
}
// The Item property is another name for the indexer, so you
// can omit its name when accessing elements.
Console.WriteLine("For key = \"rtf\", value = {0}.",
openWith["rtf"]);
// The indexer can be used to change the value associated
// with a key.
openWith["rtf"] = "winword.exe";
Console.WriteLine("For key = \"rtf\", value = {0}.",
openWith["rtf"]);
// If a key does not exist, setting the indexer for that key
// adds a new key/value pair.
openWith["doc"] = "winword.exe";
// The indexer throws an exception if the requested key is
// not in the dictionary.
try
{
Console.WriteLine("For key = \"tif\", value = {0}.",
openWith["tif"]);
}
catch (KeyNotFoundException)
{
Console.WriteLine("Key = \"tif\" is not found.");
}
// When a program often has to try keys that turn out not to
// be in the dictionary, TryGetValue can be a more efficient
// way to retrieve values.
string value = "";
if (openWith.TryGetValue("tif", out value))
{
Console.WriteLine("For key = \"tif\", value = {0}.", value);
}
else
{
Console.WriteLine("Key = \"tif\" is not found.");
}
// ContainsKey can be used to test keys before inserting
// them.
if (!openWith.ContainsKey("ht"))
{
openWith.Add("ht", "hypertrm.exe");
Console.WriteLine("Value added for key = \"ht\": {0}",
openWith["ht"]);
}
// When you use foreach to enumerate dictionary elements,
// the elements are retrieved as KeyValuePair objects.
Console.WriteLine();
foreach( KeyValuePair<string, string> kvp in openWith )
{
Console.WriteLine("Key = {0}, Value = {1}",
kvp.Key, kvp.Value);
}
// To get the values alone, use the Values property.
Dictionary<string, string>.ValueCollection valueColl =
openWith.Values;
// The elements of the ValueCollection are strongly typed
// with the type that was specified for dictionary values.
Console.WriteLine();
foreach( string s in valueColl )
{
Console.WriteLine("Value = {0}", s);
}
// To get the keys alone, use the Keys property.
Dictionary<string, string>.KeyCollection keyColl =
openWith.Keys;
// The elements of the KeyCollection are strongly typed
// with the type that was specified for dictionary keys.
Console.WriteLine();
foreach( string s in keyColl )
{
Console.WriteLine("Key = {0}", s);
}
// Use the Remove method to remove a key/value pair.
Console.WriteLine("\nRemove(\"doc\")");
openWith.Remove("doc");
if (!openWith.ContainsKey("doc"))
{
Console.WriteLine("Key \"doc\" is not found.");
}
}
}
/* This code example produces the following output:
An element with Key = "txt" already exists.
For key = "rtf", value = wordpad.exe.
For key = "rtf", value = winword.exe.
Key = "tif" is not found.
Key = "tif" is not found.
Value added for key = "ht": hypertrm.exe
Key = txt, Value = notepad.exe
Key = bmp, Value = paint.exe
Key = dib, Value = paint.exe
Key = rtf, Value = winword.exe
Key = doc, Value = winword.exe
Key = ht, Value = hypertrm.exe
Value = notepad.exe
Value = paint.exe
Value = paint.exe
Value = winword.exe
Value = winword.exe
Value = hypertrm.exe
Key = txt
Key = bmp
Key = dib
Key = rtf
Key = doc
Key = ht
Remove("doc")
Key "doc" is not found.
*/
2009年9月8日 星期二
Barcode Image Generation Library
It's the best solution without font supporting and free.
Using the ashx, we can take various methods to generate / draw the barcode bitmap.
In this library, barcode is drawed as thin line.
In the other library, Code39, barcode is drawed as a little fat hence it's blurred while we print it out.
2009年9月4日 星期五
Google Map Cursor
Cursor styles
http://www.worldtimzone.com/mozilla/testcase/css3cursors.htmlSupported Browser:
http://www.quirksmode.org/css/cursor.htmlusage: {cursor: url(../images/openhand.cur), move;}
http://www.google.com/intl/zh-CN_ALL/mapfiles/openhand.cur
http://www.google.com/intl/zh-CN_ALL/mapfiles/closedhand.cur
訂閱:
文章 (Atom)
網誌存檔
-
▼
2009
(42)
-
▼
9月
(13)
- Config the GuestOS's resolution in the VMware
- Sorting maps in Java based on it’s values
- jQuery Floating Layer Plugin
- C# 中的Map: Dictionary 的使用
- Barcode Image Generation Library
- Code 39 barcodes in C#
- An ASP.NET .ashx HTTP handler for Code 39 barcode ...
- http://www.codeproject.com/KB/aspnet/AspBarCodes.aspx
- Barcodes in ASP.NET applications
- Advanced Barcode Generation System for Code 39 Sta...
- jQuery Time Entry
- jQuery Timers
- Google Map Cursor
-
▼
9月
(13)