Skip to content

Instantly share code, notes, and snippets.

View pandermatt's full-sized avatar
🎉
Party

Pascal Andermatt pandermatt

🎉
Party
View GitHub Profile
brew services stop postgresql
rm /usr/local/var/postgres/postmaster.pid # adjust path accordingly to your install
brew services start postgresql
@pandermatt
pandermatt / MusicPlayer
Created August 23, 2018 10:08
Play Math Functions
function startMusic() {
(function myLoop(i) {
setTimeout(function () {
var x = i / 10;
var tone = Math.floor(1/(Math.sqrt(Math.pow(x, Math.cos(x)))) * 100);
console.log(tone);
playNote(600 - tone, 50);
i++;
myLoop(i);
}, 30)
@pandermatt
pandermatt / Ackermann.java
Created December 15, 2017 12:23
Ackermann
public class Ackermann {
// Definition of the Ackermann function
// a(0, m) = m + 1
// a(n + 1, 0) = a(n, 1)
// a(n + 1, m + 1) = a(n, a(n + 1, m))
private static int a(int n, int m) {
if (n == 0) {
return m + 1;
} else if (m == 0) {
@pandermatt
pandermatt / EuclidAlgorithm.java
Created December 15, 2017 12:21
EuclidAlgorithm
public class EuclidAlgorithm {
public static void main(String[] args) {
System.out.println("GGT: " + ggt(99,78));
}
private static int ggt(int y, int x) {
if (x > y) {
x = x + y;
y = x - y;