Skip to content

Instantly share code, notes, and snippets.

@panmari
panmari / Laufzeitanalse
Created May 29, 2012 21:56
Some examples for determining the average performance of algorithms
1.
from i:= 1 until i > n loop
from j:= 1 until j > i loop
j:= j+1
end
i := i*2
end
2.
from i:= 1 until i > n loop
@panmari
panmari / mastermind
Created July 2, 2012 11:39
mastermind for android
// MasterMind.java
package app.mastermind1;
import ch.aplu.android.*;
import android.graphics.*;
import java.util.ArrayList;
// -----------class ActiveRowMarker -----------
@panmari
panmari / gist:3060436
Created July 6, 2012 14:21
setPixelLocation buggy?
public void act() {
xVelocity += FACTOR*gg.getXSlope();
yVelocity += FACTOR*gg.getYSlope();
xPos += xVelocity;
yPos += yVelocity;
setPixelLocation(new Point(Math.round(xPos), Math.round(yPos)));
L.d(isInGrid() + " " + getLocation());
if (!isInGrid())
gg.gameOver();
}
@panmari
panmari / gist:3083103
Created July 10, 2012 13:00
disable touch with only one thread
public void flipCardsBack() {
setTouchEnabled(false); // Disable mouse events
delay(1000);
card1.show(1); // Flip cards back
card2.show(1);
refresh();
setTouchEnabled(true);
}
@panmari
panmari / Cardex12.java
Created August 14, 2012 12:41
Touch is not automatically enabled, when a TouchListener is added
package ch.aplu.cardex12;
import android.graphics.Color;
import ch.aplu.jcardgame.*;
import ch.aplu.android.*;
public class CardEx12 extends CardGame
{
public enum Suit {
KREUZ, HERZ, KARO, PIK
@panmari
panmari / CardEx12.java
Created August 14, 2012 13:05
Constructor for Hands with CardLayout as parameter is buggy
package ch.aplu.cardex12;
import android.graphics.Color;
import ch.aplu.jcardgame.*;
import ch.aplu.android.*;
public class CardEx12 extends CardGame
{
public enum Suit {
KREUZ, HERZ, KARO, PIK
@panmari
panmari / CardEx12.java
Created August 14, 2012 13:08
setView ignores Layout other than StackLayout?
package ch.aplu.cardex12;
import android.graphics.Color;
import ch.aplu.jcardgame.*;
import ch.aplu.android.*;
public class CardEx12 extends CardGame
{
public enum Suit {
KREUZ, HERZ, KARO, PIK
@panmari
panmari / TestBorder.java
Created August 23, 2012 09:43
isNearBorder() doesn't work as expected when using windowZoom
package online.app2;
import ch.aplu.android.*;
import android.graphics.Color;
public class TestBorder extends GameGrid
{
public TestBorder()
{
super(true, windowZoom(200));
@panmari
panmari / Tu16.java
Created September 25, 2012 12:32
Many Turtles & Arc => flickering
// Tu16java
package app.tu16;
import turtle.*;
public class Tu16 extends Playground
{
public void playgroundPressed(double x, double y)
{
@panmari
panmari / elastic_search_parallel
Created August 28, 2013 09:14
Starting two queries to the elasticsearch server through the Tire gem. Even though the long, complicated query starts before the short one, the short one is returned first.
# try this in a rails environment, that has the Indexing module loaded. (medcode, orangeproton)
search_queries = ["Ein sehr komplizierter query, der sehr lange zum ausfuhren braucht", "kurz"] # !sic
threads = []
search_queries.each do |string|
threads << Thread.new(string) do |query|
puts "started #{query}"
Indexing.elastic_find_all(string, 'icd', '2012', 'ch', 'de')
puts "finished #{query}"
end