Skip to content

Instantly share code, notes, and snippets.

View hugs's full-sized avatar
🤖
Making robots

Jason Huggins hugs

🤖
Making robots
View GitHub Profile
@hugs
hugs / bot.js
Last active August 29, 2015 14:23
Bot.js for Tapster for use with digital servos
var sleep = require('sleep');
five = require("johnny-five");
ik = require("./ik");
board = new five.Board({ debug: false });
board.on("ready", function() {
// Setup
servo1 = five.Servo({
address: 0x40,
controller: "PCA9685",
@hugs
hugs / example.js
Last active August 29, 2015 14:23 — forked from jackskalitzky/lines
> var linesRaw = fs.readFileSync('lines.json', 'utf8');
> lines = JSON.parse(linesRaw)
[ [ { x: 122.01388549804688, y: 183.01388549804688 },
{ x: 119.01388549804688, y: 195.01388549804688 },
{ x: 115.01388549804688, y: 307.0138854980469 },
{ x: 115.01388549804688, y: 354.0138854980469 },
{ x: 117.01388549804688, y: 360.0138854980469 } ],
[ { x: 206.01388549804688, y: 177.01388549804688 },
{ x: 204.01388549804688, y: 194.01388549804688 },
{ x: 202.01388549804688, y: 287.0138854980469 },
@hugs
hugs / README.md
Last active December 28, 2016 19:16 — forked from elidupuis/README.md
Simple Drawing Example

Simple Drawing Example

Click and drag your mouse (or finger on touch device) to draw a line. A new path is created for each touch or click.

Paths are stored in a nested array; you can inspect the variable in console: session (assuming the example is in it's own window).

@hugs
hugs / draw-a-circle.js
Last active August 29, 2015 14:22
Draws a circle using a Tapster robot
var centerX=0;
var centerY=0;
var radius=20;
// an array to save your points
var points=[];
// populate array with points along a circle
for (var degree=0; degree<360; degree++){
var radians = degree * Math.PI/180;
@hugs
hugs / motion.js
Last active January 26, 2018 00:09
An improved algorithm for controlling Tapster motion
/*
// Usage:
// motion.move(pointA, pointB, numberOfSteps, easingType, timeDeltaInMilliseconds)
// Example
$ node bot.js
>> motion = require('./motion')
>> motion.move([0,0,-140],[-20,20,-140], 20, 'easeInOutCubic', 500)
>> motion.move([-20,60,-165],[-20,-60,-165], 30, 'easeInOutCubic', 20)
>> motion.move([-20,-60,-165],[-20,60,-165], 30, 'easeInOutCubic', 20)
@hugs
hugs / 1_print_problems_and_answers.py
Last active August 29, 2015 14:06
Addition and Subtraction Practice Problems (Hundred Thousands)
from random import randint
problems = []
def print_problem(operation):
a = randint(100000, 999999)
b = randint(100000, 999999)
if b > a:
a,b = b,a
@hugs
hugs / tranquility_base_hotel.txt
Last active August 29, 2015 14:06
Tranquility Base Hotel - Chapter 1
Tranquility Base Hotel
by Jason Huggins
Chapter 1
"That's the stupidest idea I ever heard," said Jack, senior partner at Sand
Hill Road's storied Exemplar Capital, who jumped into the meeting 20 minutes
late. "Seriously, is this a joke?"
@hugs
hugs / archive-twitpic-data.py
Last active August 29, 2015 14:06
Twitpic Image and Data Archiver
# Archive your Twitpic photos and metadata
#
# A cleaned-up fork of Terence Eden's original archiver:
# http://shkspr.mobi/blog/2013/08/exporting-twitpic-images-python/
#
# License: MIT
import urllib
import urllib2
import json
@hugs
hugs / knock.py
Last active August 29, 2015 13:57
Knock-on-Wood-Bot
# Step 1: Get a dancebot (https://github.com/hugs/dancebot)
# Step 2: Find wooden box
# Step 3: Run this code
from BreakfastSerial import Arduino, Servo
from time import sleep
board = Arduino()
s1 = Servo(board, "9")
s2 = Servo(board, "10")
@hugs
hugs / sync-is-great-for-testing.js
Last active October 4, 2018 05:56
A simple Node.js script that uses synchronous APIs for automated testing with Selenium WebDriver. Yes, I said "synchronous". Deal with it -- 'cause it's awesome.
var WebDriver = require('webdriver-http-sync');
var sleep = require('teddybear');
driver = new WebDriver('http://localhost:4444/wd/hub', {browserName:"firefox"});
// Look, no callbacks!
driver.navigateTo('http://pinthing.com');
// Oh my, I need a break. I can't handle the awesome.
sleep(5000);