Skip to content

Instantly share code, notes, and snippets.

View eklimcz-zz's full-sized avatar

Erik Klimczak eklimcz-zz

View GitHub Profile
@eklimcz-zz
eklimcz-zz / gist:980d5cbc26923234e9c0
Created April 22, 2015 19:25
Threejs extrude geometry
//use Extrude Geometry to give it depth, and add it to the scene.
var geometry = new THREE.ExtrudeGeometry( cube,
{
bevelEnabled: false, bevelSegments: 0, steps:20, amount: 80
});
//we're using a dark gray flat material
cubeMesh = new THREE.Mesh( geometry, new THREE.MeshLambertMaterial( {
color: 0x333333,
shading: THREE.FlatShading
@eklimcz-zz
eklimcz-zz / gist:9294e027a2a319b4ed91
Created April 22, 2015 19:24
three.js line drawing
var cube = new THREE.Shape();
cube.moveTo(80.0,80.0);
cube.lineTo(0.0, 79.0);
cube.lineTo(0.0, 0.0);
cube.lineTo(80.0, 0.0);
cube.lineTo(80.0, 80.0);
@eklimcz-zz
eklimcz-zz / gist:55bda51a8a72b841dd36
Created April 22, 2015 19:00
Get Accerlerometer values
//check for mobile and accerlerometer support
if(this.isMobile && window.DeviceOrientationEvent) {
//wireup the event
window.addEventListener('deviceorientation', function(eventData){
//grab the accelerometer values
this.target.x = eventData.gamma * 2; //exaggerate the effect
this.target.y = eventData.beta * 3;
@eklimcz-zz
eklimcz-zz / gist:50df07bee6b6e67133e5
Last active February 12, 2018 07:42
Beacon Client render
$(document).ready(function() {
var socket = io('http://localhost/client');
var linearScale = d3.scale.linear()
.domain([0, 20])
.range([20, 1000]);
socket.on('connected', function(msg) {
console.log('connected to server');
@eklimcz-zz
eklimcz-zz / gist:446b56c0cb9cfe61d575
Created December 15, 2014 05:54
RSSI to Distance Conversion
function calculateDistance(rssi) {
var txPower = -59 //hard coded power value. Usually ranges between -59 to -65
if (rssi == 0) {
return -1.0;
}
var ratio = rssi*1.0/txPower;
if (ratio < 1.0) {
@eklimcz-zz
eklimcz-zz / gist:9973c7b97d4930d827c9
Last active August 29, 2015 14:11
basic node app for ble scanner
var express = require('express');
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
var scanner = io.of('/scanner');
scanner.on('connection', function(socket) {
console.log('Scanner Connected');
@eklimcz-zz
eklimcz-zz / gist:225d4617cc10e40b3053
Last active February 12, 2018 08:46
Basic scanning with Noble
var noble = require('noble');
//replace localhost with your server's IP;
var socket = require('socket.io-client')('http://localhost/scanner');
//replace with your hardware address
var addressToTrack = '7c669d9b2dda';
socket.on('connect', function(){
console.log('connected to server');
@eklimcz-zz
eklimcz-zz / gist:b37c05b29d9ac7cdd040
Last active July 14, 2020 17:43
Noble basic scan
noble.startScanning();
noble.on(‘discover’, function(peripheral) {
var macAddress = peripheral.uuid;
var rss = peripheral.rssi;
var localName = advertisement.localName;
console.log('found device: ', macAdress, ' ', localName, ' ', rss);
}
# sudo hcitool lescan
LE Scan ...
7C:66:9D:9B:2D:DA (unknown)
7C:66:9D:9B:2D:DA Estimote
7C:66:9D:9B:2D:DA (unknown)
7C:66:9D:9B:2D:DA (unknown)
@eklimcz-zz
eklimcz-zz / gist:9047048
Created February 17, 2014 08:54
Box-Sizing
*, *:before, *:after {
-moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box;
}