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
import numpy as np
import matplotlib.pyplot as plt
xax = np.array([1.7,7.7,18.8,27.2,34.5,37.5,37.8,38.1,36.8,35.7,34.9])
yax = np.array(["0-9","10-19","20-29","30-39","40-49","50-59","60-69","70-79","80-89","90-99","100-109"])
values, base = np.histogram(xax, bins=10)
cum = np.cumsum(values)
yax_arrange = y_axis = np.arange(1, len(yax) + 1, 1)
@chtzvt
chtzvt / cheerlights.html
Created September 3, 2016 21:25
Displays the latest Cheerlights color in your web browser
<head>
<!--
Cheerlights for the Web.
Created by Charlton Trezevant (2016), MIT License
What is Cheerlights? See http://cheerlights.com
Live Demo: http://cheerlights.ctis.me
-->
<title>Cheerlights</title>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script src="https://code.jquery.com/color/jquery.color-2.1.2.min.js"></script>
@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');
@chtzvt
chtzvt / shitmemes.js
Last active September 4, 2016 01:30
Automatically reply to Twitter direct messages with terrible memes
var CONFIG = {
BOT_NAME: ' ',
TWITTER_API_KEYS: {
consumer_key: ' ',
consumer_secret: ' ',
access_token: ' ',
access_token_secret: ' ',
},
IMGUR_CLIENT_ID: ' ',
GIPHY_API_KEY: 'dc6zaTOxFJmzC', // Giphy's default public API key, from their wiki
@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 / 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;
}
@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)
/* 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: