Skip to content

Instantly share code, notes, and snippets.

View dermatthias's full-sized avatar

Matthias Schneider dermatthias

View GitHub Profile
### Keybase proof
I hereby claim:
* I am dermatthias on github.
* I am dermatthias (https://keybase.io/dermatthias) on keybase.
* I have a public key whose fingerprint is AC02 AA14 BA11 3F8D E75E 9D0A D870 E61F DA5A 94C4
To claim this, I am signing this object:
(defn process-file
[file-name line-func line-acc]
(reduce line-func line-acc (read-lines file-name)))
(defn process-line-data
[acc line]
(let [l (.split line "\t")]
(assoc acc (first l) (vec (rest l)))))
(defn euclidean
"berechnet den (modifizierten) euklidischen abstand zwischen zwei usern"
[active other]
(Math/sqrt (reduce + (map (fn [movie]
(let [features (item-map movie)]
(reduce + (map (fn [feat] (diff active other movie feat)) features)) ))
(common-items active other)))))
(defn pearson-fast
[v1 v2]
(let [dim (double (count v1))
meanv1 (/ (areduce v1 i ret 0
(+ ret (aget v1 i))) dim)
meanv2 (/ (areduce v2 i ret 0
(+ ret (aget v2 i))) dim)
sum (areduce v1 i ret 0
(+ ret (* (- (aget v1 i) meanv1)
(- (aget v2 i) meanv2))))
(ns com.freiheit.clojure.appengine.appengine-local
(:use
[compojure.http routes servlet helpers]
clojure.contrib.test-is
compojure.server.jetty
[clojure.contrib def str-utils duck-streams])
(:require
[clojure.contrib.logging :as log])
(:import
[com.google.appengine.api.labs.taskqueue.dev LocalTaskQueue]
import android.os.Handler;
import android.os.Looper;
import com.squareup.otto.Bus;
public class MainThreadBus extends Bus {
private final Handler mainThread = new Handler(Looper.getMainLooper());
@Override public void post(final Object event) {
if (Looper.myLooper() == Looper.getMainLooper()) {
# -*- coding: utf-8 -*-
import paho.mqtt.client as mqtt
import time
import json
import base64
def on_connect(client, userdata, flags, rc):
print("Connected with result code " + str(rc))
dev_eui = 'ZZZZZ'
@dermatthias
dermatthias / gist:ff80764120db3e24232e1e69cf2e127e
Last active October 20, 2018 11:20
TTN Ulm Minster Node - Basic Example
#include <lmic.h>
#include <hal/hal.h>
#include <SPI.h>
// TODO: fill in your credentials here
static const PROGMEM u1_t NWKSKEY[16] = ;
static const u1_t PROGMEM APPSKEY[16] = ;
static const u4_t DEVADDR = ;
void os_getArtEui (u1_t* buf) { }
@dermatthias
dermatthias / eddystone.java
Last active March 19, 2024 20:30
Parse Eddystone URL with Android Beacon Library
// m:2-2=10 for scanning for URL frames (00 = UID, 20 = TLM)
BeaconParser eddystoneURLBeaconParser = new BeaconParser().setBeaconLayout("s:0-1=feaa,m:2-2=10,p:3-3:-41,i:4-13,i:14-19");
beaconManager.getBeaconParsers().add(eddystoneURLBeaconParser);
//....(search for beacons with didRangeBeaconsInRegion() etc.)
String url = new String(beacon.getId1().toByteArray(), "UTF-8");