Skip to content

Instantly share code, notes, and snippets.

Avatar

Tomáš Valenta semanticer

View GitHub Profile
View CityInfoContentItem
public class CityInfoContentItem {
private int type;
// type header - 0
private String headerText;
// type phrase - 1
private String extraInfo;
private String phrase;
View Example mock states of minimax
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
View ARN
----- 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 Apr 8, 2016 — forked from dlew/File.java
Automated onError() message generation
View File.java
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());
View Example Expression Evaluator
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 Mar 10, 2016
Basic example of builder for poker hand
View Poker Hand Builder
public class Hand {
public final Card firstCard;
public final Card secondCard;
public Hand(Card firstCard, Card secondCard) {
this.firstCard = firstCard;
this.secondCard = secondCard;
}
}
View Christmas Tree Output
-- print given tree
main = putStrLn (treeToSring (tree 4 2 3))
-- concatenate string from tree list structure
treeToSring treeList = intercalate "" [ unlines block | block <- treeList]
View Christmas Tree Core Functions
-- 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