Skip to content

Instantly share code, notes, and snippets.

Gabriel Baciu motiooon

Block or report user

Report or block motiooon

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:9a3a4c5902cff347699c
var raspi = require('raspi-io');
var five = require('johnny-five');
var board = new five.Board({
io: new raspi()
});
// Initialize the board
board.on('ready', function () {
var Motor1A = 'P1-16';
View gist:99148367b307d17cc08d
var raspi = require('raspi-io');
var five = require('johnny-five');
var board = new five.Board({
io: new raspi()
});
// Initialize the board
board.on('ready', function () {
// var Motor1A = 'P1-16';
View gist:55cbee1d993364362df9
pi@raspberrypi ~/projects/robot $ sudo node start.js
1420336684394 Device(s) RaspberryPi-IO
1420336684555 Connected RaspberryPi-IO
1420336684561 Repl Initialized
>>
/home/pi/projects/robot/start.js:28
board.pinMode(Motor1A, board.MODES.OUTPUT);
^
TypeError: Cannot read property 'OUTPUT' of undefined
at Board.<anonymous> (/home/pi/projects/robot/start.js:28:37)
View gist:bb1b979469f7c69bacd5
var raspi = require('raspi-io');
var board = new raspi();
// Initialize the board
board.on('ready', function () {
// var Motor1A = 'P1-16';
// var Motor1B = 'P1-18';
// var Motor1E = 'P1-22';
View gist:eb5be4823d3e3a133c50
var raspi = require('raspi-io');
var board = new raspi();
// Read a pin value
console.log(board.pins[board.normalize('P1-7')].value);
// Initialize the board
board.on('ready', function () {
var Motor1A = 'P1-16';
View gist:ffb7e92d853e7d426110
var mongoose = require('mongoose'),
request = require('request'),
async = require('async'),
config = require('../config/config'),
_ = require('lodash');
var helpers = require('../loopback_helpers');
/**
* Do Search
View gist:3a44b092d5c5318891b7
function lbPick (a){
var str = '';
a.forEach(function(field){
str+='&filter[fields]['+field+']=1';
});
return str;
}
function lbGetPage(page){
var str = '&filter[limit]=50&filter[skip]=' + ((page-1) * 50);
View boot.js
// This script will boot app.js with the number of workers
// specified in WORKER_COUNT.
//
// The master will respond to SIGHUP, which will trigger
// restarting all the workers and reloading the app.
var cluster = require('cluster');
var workerCount = process.env.WORKER_COUNT || 2;
// Defines what each worker needs to run
@motiooon
motiooon / gist:8426785
Last active Jan 3, 2016
Find reversed words in a string. O(n) this time.
View gist:8426785
var string = "qwertyuiopasdfghjleirbaglgabrielmnbvcdrgythacnakancajuilsre";
function find_reverses(str){
var j = 0;
var potential_reverses = [];
while(j < string.length){
if(string[j] === string[j+2]){
potential_reverses.push({letter:string[j], index: j+2});
}
View gist:8421888
function bSearch(items, value){
var startIndex = 0;
var stopIndex = items.length-1;
var middle = Math.floor((startIndex + stopIndex)/2);
while(value !== items[middle] && startIndex < stopIndex){
if(value > items[middle]){
startIndex = middle + 1;
}else if(value < items[middle]){
You can’t perform that action at this time.