Skip to content

Instantly share code, notes, and snippets.

@cmsunu28
cmsunu28 / agent.nut
Created December 8, 2020 19:53
imp001 impExplorer agent code: control an LED from the internet
// HTTP
function requestHandler(request,response) {
try {
server.log(http.jsonencode(request.query));
if ("led" in request.query) {
device.send("set.led",request.query.led);
}
response.send(200,"OK");
} catch (err) {
response.send(500,"ERROR: "+err);
@cmsunu28
cmsunu28 / device.nut
Created December 8, 2020 19:52
imp001 impExplorer device code: control an LED from the internet
// turn the LED a color
#require "WS2812.class.nut:3.0.0"
local spi = hardware.spi257;
spi.configure(MSB_FIRST,7500);
hardware.pin1.configure(DIGITAL_OUT,1);
local led = WS2812(spi,1);
function setRGB(colorcode) {
local rgb = split(colorcode,",");
led.set(0,[rgb[0].tointeger(),rgb[1].tointeger(),rgb[2].tointeger()]);
led.draw();
@cmsunu28
cmsunu28 / yule-log-fixer.js
Created December 24, 2019 07:02
injectable code to watchyulelog.com to fix the vimeo api error
// copy and paste this whole thing into the console
// kludgy, but gets the job done
// works on chrome
// step 1: inject code at https://player.vimeo.com/api/player.js
// (if you had access, you would just add <script> tag to this)
/*! @vimeo/player v2.10.0 | (c) 2019 Vimeo | MIT License | https://github.com/vimeo/player.js */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e=e||self).Vimeo=e.Vimeo||{},e.Vimeo.Player=t())}(this,function(){"use strict";function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var e="undefined"!=typeof global&&"[object global]"==={}.toString.call(global);function i(e,t){return 0===e.indexOf(t.toLowerCase())?e:"".concat(t.toLowerCase()).concat(e.substr(0,1).toUpperCase()).concat(e.substr(1))}function s(e){return/^(https?:)?\/\/((player|www)\.)?vimeo\.com(?=$|\/)/.test(e)}function l()
module['exports'] = function echoHttp (hook) {
var https = require('https');
var querystring = require('querystring');
var env = hook.env;
var token = env.particle_access_token;
var deviceID = env.particle_doorbell_device_id;
// don't forget to define these secret variables at hook.io/env
var request = require('request');
var nickname = hook.params["name"];
@cmsunu28
cmsunu28 / bumpy-lumpy.ino
Created March 3, 2016 18:02
pothole-sensor
#define MIC_PIN A0 // Microphone is attached to this analog pin
#define DC_OFFSET 0 // DC offset in mic signal - if unusure, leave 0
#define NOISE 10 // Noise/hum/interference in mic signal
#define SAMPLES 60 // Length of buffer for dynamic level adjustment
#define VIB_PIN A7
#define SIGNAL_PIN D7
// time values
date close
0:0:0 1
0:0:1 0
0:0:2 0
0:0:3 1
0:0:4 1
0:0:5 1
0:0:6 1
0:0:7 1
0:0:8 1
@cmsunu28
cmsunu28 / arc-reactor.ino
Created October 2, 2015 19:57
arc reactor
// This #include statement was automatically added by the Particle IDE.
#include "InternetButton/InternetButton.h"
#include "math.h"
// SYSTEM_MODE(SEMI_AUTOMATIC);
long startTime2 = 0;
int alreadyDown2 = 0;
@cmsunu28
cmsunu28 / photoresistor-subscribe-publish.ino
Created May 7, 2015 23:14
Photoresistors Part Three: Subscribe and Publish
/*---OH HI THERE, WELCOME TO THE PHOTORESISTOR PROGRAM---
Part Three-- Publish and Subscribe with your Photoresistor and a Buddy
We will assume here that you've already done part one.
Now for Part Two-- the part where you get a buddy.
Go find a buddy who also has a Spark device.
Each of you will pick a unique event name
(make it weird so that no one else will have it)
@cmsunu28
cmsunu28 / photoresistor-breakbeam.ino
Created May 7, 2015 22:47
Photoresistors Part Two: Sensing Motion
/*---OH HI THERE, WELCOME TO THE PHOTORESISTOR PROGRAM---
Part Two: Sensing motion with your photoresistor
We're going to assume that you've already checked out Part One!
This app will make it so that you know when the beam of light
between the LED and the photoresistor is broken.
It essentially makes a little tripwire sensor out of your LED and photoresistor.
@cmsunu28
cmsunu28 / photoresistor-variable.html
Created May 7, 2015 16:48
Photoresistors Part One: Turning on and off from the internet
<!-- Replace your-device-ID-goes-here with your actual device ID
and replace your-access-token-goes-here with your actual access token-->
<center>
<br>
<br>
<br>
<form action="https://api.spark.io/v1/devices/your-device-ID-goes-here/led?access_token=your-access-token-goes-here" method="POST">
Tell your device what to do!<br>
<br>