Skip to content

Instantly share code, notes, and snippets.

View semanticer's full-sized avatar

Tomáš Valenta semanticer

View GitHub Profile
public class CityInfoContentItem {
private int type;
// type header - 0
private String headerText;
// type phrase - 1
private String extraInfo;
private String phrase;
object MockMiniMax {
def mockEval(state: MockState): Int = state match {
case MockState(List(false,false,false,false)) => 8
case MockState(List(true,false,false,false)) => 7
case MockState(List(false,true,false,false)) => 3
case MockState(List(true,true,false,false)) => 9
case MockState(List(false,false,true,false)) => 9
case MockState(List(true,false,true,false)) => 8
case MockState(List(false,true,true,false)) => 2
----- pid 1479 at 2016-05-31 15:27:30 -----
Cmd line: com.android.phone
Build fingerprint: 'google/razor/flo:6.0.1/MOB30J/2775141:user/release-keys'
ABI: 'arm'
Build type: optimized
Zygote loaded classes=3978 post zygote classes=394
Intern table: 45424 strong; 33 weak
JNI: CheckJNI is off; globals=352 (plus 362 weak)
Libraries: /system/lib/libandroid.so /system/lib/libcompiler_rt.so /system/lib/libjavacrypto.so /system/lib/libjnigraphics.so /system/lib/libmedia_jni.so /system/lib/libwebviewchromium_loader.so libjavacore.so (7)
Heap: 5% free, 12MB/13MB; 137224 objects
@semanticer
semanticer / File.java
Created April 8, 2016 14:17 — forked from dlew/File.java
Automated onError() message generation
public static Action1<Throwable> crashOnError() {
final Throwable checkpoint = new Throwable();
return throwable -> {
StackTraceElement[] stackTrace = checkpoint.getStackTrace();
StackTraceElement element = stackTrace[1]; // First element after `crashOnError()`
String msg = String.format("onError() crash from subscribe() in %s.%s(%s:%s)",
element.getClassName(),
element.getMethodName(),
element.getFileName(),
element.getLineNumber());
trait Exp {
def eval: Int
}
case class Oper(op: (Int, Int) => Int, left: Exp, right: Exp) extends Exp {
override def eval: Int = op(left.eval, right.eval)
}
case class Num(value: Int) extends Exp {
override def eval: Int = value
@semanticer
semanticer / Poker Hand Builder
Created March 10, 2016 08:32
Basic example of builder for poker hand
public class Hand {
public final Card firstCard;
public final Card secondCard;
public Hand(Card firstCard, Card secondCard) {
this.firstCard = firstCard;
this.secondCard = secondCard;
}
}
-- print given tree
main = putStrLn (treeToSring (tree 4 2 3))
-- concatenate string from tree list structure
treeToSring treeList = intercalate "" [ unlines block | block <- treeList]
-- creates tree in list structure
tree bc gf fbs = [block rows (treeMaxSp bc gf fbs) | rows <- take bc [fbs,(fbs+gf)..]]
-- counts maximal number of spaces for given tree
treeMaxSp bc gf fbs = ((bc-1)*gf)+(fbs-1)
-- creates one block with specified number of rows and maximal space
block rowCount maxSp = [row st sp | (st,sp) <- take rowCount (zip [1,3..] [maxSp,maxSp-1..0])]
-- creates one row with specified number of stars and spaces