Skip to content

Instantly share code, notes, and snippets.

View cdbkr's full-sized avatar

Francesco Paolo Vitullo cdbkr

View GitHub Profile
// Bootstrap models
fs.readdirSync(__dirname + '/app/models').forEach(function (file) {
require(__dirname + '/app/models/' + file)
})
@cdbkr
cdbkr / init-leap
Last active January 2, 2016 11:59
Initialize LeapMotion js
var controller = new Leap.Controller({enableGestures:true});
controller.on('connect', function() {
console.log("Successfully connected.");
});
controller.on('deviceConnected', function() {
console.log("A Leap device has been connected.");
});
var map;
function initialize() {
var mapOptions = {
zoom: 8,
center: new google.maps.LatLng(-34.397, 150.644)
};
map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
}
controller.on('frame', function(frame){
data = frame;
if(data && data.hands.length > 0){
if(data.hands[0].palmPosition[1] < PALM_MAP_MOVE_THRESHOLD){
map.panBy(data.hands[0].palmPosition[0]/10,data.hands[0].palmPosition[2]/10);
}else if(data.hands[0].palmPosition[1] > PALM_MAP_TYPE_THRESHOLD){
checkFingers(data);
}
}
});
@cdbkr
cdbkr / who-am-i template.html
Last active August 29, 2015 13:56
who-am-i template.html
<link rel="import" href="bower_components/polymer/polymer.html">
<polymer-element name="who-am-i">
<template>
<section>
<p>My name is <strong>{{name}}</strong>!
I am <strong>{{age}}</strong> years old.
I love <strong>{{fav_thing}}</strong></p>
<label for="ageInput">Age:</label>
<input id="ageInput" type="range" value="{{age}}">
@cdbkr
cdbkr / polymer-first-example.html
Last active August 29, 2015 13:56
polymer-first-example.html
<!DOCTYPE html>
<html>
<head>
<script src="bower_components/platform/platform.js"></script>
<link rel="import" href="who-am-i.html">
</head>
<body>
<who-am-i></who-am-i>
</body>
</html>
@cdbkr
cdbkr / gist:7bed75e6892466daff8d
Created June 26, 2014 22:21
polymer in webview issue
06-27 00:07:36.350: I/chromium(3877): [INFO:CONSOLE(13)] "Uncaught TypeError: undefined is not a function", source: file:///android_asset/components/platform/platform.js (13)
06-27 00:07:36.360: I/chromium(3877): [INFO:CONSOLE(13)] "Uncaught TypeError: undefined is not a function", source: file:///android_asset/components/platform/platform.js (13)
06-27 00:07:36.360: I/chromium(3877): [INFO:CONSOLE(13)] "Uncaught TypeError: undefined is not a function", source: file:///android_asset/components/platform/platform.js (13)
06-27 00:07:36.390: I/chromium(3877): [INFO:CONSOLE(12)] "Exception caught during observer callback: TypeError: undefined is not a function
06-27 00:07:36.390: I/chromium(3877): at b.classList (file:///android_asset/components/platform/platform.js:13:20941)
06-27 00:07:36.390: I/chromium(3877): at Polymer.selectedIndexChanged (data:text/javascript;base64,CgogIFBvbHltZXIoJ3BhcGVyLXRhYnMnLCB7CiAgICAKICAgIC8qKgogICAgICogSWYgdHJ1ZSwgaW5rIGVmZmVjdCBpcyBkaXNhYmxlZC4KICAgICAqCiAgICAgKiBAYXR0cm
@cdbkr
cdbkr / simple-martini
Created November 24, 2014 14:42
Simple Martini snippet Golang
package main
import "github.com/go-martini/martini"
func main() {
m := martini.Classic()
m.Get("/", func() string {
return "Hello world!"
})
m.Run()
@cdbkr
cdbkr / server
Last active August 29, 2015 14:10
Go Bluemix Watson main
package main
//
// 1
//
import (
"github.com/go-martini/martini"
"github.com/martini-contrib/render"
"encoding/json"
"encoding/base64"
const React = require('react');
const ReactAtellier = require('react-atellier')(React);
class AtellierWrapper extends React.Component{
render() {
const Icon = React.createClass({
render: function() {
return (
<div>
hello