Skip to content

Instantly share code, notes, and snippets.

View laszlokorte's full-sized avatar

Laszlo Korte laszlokorte

View GitHub Profile
<?php
file_put_contents(__DIR__ . '/test.txt', "Hello World");
?>
// Only scalar values, both for parameters and return values.
// Calculation must be split into 2 methods. Ugly code, duplicate calculations.
public final class VectorMath {
public static double getRotatedX(final double x, final double y,
final double angle) {
return x * Math.cos(angle) - y * Math.sin(angle);
}
@laszlokorte
laszlokorte / Main.java
Last active August 29, 2015 14:24
JScrollpane and Textarea
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;
import javax.swing.Box;
@laszlokorte
laszlokorte / after-aab22
Last active December 19, 2015 15:09
dart-box2d before and after vector_math aabb2 port
Running Ball Drop
Ball Drop (10 steps, 10 solve loops) : 27 ms (370.3703703703704 steps/second)
Checksum: -1.8194444444444444
Ball Drop (10 steps, 30 solve loops) : 10 ms (1000.0 steps/second)
Checksum: -1.8194444444444444
Ball Drop (100 steps, 10 solve loops) : 39 ms (2564.102564102564 steps/second)
Checksum: -30.69444444444442
@laszlokorte
laszlokorte / with vector_math
Created July 8, 2013 17:36
Benchmark of Dart-Box2d comparing the before and after port to vector_math library.
Running Ball Drop
Ball Drop (10 steps, 10 solve loops) : 23 ms (434.7826086956522 steps/second)
Checksum: -1.8194442838430405
Ball Drop (10 steps, 30 solve loops) : 9 ms (1111.111111111111 steps/second)
Checksum: -1.8194442838430405
Ball Drop (100 steps, 10 solve loops) : 42 ms (2380.9523809523807 steps/second)
Checksum: -30.694456100463867
#lang racket
(define (anfangskurs A B D)
(define alpha (my-acos (/ (- (sin B) (* (cos D) (sin A))) (* (cos A) (sin D)))))
(cond
[(< 180 alpha) (- 360 alpha) alpha]))
#lang racket
(define (degree->cardinal degree)
(case (modulo (inexact->exact (round (* 32 (/ degree 360)))) 32)
((0) "N")
((1) "NbE")
((2) "NNE")
((3) "NEbN")
((4) "NE")
((5) "NEbE")
#lang racket
(define (helper dir1 dir2 sub)
(cond
[(= sub 1) dir1]
[(= (modulo sub 4) 0) (string-append "b" dir1)]
[(= (modulo sub 2) 0) (string-append "b" dir2)]
))
(define directions "NESESWNW")
@laszlokorte
laszlokorte / gist:3941116
Created October 23, 2012 19:47
Uni Hamburg - SE3-Übung #1 2012
#lang racket
(define (degree->radian degree)
(* (/ (* 2 pi) 360) degree))
(define (radian->degree radian)
(* (/ 360 (* pi)) radian))
(define (my-acos alpha)
(if (= alpha 0)
@laszlokorte
laszlokorte / trait.php
Created July 23, 2011 19:24
Is this possible in php 5.4 with the new traits feature?
<?php
/**
* Is this possible in php5.4 using traits?
*/
trait Hashmap {
public function set($key, $val) {
$this->data[$key] = $val;