This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyMapActivity extends MapActivity | |
implements OnGestureListener { | |
... | |
private GestureDetector gestureDetector; | |
@Override |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ShowMapActivity extends MapActivity { | |
... | |
private long touchActionDownStartTime; | |
private float histX; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HackUtils { | |
public static void setListViewHeightBasedOnChildren(ListView listView) { | |
ListAdapter listAdapter = listView.getAdapter(); | |
if (listAdapter == null) { | |
// pre-condition | |
return; | |
} | |
int totalHeight = 0; | |
for (int i = 0; i < listAdapter.getCount(); i++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Implicit | |
import scala.collection.JavaConverters._ | |
// For method: | |
def doSomething(things: List[Thing]): List[Result] = { ... } | |
// add the same method with another signature: | |
def doSomething(things: java.util.List[Thing]): java.util.List[Result] = | |
doSomething(things.asScala.toList).asJava |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> val s = "Me Moscow 2012" | |
s: String = some text 2012 | |
scala> val PersonLocation = """(.+) (.+) (.+)""".r | |
PersonLocation: scala.util.matching.Regex = (.+) (.+) (.+) | |
scala> val PersonLocation(person, city, year) = s | |
person: String = Me | |
city: String = Moscow | |
year: String = 2012 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Here are a few alternatives you might wish to consider: | |
1. Use a view bound | |
If it's possible to change the function that takes a List of Bs, this would be the simplest solution. Modify it to accept a List of things that can be converted to Bs. That is, | |
def myfun(l: List[B]) = ... | |
would become | |
def myfun[X <% B](l: List[X]) = ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Mongo shell command | |
> db.users.update( | |
{ community:'Coomunity1', | |
'users.login': {'$ne': 'Login1'} | |
}, | |
{ $push: | |
{ users: {login:'Login1', pwd:'*****'} } | |
}, | |
{upsert: true}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object UserDaoImpl { | |
object Implicits { | |
implicit object AccountWriter extends BSONDocumentWriter[Account] { | |
def write(acc: Account) = BSONDocument( | |
"email" -> acc.email) | |
} | |
implicit object AccountReader extends BSONDocumentReader[Account] { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
akka { | |
actor { | |
provider = "akka.remote.RemoteActorRefProvider" | |
serialize-messages = on | |
serializers { | |
proto = "akka.remote.serialization.ProtobufSerializer" | |
} | |
serialization-bindings { | |
"scala.collection.immutable.List" = proto |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyPipelineFactory implements ChannelPipelineFactory { | |
private final Timer timer; | |
private final ChannelHandler timeoutHandler; | |
public MyPipelineFactory(Timer timer) { | |
this.timer = timer; | |
this.timeoutHandler = new ReadTimeoutHandler(timer, 30), // timer must be shared. | |
} |
OlderNewer