Skip to content

Instantly share code, notes, and snippets.

@salzig
salzig / Application.java
Created July 6, 2011 17:43
HAW - PRP2 - WS10 - Example Solution
package ws10;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class Application {
@salzig
salzig / Pruefung.java
Created July 7, 2011 11:36
Exampleexam 2011
package klausur;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class Pruefung {
@salzig
salzig / Permutation.java
Created October 11, 2011 08:53
Permutation
import java.util.ArrayList;
public interface Permutation extends Iterable<Integer>{
// Build a new Permutation by composition of this and other
public Permutation compose(Permutation other);
// Get element of Permutation at index
public Integer sigma(Integer index);
@salzig
salzig / Test.java
Created October 21, 2011 11:54
Rekursive Summe von Array Elementen
import java.util.Arrays;
import java.util.List;
public class Test {
/**
* @author Ben Rexin <benjamin.rexin@haw-hamburg.de
*/
public static void main(String[] args) {
List<Integer> array = Arrays.asList(1,2,3,4);
System.out.println(sum(array));
}
@salzig
salzig / Prozesse.md
Created March 6, 2012 19:46
Betriebssysteme

Prozess - das laufende Programm

Programm

Erzeugung

  • unix: fork, execve
  • windows:CreateProcess

Beenden

  • unix: exit / kill
  • windows: ExitProcess / TerminateProcess
@salzig
salzig / aufgabe2.scala
Created April 3, 2012 13:59
HAW WP 2012 Scala - Aufgabe 2
package aufgabe2
object App {
def sort[T <% Ordered[T]](arg1:T, arg2:T, args:T*) = (arg1 +: arg2 +: args).sortWith(_<_)
case class PointI(x:Int, y:Int) extends Ordered[PointI] {
def compare(that:PointI):Int = x compare that.x match {
case i if i == 0 => y compare that.y
case i => i
}
@salzig
salzig / gist:2428625
Created April 20, 2012 13:37
Stacktrace
$ gem install ffi -v '0.6.3'
Building native extensions. This could take a while...
ERROR: Error installing ffi:
ERROR: Failed to build gem native extension.
/Users/ben/.rvm/rubies/ruby-1.9.3-p125/bin/ruby extconf.rb
extconf.rb:6: Use RbConfig instead of obsolete and deprecated Config.
checking for ffi.h in /usr/local/include... no
checking for rb_thread_blocking_region()... yes
creating extconf.h
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines in the history. See bash(1) for more options
export HISTCONTROL=ignoredups
# ... and ignore same sucessive entries.
export HISTCONTROL=ignoreboth
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
class Matrix[T: Numeric: Manifest](val xDim:Int, val yDim:Int, private val data:Array[T]) {
require(data.size == xDim*yDim, "provided data dosn't match required dimensions")
val numeric = implicitly[Numeric[T]]
val manifest:Manifest[T] = implicitly
//...
override def toString = "Matrix[%s](%s)" format (manifest, data.grouped(xDim).map( "(%s)" format _.mkString(", ") ).mkString(", "))
}
object Matrix {
@salzig
salzig / aufgabe5.scala
Created April 24, 2012 21:50
Scala Aufgabe 5
package aufgabe5
class Matrix[T](val xDim:Int, val yDim:Int, protected val data:Array[T])(implicit num : Numeric[T], m : Manifest[T]) {
val numeric = num
val manifest = m
def apply(x:Int, y:Int):T =
if (x < 0 || x >= xDim || y < 0 || y >= yDim)
numeric.zero
else