Skip to content

Instantly share code, notes, and snippets.

View chtzvt's full-sized avatar
🌻
‍To create a little flower is the labor of ages.

Charlton Trezevant chtzvt

🌻
‍To create a little flower is the labor of ages.
View GitHub Profile
@chtzvt
chtzvt / tikteck_cheerlights.py
Last active September 4, 2016 01:28
Python script that continually sets the color of your tikteck bulb to the current Cheerlights color.
import time
import tikteck # See https://github.com/mjg59/python-tikteck
import urllib2
# Bulb connection information - HW address, name and password specific to your bulb. See tikteck repo for additional info.
bulb_config = ("00:21:4d:00:00:01", "Smart Light", "password")
def updateColor(bulb):
try:
latest_color = urllib2.urlopen('http://api.thingspeak.com/channels/1417/field/2/last.txt');
var seta = 'A train makes only two stops after its starting point. At the first stop, one third of the passengers get off and twenty new passengers get on. At the second stop, the remaining sixty passengers get off. How many passengers were there originally?'.replace(/[.,\/#!$%\^&\*";:{}=\-_`~()?]/g,"").split(' ');
["A", "train", "makes", "only", "two", "stops", "after", "its", "starting", "point", "At", "the", "first", "stop", "one", "third", "of", "the", "passengers", "get", "off", "and", "twenty", "new", "passengers", "get", "on", "At", "the", "second", "stop", "the", "remaining", "sixty", "passengers", "get", "off", "How", "many", "passengers", "were", "there", "originally"]
var alengths = [];
for(var i = 0; i < b.length; i++){
alengths.push(seta[i].length);
}
[1, 5, 5, 4, 3, 5, 5, 3, 8, 5, 2, 3, 5, 4, 3, 5, 2, 3, 10, 3, 3, 3, 6, 3, 10, 3, 2, 2, 3, 6, 4, 3, 9, 5, 10, 3, 3]
Charltons-MacBook-Air:clevbot charlton$ node main.js
BOT 1: What's up?
BOT 1: Oh Damn b1
BOT 1: Okay Nothing.
BOT 2: Okay, sure. Eggs have nothing to do with the core concepts of Buddhism.
BOT 1: Maybe I would if you knew how to keep a relationship intact!
BOT 2: Okay Nothing.
BOT 1: Okay Nothing.
BOT 2: I can't.
BOT 2: It is movie with Jennifer Lawrence.
@chtzvt
chtzvt / cleverloop.js
Created September 8, 2016 20:22
Have Cleverbot.io talk to itself
// Have Cleverbot.io talk to itself
// Generally somewhat entertaining, see https://gist.github.com/ctrezevant/119a92c430a7a61134505995461abf66 for an
// example transcript.
// Charlton Trezevant - 2016 - Unlicense
var BOT1 = {
CLEVERBOTIO_API_USER: ' ',
CLEVERBOTIO_API_KEY: ' ',
CLEVERBOTIO_NICK: 'none',
};
@chtzvt
chtzvt / imgurProxy.js
Last active September 12, 2016 04:15
Proxies Imgur links through Google Cloud Functions
var request = require('request');
var IMGUR_API_KEY = '<your key here>';
exports.fetchImage = function fetchImage(req, res) {
if (req.path === undefined || req.path.length <= 1) {
res.status(400).send('{"error":"No Data"}');
return;
}
@chtzvt
chtzvt / server.js
Last active October 20, 2016 13:42
speedRacer v1.0 - 3 track Pinewood Derby timer with web UI
// moved to https://github.com/ctrezevant/speedRacer !
@chtzvt
chtzvt / main.c
Created February 13, 2017 17:59
Ouija board controller
/* Hardware configuration data is apparently handled by #pragma directives.
const static char* MOTOR_NAME = 'forward'; // Name of motor
const static POTENTIOMETER_PIN = 1; // analog port on VEX controller where pot connected
*/
// Configuration and constants for mathematical calculations
const static int DEGREE_DISTANCE_BETWEEN_LETTERS = 10; // degree distance between each letter. Letters are equidistant from one another
const static int POINTER_TOLERANCE = 5; // Leeway for pointing to letter
const static int MOTOR_SPEED = 32; // Speed at which to move motor
const static int WAIT_TIME_SEC = 2; // Number of milliseconds to wait on each letter
@chtzvt
chtzvt / simpleOuijaController.c
Last active March 2, 2017 03:27
Given a VEX Cortex with a motor and potentiometer, this program will allow you to control a pointer in order to spell arbitrary strings.
#pragma config(Sensor, in1, POT, sensorPotentiometer)
#pragma config(Motor, port1, MOTOR1, tmotorVex269_HBridge, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
const static int TOLERANCE = 1; // Leeway for pointing to letter
const static int MOTOR_SPEED = 32; // Speed at which to move motor
const static int WAIT_TIME_SEC = 2; // Number of seconds to wait on each letter
// Function should return degree value of position of letters on the dial.
// (Forgive me, for I know not of how to implement a proper lookup table in C)
@chtzvt
chtzvt / imgurProxy-album.js
Created February 24, 2017 00:25
Google Cloud Function which, when given an Imgur album ID, this will serve a proxied version via imgurProxy.js.
var request = require('request');
var IMGUR_API_KEY = ' ';
var PROXY_URL = 'us-central1-[...].cloudfunctions.net';
exports.album = function album (req, res) {
if (req.path === undefined || req.path.length <= 1) {
res.status(400).send('{"error":"No Data"}');
return;
}
/* Documentation:
* Assuming an Arduino Mega with the Adafruit Motor Shield and a
* stepper motor with a 1.8deg resolution connected to M1 and M2
* Your IDE should have the AFMotor library installed before compilation.
* This software manages the movement of a dial connected to a stepper motor,
* for use in the demonstration of a caesar cipher (see https://en.wikipedia.org/wiki/Caesar_cipher)
* How movement is calculated:
* Steps per revolution: (360/motorResolution) + optional stepOffset
* Steps to move: (stepsPerRevolution/dialSections) * shiftAmount
* Examples: