sudo apt-get install --reinstall bcmwl-kernel-sourceHope that helps. It works for me now.
Showing posts with label tips. Show all posts
Showing posts with label tips. Show all posts
Wednesday, April 28, 2010
Ubuntu 9.10: Wifi connection fix
You have trouble connecting to the wireless network on UBuntu 9.10 try this
Sunday, March 28, 2010
Cascading: How does cascading decides which fields should go to a column family?
I was playing with Cascading code sample as given here.
Problem Statement: let's say we have three fields in a tuple for e.g.
and I wish to add double to its own column family or lets say club it with an existing column family 'right' How do I do that.
Problem Statement: let's say we have three fields in a tuple for e.g.
line_num, lower, upper, double
1, a, A, AA
and I wish to add double to its own column family or lets say club it with an existing column family 'right' How do I do that.
Solution:
String tableName = "DataLoadTable";
Fields keyFields = new Fields("line_num");// add a new family name
String[] familyNames = new String[] { "left", "right", "double" };// group your fields together in the order in which you would like them to be// added to column families
Fields[] valueFields = new Fields[] { new Fields("lower"),
new Fields("upper"), new Fields("double") };
HBaseScheme hbaseScheme = new HBaseScheme(keyFields, familyNames,
valueFields);
Tap sink = new HBaseTap(tableName, hbaseScheme, SinkMode.REPLACE);// describe your tuple entry: add the new field
Fields fieldDeclaration = new Fields("line_num", "lower", "upper",
"double");
Function function = new RegexSplitter(fieldDeclaration, ", ");
The remaining of the code remains the same as given in the example.
Either, the above was too obvious that the authors didn't talked about it in the user guide or I do not know how to describe the problem and hence was not able to find them.
Let me know if I'm wrong.
Thursday, February 4, 2010
Running Java in debug mode using Apache Ant
Configure your Java task as given below;
Further, configure your eclipse debug remote application to listen to the specified port (8999 in this case).
Also, add Thread.sleep(1000); as the first line in your main method.
Execute Java task and try connecting from eclipse, you may need to increase the thread sleep time.
<java classname="org.zero.Main" fork="true" failonerror="true">
<sysproperty key="DEBUG" value="true" />
<jvmarg value="-Xdebug" />
<jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8999" />
<jvmarg value="-Xnoagent" />
<jvmarg value="-Djava.compiler=none" />
<arg value="${project.root}/conf/preferences.xml" />
<classpath refid="project.classpath" />
</java>
Further, configure your eclipse debug remote application to listen to the specified port (8999 in this case).
Also, add Thread.sleep(1000); as the first line in your main method.
Execute Java task and try connecting from eclipse, you may need to increase the thread sleep time.
Friday, February 20, 2009
Tip: Sort a map by values
A handy tip to sort map by values.
//:~
package samples.core.java;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
public class SortMapByValueExample {
public static void main(String[] args) {
Map map = new TreeMap();
map.put("1", "100");
map.put("10", "50");
map.put("100", "40");
map.put("1000", "10000");
List keys = new ArrayList(map.keySet());
ByValueComparator bvc = new SortMapByValueExample().new ByValueComparator(
map);
Collections.sort(keys, bvc);
Iterator iterator = keys.iterator();
while (iterator.hasNext()) {
String key = (String) iterator.next();
System.out.println(key + "-" + map.get(key));
}
}
private class ByValueComparator implements Comparator {
private Map map;
public ByValueComparator(Map map) {
this.map = map;
}
public int compare(Object o1, Object o2) {
int integer = Integer.parseInt((String) this.map.get((String) o1));
int otherInteger = Integer.parseInt((String) this.map
.get((String) o2));
return -1
* (new Integer(integer)
.compareTo(new Integer(otherInteger)));
}
}
}
Subscribe to:
Posts (Atom)